mirror of
https://github.com/nais/wonderwall.git
synced 2026-05-16 13:26:56 +00:00
feat(router): add ping route for health probes
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -8,5 +8,6 @@ const (
|
||||
LogoutCallback = "/logout/callback"
|
||||
LogoutFrontChannel = "/logout/frontchannel"
|
||||
LogoutLocal = "/logout/local"
|
||||
Ping = "/ping"
|
||||
Session = "/session"
|
||||
)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user