From 059a87a80227426f854256139bbbc7309bdb6fa0 Mon Sep 17 00:00:00 2001 From: mo khan Date: Mon, 28 Apr 2025 16:51:56 -0600 Subject: feat: redirect to login page when session is established --- app/controllers/sessions/controller_test.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'app/controllers/sessions/controller_test.go') 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) {}) }) -- cgit v1.2.3