TestHandleCreateAPIKey_RejectsPastExpiresAt: a past timestamp must be a 400 — silently swallowing it would issue a key that's already expired, which is worse UX than rejecting at create time.
(t *testing.T)
| 242 | // be a 400 — silently swallowing it would issue a key that's already |
| 243 | // expired, which is worse UX than rejecting at create time. |
| 244 | func TestHandleCreateAPIKey_RejectsPastExpiresAt(t *testing.T) { |
| 245 | ua, _, token := setupUserAuth(t) |
| 246 | |
| 247 | past := time.Now().Add(-1 * time.Hour).UTC().Format(time.RFC3339) |
| 248 | req := authedJSON("POST", "/api/keys", token, `{"name":"backdated","expires_at":"`+past+`"}`) |
| 249 | w := httptest.NewRecorder() |
| 250 | ua.HandleCreateAPIKey(w, req) |
| 251 | |
| 252 | if w.Code != http.StatusBadRequest { |
| 253 | t.Errorf("status = %d, want 400; body=%s", w.Code, w.Body.String()) |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | // TestHandleCreateAPIKey_RejectsMalformedExpiresAt: not-RFC-3339 → |
| 258 | // 400, not "silently fall back to NULL." The handler chooses to fail |
nothing calls this directly
no test coverage detected