diff --git a/pkg/handler/handler_test.go b/pkg/handler/handler_test.go index b048aba..529a5d6 100644 --- a/pkg/handler/handler_test.go +++ b/pkg/handler/handler_test.go @@ -419,6 +419,17 @@ func TestSession_WithRefresh(t *testing.T) { assert.Equal(t, int64(-1), data.Session.TimeoutInSeconds) } +func TestPing(t *testing.T) { + cfg := mock.Config() + idp := mock.NewIdentityProvider(cfg) + defer idp.Close() + + rpClient := idp.RelyingPartyClient() + resp := get(t, rpClient, idp.RelyingPartyServer.URL+"/oauth2/ping") + assert.Equal(t, http.StatusOK, resp.StatusCode) + assert.Equal(t, "pong", resp.Body) +} + func localLogin(t *testing.T, rpClient *http.Client, idp *mock.IdentityProvider) response { // First, run /oauth2/login to set cookies loginURL, err := url.Parse(idp.RelyingPartyServer.URL + "/oauth2/login") diff --git a/pkg/router/paths/paths.go b/pkg/router/paths/paths.go index 4adbe16..6dc054b 100644 --- a/pkg/router/paths/paths.go +++ b/pkg/router/paths/paths.go @@ -8,5 +8,6 @@ const ( LogoutCallback = "/logout/callback" LogoutFrontChannel = "/logout/frontchannel" LogoutLocal = "/logout/local" + Ping = "/ping" Session = "/session" ) diff --git a/pkg/router/router.go b/pkg/router/router.go index 0a21efa..d63fa46 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -68,6 +68,10 @@ func New(src Source, cfg *config.Config) chi.Router { r.Get(paths.LogoutCallback, src.LogoutCallback) r.Get(paths.LogoutFrontChannel, src.LogoutFrontChannel) r.Get(paths.LogoutLocal, src.LogoutLocal) + r.Get(paths.Ping, func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + w.Write([]byte("pong")) + }) r.Route(paths.Session, func(r chi.Router) { if cfg.SSO.Enabled && cfg.SSO.Mode == config.SSOModeServer {