mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2026-05-21 19:45:33 +00:00
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:
@@ -25,10 +25,18 @@ func (s *stubAuthenticator) Login(_ context.Context, _ LoginRequest) (*LoginResp
|
||||
return &LoginResponse{Token: "tok"}, nil
|
||||
}
|
||||
|
||||
func (s *stubAuthenticator) LoginWithCookie(ctx context.Context, req LoginRequest, _ http.ResponseWriter) (*LoginResponse, error) {
|
||||
return s.Login(ctx, req)
|
||||
}
|
||||
|
||||
func (s *stubAuthenticator) Logout(_ context.Context, _ LogoutRequest) error {
|
||||
return s.err
|
||||
}
|
||||
|
||||
func (s *stubAuthenticator) LogoutWithCookie(ctx context.Context, req LogoutRequest, _ http.ResponseWriter) error {
|
||||
return s.Logout(ctx, req)
|
||||
}
|
||||
|
||||
func TestChainAuthenticator_Authenticate(t *testing.T) {
|
||||
successCtx := &UserContext{UserID: 42, UserName: "alice"}
|
||||
failStub := &stubAuthenticator{err: fmt.Errorf("no token")}
|
||||
|
||||
Reference in New Issue
Block a user