feat(security): add cookie support for login and logout methods

* Implement LoginWithCookie and LogoutWithCookie in stubAuthenticator, mockAuth, mockSecurityProvider, and MockAuthenticator
* Update tests to use cookie-based authentication
This commit is contained in:
Hein
2026-05-21 09:51:30 +02:00
parent 76909ae869
commit e5984f5205
5 changed files with 37 additions and 1 deletions

View File

@@ -511,6 +511,10 @@ func TestDatabaseAuthenticator(t *testing.T) {
})
t.Run("authenticate with cookie", func(t *testing.T) {
cookieAuth := NewDatabaseAuthenticatorWithOptions(db, DatabaseAuthenticatorOptions{
EnableCookieSession: true,
})
req := httptest.NewRequest("GET", "/test", nil)
req.AddCookie(&http.Cookie{
Name: "session_token",
@@ -524,7 +528,7 @@ func TestDatabaseAuthenticator(t *testing.T) {
WithArgs("cookie-token-456", "cookie").
WillReturnRows(rows)
userCtx, err := auth.Authenticate(req)
userCtx, err := cookieAuth.Authenticate(req)
if err != nil {
t.Fatalf("expected no error, got %v", err)
}