Files
wonderwall/pkg/mock/client.go
Trong Huu Nguyen 1f5635239a refactor: split out openid client, config and provider
There's a bunch of changes here, but in essence:

- split out openid configuration
- separate openid configuration between client/rp and provider
- consolidate client and provider related code in separate packages

These changes allow for simplification of the Handler, as well as a
bunch of test/mock code as the configuration is now instantiated
seperately from the client/provider code.
2022-07-05 13:09:00 +02:00

79 lines
1.8 KiB
Go

package mock
import (
"github.com/lestrrat-go/jwx/v2/jwk"
"github.com/nais/wonderwall/pkg/config"
"github.com/nais/wonderwall/pkg/crypto"
"github.com/nais/wonderwall/pkg/openid/scopes"
)
type TestClientConfiguration struct {
ClientID string
ClientJWK jwk.Key
CallbackURI string
LogoutCallbackURI string
PostLogoutRedirectURI string
Scopes scopes.Scopes
ACRValues string
UILocales string
WellKnownURL string
}
func (c TestClientConfiguration) GetCallbackURI() string {
return c.CallbackURI
}
func (c TestClientConfiguration) GetClientID() string {
return c.ClientID
}
func (c TestClientConfiguration) GetClientJWK() jwk.Key {
return c.ClientJWK
}
func (c TestClientConfiguration) GetLogoutCallbackURI() string {
return c.LogoutCallbackURI
}
func (c TestClientConfiguration) GetPostLogoutRedirectURI() string {
return c.PostLogoutRedirectURI
}
func (c TestClientConfiguration) GetScopes() scopes.Scopes {
return c.Scopes
}
func (c TestClientConfiguration) GetACRValues() string {
return c.ACRValues
}
func (c TestClientConfiguration) GetUILocales() string {
return c.UILocales
}
func (c TestClientConfiguration) GetWellKnownURL() string {
return c.WellKnownURL
}
func (c TestClientConfiguration) Print() {}
func clientConfiguration(cfg *config.Config) *TestClientConfiguration {
key, err := crypto.NewJwk()
if err != nil {
panic(err)
}
return &TestClientConfiguration{
ClientID: cfg.OpenID.ClientID,
ClientJWK: key,
CallbackURI: "http://localhost/callback",
LogoutCallbackURI: "http://localhost/logout/callback",
WellKnownURL: "",
UILocales: "nb",
ACRValues: "Level4",
PostLogoutRedirectURI: "",
Scopes: scopes.DefaultScopes(),
}
}