diff options
| author | mo khan <mo@mokhan.ca> | 2025-05-14 17:25:31 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-05-14 17:25:31 -0600 |
| commit | 89e982185563ef9372db605b0dbf2482e311d0d9 (patch) | |
| tree | b0443dffaa526243adb55444fa1f1f0466d65ca8 | |
| parent | 5f252043974fc326a1b6903d3dea0a3b1945ec33 (diff) | |
refactor: use the existing oidc TestServer
| -rw-r--r-- | test/integration/container_test.go | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/test/integration/container_test.go b/test/integration/container_test.go index fcb9d27..b956250 100644 --- a/test/integration/container_test.go +++ b/test/integration/container_test.go @@ -9,23 +9,22 @@ import ( "testing" "time" - "github.com/oauth2-proxy/mockoidc" playwright "github.com/playwright-community/playwright-go" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/testcontainers/testcontainers-go" "github.com/xlgmokha/x/pkg/env" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc" ) -func environmentVariables(srv *mockoidc.MockOIDC) map[string]string { - config := srv.Config() +func environmentVariables(srv *oidc.TestServer) map[string]string { return map[string]string{ "APP_ENV": "test", "BIND_ADDR": ":8080", "DEBUG": env.Fetch("DEBUG", ""), "HMAC_SESSION_SECRET": "secret", - "OAUTH_CLIENT_ID": config.ClientID, - "OAUTH_CLIENT_SECRET": config.ClientSecret, + "OAUTH_CLIENT_ID": srv.MockOIDC.ClientID, + "OAUTH_CLIENT_SECRET": srv.MockOIDC.ClientSecret, "OAUTH_REDIRECT_URL": "", "OIDC_ISSUER": srv.Issuer(), } @@ -35,8 +34,8 @@ func TestContainer(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) defer cancel() - srv := NewOIDCTestServer(t) - defer srv.Shutdown() + srv := oidc.NewTestServer(t) + defer srv.Close() container := NewContainer(t, ctx, environmentVariables(srv)) defer testcontainers.TerminateContainer(container) @@ -96,7 +95,7 @@ func TestContainer(t *testing.T) { require.NoError(t, page.GetByText("Login").Click()) // The envoy.yaml configuration has a hardcoded path that doesn't match the one provided by mockoidc // because the oauth2 envoy filter doesn't support the OIDC discovery endpoint. - assert.Contains(t, page.URL(), srv.AuthorizationEndpoint()+"?client_id="+srv.Config().ClientID) + assert.Contains(t, page.URL(), srv.AuthorizationEndpoint()+"?client_id="+srv.MockOIDC.ClientID) }) }) }) |
