diff options
Diffstat (limited to 'app/controllers/sessions/controller_test.go')
| -rw-r--r-- | app/controllers/sessions/controller_test.go | 16 |
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) |
