From 89e982185563ef9372db605b0dbf2482e311d0d9 Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 14 May 2025 17:25:31 -0600 Subject: refactor: use the existing oidc TestServer --- test/integration/container_test.go | 15 +++++++-------- 1 file 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) }) }) }) -- cgit v1.2.3