summaryrefslogtreecommitdiff
path: root/app/controllers/sessions/controller_test.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-05-11 22:11:09 -0600
committermo khan <mo@mokhan.ca>2025-05-11 22:11:09 -0600
commit7517e20bcce760c896e6b349c98cf04f88d6e00f (patch)
treebc894004cb6ac3e14789c44a92f53987b44003b1 /app/controllers/sessions/controller_test.go
parent086300ea0dbd0ff4af320a1b4402a93f5bd87ac0 (diff)
fix: redirect to dashboard when already logged in at callback url
Diffstat (limited to 'app/controllers/sessions/controller_test.go')
-rw-r--r--app/controllers/sessions/controller_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/controllers/sessions/controller_test.go b/app/controllers/sessions/controller_test.go
index 00e3f4e..b3e1d56 100644
--- a/app/controllers/sessions/controller_test.go
+++ b/app/controllers/sessions/controller_test.go
@@ -110,6 +110,22 @@ func TestSessions(t *testing.T) {
assert.Equal(t, http.StatusBadRequest, w.Code)
})
+ t.Run("when already logged in", func(t *testing.T) {
+ t.Run("redirects to the dashboard", func(t *testing.T) {
+ user := &domain.User{}
+ r, w := test.RequestResponse(
+ "GET",
+ "/session/callback?code=valid",
+ 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 a valid authorization code grant", func(t *testing.T) {
user := mockoidc.DefaultUser()
code := srv.CreateAuthorizationCodeFor(user)