diff options
| author | mo khan <mo@mokhan.ca> | 2025-05-15 09:40:06 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-05-15 09:40:06 -0600 |
| commit | a0891d0871e3db4d6b03899c58b811374bb016de (patch) | |
| tree | d9b20535e5fe6fd8838846ca0ad3a89c7fa42d21 /app/middleware | |
| parent | a636172d657fe71470455b337ef5c49191d66cbd (diff) | |
refactor: provide oauth config to oidc.New
Diffstat (limited to 'app/middleware')
| -rw-r--r-- | app/middleware/id_token_test.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/middleware/id_token_test.go b/app/middleware/id_token_test.go index b363d2c..bdeaa49 100644 --- a/app/middleware/id_token_test.go +++ b/app/middleware/id_token_test.go @@ -4,6 +4,7 @@ import ( "net/http" "testing" + xoidc "github.com/coreos/go-oidc/v3/oidc" "github.com/oauth2-proxy/mockoidc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -11,13 +12,21 @@ import ( xcfg "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/cfg" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/web" + "golang.org/x/oauth2" ) func TestIDToken(t *testing.T) { srv := oidc.NewTestServer(t) defer srv.Close() - openID := oidc.New(srv.Provider, srv.MockOIDC.ClientID, srv.MockOIDC.ClientSecret, "https://example.com/oauth/callback") + config := &oauth2.Config{ + ClientID: srv.MockOIDC.ClientID, + ClientSecret: srv.MockOIDC.ClientSecret, + RedirectURL: "https://example.com/oauth/callback", + Endpoint: srv.Provider.Endpoint(), + Scopes: []string{xoidc.ScopeOpenID, "profile", "email"}, + } + openID := oidc.New(srv.Provider, config) middleware := IDToken(openID, IDTokenFromSessionCookie) t.Run("when an active session cookie is provided", func(t *testing.T) { |
