MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / TestEnrollMissingFields

Function TestEnrollMissingFields

internal/serverapi/enroll_test.go:195–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

193}
194
195func 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}

Callers

nothing calls this directly

Calls 4

NewMemoryStoreFunction · 0.92
RegisterEnrollEndpointFunction · 0.85
doEnrollFunction · 0.85
newTestCAFunction · 0.70

Tested by

no test coverage detected