TestHandleCreateAPIKey_RejectsMalformedExpiresAt: not-RFC-3339 → 400, not "silently fall back to NULL." The handler chooses to fail loudly because misformed input is a real client bug worth surfacing.
(t *testing.T)
| 258 | // 400, not "silently fall back to NULL." The handler chooses to fail |
| 259 | // loudly because misformed input is a real client bug worth surfacing. |
| 260 | func TestHandleCreateAPIKey_RejectsMalformedExpiresAt(t *testing.T) { |
| 261 | ua, _, token := setupUserAuth(t) |
| 262 | |
| 263 | req := authedJSON("POST", "/api/keys", token, `{"name":"bad","expires_at":"next-tuesday"}`) |
| 264 | w := httptest.NewRecorder() |
| 265 | ua.HandleCreateAPIKey(w, req) |
| 266 | |
| 267 | if w.Code != http.StatusBadRequest { |
| 268 | t.Errorf("status = %d, want 400; body=%s", w.Code, w.Body.String()) |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | // --- PATCH /api/auth/me (Item #8) --- |
| 273 |
nothing calls this directly
no test coverage detected