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

Function TestEnrollNodeIDMismatch

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

Source from the content-addressed store, hash-verified

163}
164
165func TestEnrollNodeIDMismatch(t *testing.T) {
166 ca := newTestCA(t)
167 store := enrolltokens.NewMemoryStore()
168 ctx := context.Background()
169 tok := enrolltokens.Token{Token: "tk-mm", NodeID: "node-A", ExpiresAt: time.Now().Add(time.Hour)}
170 _ = store.Insert(ctx, tok)
171
172 mux := http.NewServeMux()
173 RegisterEnrollEndpoint(mux, ca, store, "")
174 w := doEnroll(t, mux, enrollRequest{NodeID: "node-B", CSRPem: newTestCSR(t, "node-B"), Token: tok.Token})
175 if w.Code != http.StatusUnauthorized {
176 t.Fatalf("status=%d body=%s", w.Code, w.Body.String())
177 }
178}
179
180func TestEnrollInvalidCSR(t *testing.T) {
181 ca := newTestCA(t)

Callers

nothing calls this directly

Calls 8

InsertMethod · 0.95
NewMemoryStoreFunction · 0.92
RegisterEnrollEndpointFunction · 0.85
doEnrollFunction · 0.85
newTestCSRFunction · 0.85
AddMethod · 0.80
newTestCAFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected