mirror of
https://github.com/nais/wonderwall.git
synced 2026-08-23 21:16:14 +00:00
refactor(openid/config): extract getter for ingresses
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/nais/wonderwall/pkg/crypto"
|
||||
"github.com/nais/wonderwall/pkg/handler/autologin"
|
||||
"github.com/nais/wonderwall/pkg/handler/reverseproxy"
|
||||
"github.com/nais/wonderwall/pkg/ingress"
|
||||
"github.com/nais/wonderwall/pkg/loginstatus"
|
||||
"github.com/nais/wonderwall/pkg/openid/client"
|
||||
openidconfig "github.com/nais/wonderwall/pkg/openid/config"
|
||||
@@ -46,12 +47,18 @@ func NewHandler(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ingresses, err := ingress.ParseIngresses(cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &StandardHandler{
|
||||
autoLogin: autoLogin,
|
||||
client: openidClient,
|
||||
config: cfg,
|
||||
cookieOptions: cookieOpts,
|
||||
crypter: crypter,
|
||||
ingresses: ingresses,
|
||||
loginstatus: loginstatus.NewClient(cfg.Loginstatus, httpClient),
|
||||
openidConfig: openidConfig,
|
||||
provider: openidProvider,
|
||||
|
||||
@@ -34,6 +34,7 @@ type StandardHandler struct {
|
||||
config *config.Config
|
||||
cookieOptions cookie.Options
|
||||
crypter crypto.Crypter
|
||||
ingresses *ingress.Ingresses
|
||||
loginstatus loginstatus.Loginstatus
|
||||
openidConfig openidconfig.Config
|
||||
provider provider.Provider
|
||||
@@ -71,7 +72,11 @@ func (s *StandardHandler) GetErrorRedirectURI() string {
|
||||
}
|
||||
|
||||
func (s *StandardHandler) GetIngresses() *ingress.Ingresses {
|
||||
return s.openidConfig.Client().Ingresses()
|
||||
return s.ingresses
|
||||
}
|
||||
|
||||
func (s *StandardHandler) SetIngresses(ingresses *ingress.Ingresses) {
|
||||
s.ingresses = ingresses
|
||||
}
|
||||
|
||||
func (s *StandardHandler) GetLoginstatus() loginstatus.Loginstatus {
|
||||
|
||||
@@ -195,7 +195,7 @@ func TestLoginCallbackURL(t *testing.T) {
|
||||
"https://nav.no/dagpenger",
|
||||
"https://nav.no/dagpenger/soknad",
|
||||
}
|
||||
openidConfig := mock.NewTestConfiguration(cfg)
|
||||
ingresses := mock.Ingresses(cfg)
|
||||
|
||||
for _, test := range []struct {
|
||||
input string
|
||||
@@ -224,7 +224,7 @@ func TestLoginCallbackURL(t *testing.T) {
|
||||
},
|
||||
} {
|
||||
t.Run(test.input, func(t *testing.T) {
|
||||
req := mock.NewGetRequest(test.input, openidConfig)
|
||||
req := mock.NewGetRequest(test.input, ingresses)
|
||||
|
||||
actual, err := urlpkg.LoginCallbackURL(req)
|
||||
if test.err != nil {
|
||||
@@ -245,7 +245,7 @@ func TestLogoutCallbackURL(t *testing.T) {
|
||||
"https://nav.no/dagpenger",
|
||||
"https://nav.no/dagpenger/soknad",
|
||||
}
|
||||
openidConfig := mock.NewTestConfiguration(cfg)
|
||||
ingresses := mock.Ingresses(cfg)
|
||||
|
||||
for _, test := range []struct {
|
||||
input string
|
||||
@@ -274,7 +274,7 @@ func TestLogoutCallbackURL(t *testing.T) {
|
||||
},
|
||||
} {
|
||||
t.Run(test.input, func(t *testing.T) {
|
||||
req := mock.NewGetRequest(test.input, openidConfig)
|
||||
req := mock.NewGetRequest(test.input, ingresses)
|
||||
|
||||
actual, err := urlpkg.LogoutCallbackURL(req)
|
||||
if test.err != nil {
|
||||
|
||||
Reference in New Issue
Block a user