Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions test/e2e/tests/oidc-backendcluster.go

This file was deleted.

31 changes: 14 additions & 17 deletions test/e2e/tests/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,19 @@ var OIDCTest = suite.ConformanceTest{
Description: "Test OIDC authentication",
Manifests: []string{"testdata/oidc-keycloak.yaml"},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
ns := "gateway-conformance-infra"
podInitialized := corev1.PodCondition{Type: corev1.PodInitialized, Status: corev1.ConditionTrue}
// Wait for the keycloak pod to be configured with the test user and client
WaitForPods(t, suite.Client, ns, map[string]string{"job-name": "setup-keycloak"}, corev1.PodSucceeded, &podInitialized)
// Apply the security policy after the keycloak pod is ready, this is because EG will try to fetch the
// OIDC configuration from the keycloak's well-known endpoint
suite.Applier.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, "testdata/oidc-securitypolicy.yaml", true)

t.Run("oidc provider represented by a URL", func(t *testing.T) {
testOIDC(t, suite, "testdata/oidc-securitypolicy.yaml")
})

t.Run("oidc bypass", func(t *testing.T) {
ns := "gateway-conformance-infra"

podInitialized := corev1.PodCondition{Type: corev1.PodInitialized, Status: corev1.ConditionTrue}
// Wait for the keycloak pod to be configured with the test user and client
WaitForPods(t, suite.Client, ns, map[string]string{"job-name": "setup-keycloak"}, corev1.PodSucceeded, &podInitialized)

// Apply the security policy that configures OIDC authentication
suite.Applier.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, "testdata/oidc-securitypolicy.yaml", true)

routeWithOIDCNN := types.NamespacedName{Name: "http-with-oidc", Namespace: ns}
routeWithoutOIDCNN := types.NamespacedName{Name: "http-without-oidc", Namespace: ns}
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
Expand Down Expand Up @@ -114,6 +113,12 @@ var OIDCTest = suite.ConformanceTest{
})
}
})

// Apply the security policy that configures OIDC authentication with BackendCluster
suite.Applier.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, "testdata/oidc-securitypolicy-backendcluster.yaml", true)
t.Run("oidc provider represented by a BackendCluster", func(t *testing.T) {
testOIDC(t, suite, "testdata/oidc-securitypolicy-backendcluster.yaml")
})
},
}

Expand All @@ -125,14 +130,6 @@ func testOIDC(t *testing.T, suite *suite.ConformanceTestSuite, securityPolicyMan
sp = "oidc-test"
ns = "gateway-conformance-infra"
)

podInitialized := corev1.PodCondition{Type: corev1.PodInitialized, Status: corev1.ConditionTrue}
// Wait for the keycloak pod to be configured with the test user and client
WaitForPods(t, suite.Client, ns, map[string]string{"job-name": "setup-keycloak"}, corev1.PodSucceeded, &podInitialized)

// Apply the security policy that configures OIDC authentication
suite.Applier.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, securityPolicyManifest, true)

routeNN := types.NamespacedName{Name: route, Namespace: ns}
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
httpGWAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN, "http"), routeNN)
Expand Down