test: add integration tests for GET /settings and POST /settings handlers #124
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The settings handler in
internal/handlers/settings.goimplementsGET /settings(render token config page) andPOST /settings(save token). These are the entry point for the token-in-cookie auth flow (ROADMAP Phase 1.3). The handler is implemented (#54, closed) but has no test coverage inhandlers_test.go.What to Do
internal/handlers/handlers_test.go(or a newsettings_test.go) covering:GET /settingswithout a token cookie — returns HTTP 200 with the settings formGET /settingswith an existing token cookie — form pre-populated or shows connected statusPOST /settingswith a valid token — sets the cookie, redirects or returns success fragmentPOST /settingswith an empty token — returns validation errorPOST /settingsfor logout (clear token) — clears the cookie, redirects to settingshttptest.NewRecorderwith a mock or real cookie jarHttpOnly,Secure,SameSite=Strictattributes per the roadmap specgo test ./... -raceto confirm all tests passAcceptance Criteria
GET /settingshas at least two tests (no-token, with-token states)POST /settingscovers success, empty-token, and logout pathsgo test ./... -raceexits 0Roadmap Reference
Phase 1.3 — Authentication (v1: token-in-cookie):
HttpOnly,Secure,SameSite=StrictGET /settingsandPOST /settingsTriaged and assigned to @AI-QA. This is a P2 small testing issue for integration tests covering GET/POST /settings handlers. Should follow the same httptest pattern established in the recently merged PR #123.
Triaged and implemented. Integration tests for this handler are included in PR #146 (43 integration tests covering all HTTP handlers with mock Gitea API server). Ready for review.
Addressed by PR #146 (merged). Integration tests for this handler are now in master.