Files
wonderwall/pkg/openid/client/logout_callback_test.go
Trong Huu Nguyen 5a50ba7c3a feat: support multiple ingresses
Replace hardcoded callback URLs with dynamic generation
of URLs based on incoming requests. These are validated against
a pre-registered list of ingresses for which Wonderwall is considered
authorative for.

We also preserve the cookie behaviour; the most specific ingress path
and domain is used for the cookies.

The `url` package has been moved to the `handler` package, and its
implementation refactored slightly for readability and DRY.
2022-08-17 20:43:56 +02:00

42 lines
1.1 KiB
Go

package client_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/nais/wonderwall/pkg/config"
"github.com/nais/wonderwall/pkg/mock"
"github.com/nais/wonderwall/pkg/openid/client"
)
func TestLogoutCallback_PostLogoutRedirectURI(t *testing.T) {
t.Run("happy path", func(t *testing.T) {
cfg := mock.Config()
cfg.OpenID.PostLogoutRedirectURI = "http://some-fancy-logout-page"
lc := newLogoutCallback(cfg)
uri := lc.PostLogoutRedirectURI()
assert.NotEmpty(t, uri)
assert.Equal(t, "http://some-fancy-logout-page", uri)
})
t.Run("empty preconfigured post-logout redirect uri", func(t *testing.T) {
cfg := mock.Config()
cfg.OpenID.PostLogoutRedirectURI = ""
lc := newLogoutCallback(cfg)
uri := lc.PostLogoutRedirectURI()
assert.NotEmpty(t, uri)
assert.Equal(t, mock.Ingress, uri)
})
}
func newLogoutCallback(cfg *config.Config) client.LogoutCallback {
openidCfg := mock.NewTestConfiguration(cfg)
req := mock.NewGetRequest(mock.Ingress+"/oauth2/logout/callback", openidCfg)
return newTestClientWithConfig(openidCfg).LogoutCallback(req)
}