summaryrefslogtreecommitdiff
path: root/app/controllers/sessions/controller_test.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-04-28 16:51:56 -0600
committermo khan <mo@mokhan.ca>2025-04-28 16:51:56 -0600
commit059a87a80227426f854256139bbbc7309bdb6fa0 (patch)
treeebd83f6a0f57133c9a34fffaf8c20ed6d62d9250 /app/controllers/sessions/controller_test.go
parent37adeb5437d0f62f5dbc137bb98addcb9d891238 (diff)
feat: redirect to login page when session is established
Diffstat (limited to 'app/controllers/sessions/controller_test.go')
-rw-r--r--app/controllers/sessions/controller_test.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/app/controllers/sessions/controller_test.go b/app/controllers/sessions/controller_test.go
index 64c9fc1..05f642b 100644
--- a/app/controllers/sessions/controller_test.go
+++ b/app/controllers/sessions/controller_test.go
@@ -12,6 +12,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/xlgmokha/x/pkg/x"
+ xcfg "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/cfg"
+ "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/domain"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/test"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/web/cookie"
@@ -68,7 +70,22 @@ func TestSessions(t *testing.T) {
})
})
- t.Run("with an active authenicated session", func(t *testing.T) {})
+ t.Run("with an active authenicated session", func(t *testing.T) {
+ t.Run("redirects to the dashboard", func(t *testing.T) {
+ user := &domain.User{}
+ r, w := test.RequestResponse(
+ "GET",
+ "/session/new",
+ test.WithContextKeyValue(t.Context(), xcfg.CurrentUser, user),
+ )
+
+ mux.ServeHTTP(w, r)
+
+ require.Equal(t, http.StatusFound, w.Code)
+ assert.Equal(t, "/dashboard", w.Header().Get("Location"))
+ })
+ })
+
t.Run("with an expired authenicated session", func(t *testing.T) {})
})