(t *testing.T)
| 121 | } |
| 122 | |
| 123 | func 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 | |
| 141 | func TestEnrollTokenExpired(t *testing.T) { |
| 142 | ca := newTestCA(t) |
nothing calls this directly
no test coverage detected