(t *testing.T)
| 193 | } |
| 194 | |
| 195 | func TestEnrollMissingFields(t *testing.T) { |
| 196 | ca := newTestCA(t) |
| 197 | store := enrolltokens.NewMemoryStore() |
| 198 | mux := http.NewServeMux() |
| 199 | RegisterEnrollEndpoint(mux, ca, store, "") |
| 200 | |
| 201 | cases := []enrollRequest{ |
| 202 | {NodeID: "", CSRPem: "x", Token: "y"}, |
| 203 | {NodeID: "n", CSRPem: "", Token: "y"}, |
| 204 | {NodeID: "n", CSRPem: "x", Token: ""}, |
| 205 | } |
| 206 | for i, c := range cases { |
| 207 | w := doEnroll(t, mux, c) |
| 208 | if w.Code != http.StatusBadRequest { |
| 209 | t.Errorf("case %d: status=%d", i, w.Code) |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | // Invalid JSON body |
| 214 | w := doEnroll(t, mux, "{not json") |
| 215 | if w.Code != http.StatusBadRequest { |
| 216 | t.Errorf("invalid json: status=%d", w.Code) |
| 217 | } |
| 218 | } |
nothing calls this directly
no test coverage detected