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

Function TestEnrollTokenAlreadyConsumed

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

Source from the content-addressed store, hash-verified

121}
122
123func TestEnrollTokenAlreadyConsumed(t *testing.T) {
124 ca := newTestCA(t)
125 store := enrolltokens.NewMemoryStore()
126 ctx := context.Background()
127 tok := enrolltokens.Token{Token: "tk-used", NodeID: "n", ExpiresAt: time.Now().Add(time.Hour)}
128 _ = store.Insert(ctx, tok)
129 if _, err := store.Consume(ctx, tok.Token); err != nil {
130 t.Fatal(err)
131 }
132
133 mux := http.NewServeMux()
134 RegisterEnrollEndpoint(mux, ca, store, "")
135 w := doEnroll(t, mux, enrollRequest{NodeID: "n", CSRPem: newTestCSR(t, "n"), Token: tok.Token})
136 if w.Code != http.StatusUnauthorized {
137 t.Fatalf("status=%d", w.Code)
138 }
139}
140
141func TestEnrollTokenExpired(t *testing.T) {
142 ca := newTestCA(t)

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected