mirror of
https://github.com/nais/wonderwall.git
synced 2026-05-20 15:22:58 +00:00
As we already clear any local sessions before redirecting to the Identity Provider, and the callback always redirects to a pre-configured URL, there isn't really any need to maintain and verify state in the logout callback. In other words, the logout callback handler is simply a redirect handler.
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package client_test
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"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) {
|
|
lc, cfg := newLogoutCallback(t)
|
|
cfg.ClientConfig.PostLogoutRedirectURI = "http://some-fancy-logout-page"
|
|
|
|
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) {
|
|
lc, cfg := newLogoutCallback(t)
|
|
cfg.ClientConfig.PostLogoutRedirectURI = ""
|
|
cfg.WonderwallConfig.Ingress = "http://wonderwall"
|
|
|
|
uri := lc.PostLogoutRedirectURI()
|
|
assert.NotEmpty(t, uri)
|
|
assert.Equal(t, "http://wonderwall", uri)
|
|
})
|
|
}
|
|
|
|
func newLogoutCallback(t *testing.T) (client.LogoutCallback, mock.Configuration) {
|
|
req, err := http.NewRequest("GET", "http://wonderwall/oauth2/logout/callback", nil)
|
|
assert.NoError(t, err)
|
|
|
|
cfg := mock.NewTestConfiguration(mock.Config())
|
|
return newTestClientWithConfig(cfg).LogoutCallback(req), cfg
|
|
}
|