Skip to content

Commit 7768139

Browse files
authored
chore: revert OIDC test change (#7257)
Revert "chore: simply OIDC test (#7196)" Signed-off-by: Huabing Zhao <[email protected]>
1 parent fc08dbd commit 7768139

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

test/e2e/tests/oidc-backendcluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ func init() {
2323
var OIDCBackendClusterTest = suite.ConformanceTest{
2424
ShortName: "OIDC with BackendCluster",
2525
Description: "Test OIDC authentication",
26-
Manifests: []string{"testdata/oidc-keycloak.yaml", "testdata/oidc-securitypolicy-backendcluster.yaml"},
26+
Manifests: []string{"testdata/oidc-keycloak.yaml"},
2727
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
2828
t.Run("oidc provider represented by a BackendCluster", func(t *testing.T) {
29-
testOIDC(t, suite)
29+
testOIDC(t, suite, "testdata/oidc-securitypolicy-backendcluster.yaml")
3030
})
3131
},
3232
}

test/e2e/tests/oidc.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,22 @@ func init() {
4848
var OIDCTest = suite.ConformanceTest{
4949
ShortName: "OIDC",
5050
Description: "Test OIDC authentication",
51-
Manifests: []string{"testdata/oidc-keycloak.yaml", "testdata/oidc-securitypolicy.yaml"},
51+
Manifests: []string{"testdata/oidc-keycloak.yaml"},
5252
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
5353
t.Run("oidc provider represented by a URL", func(t *testing.T) {
54-
testOIDC(t, suite)
54+
testOIDC(t, suite, "testdata/oidc-securitypolicy.yaml")
5555
})
5656

5757
t.Run("oidc bypass", func(t *testing.T) {
5858
ns := "gateway-conformance-infra"
59+
60+
podInitialized := corev1.PodCondition{Type: corev1.PodInitialized, Status: corev1.ConditionTrue}
5961
// Wait for the keycloak pod to be configured with the test user and client
60-
WaitForPods(t, suite.Client, ns, map[string]string{"app": "keycloak"}, corev1.PodRunning, &PodReady)
62+
WaitForPods(t, suite.Client, ns, map[string]string{"job-name": "setup-keycloak"}, corev1.PodSucceeded, &podInitialized)
63+
64+
// Apply the security policy that configures OIDC authentication
65+
suite.Applier.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, "testdata/oidc-securitypolicy.yaml", true)
66+
6167
routeWithOIDCNN := types.NamespacedName{Name: "http-with-oidc", Namespace: ns}
6268
routeWithoutOIDCNN := types.NamespacedName{Name: "http-without-oidc", Namespace: ns}
6369
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
@@ -112,7 +118,7 @@ var OIDCTest = suite.ConformanceTest{
112118
},
113119
}
114120

115-
func testOIDC(t *testing.T, suite *suite.ConformanceTestSuite) {
121+
func testOIDC(t *testing.T, suite *suite.ConformanceTestSuite, securityPolicyManifest string) {
116122
var (
117123
testURL = "http://www.example.com/myapp"
118124
logoutURL = "http://www.example.com/myapp/logout"
@@ -121,8 +127,12 @@ func testOIDC(t *testing.T, suite *suite.ConformanceTestSuite) {
121127
ns = "gateway-conformance-infra"
122128
)
123129

130+
podInitialized := corev1.PodCondition{Type: corev1.PodInitialized, Status: corev1.ConditionTrue}
124131
// Wait for the keycloak pod to be configured with the test user and client
125-
WaitForPods(t, suite.Client, ns, map[string]string{"app": "keycloak"}, corev1.PodRunning, &PodReady)
132+
WaitForPods(t, suite.Client, ns, map[string]string{"job-name": "setup-keycloak"}, corev1.PodSucceeded, &podInitialized)
133+
134+
// Apply the security policy that configures OIDC authentication
135+
suite.Applier.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, securityPolicyManifest, true)
126136

127137
routeNN := types.NamespacedName{Name: route, Namespace: ns}
128138
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
@@ -179,6 +189,7 @@ func testOIDC(t *testing.T, suite *suite.ConformanceTestSuite) {
179189
},
180190
}
181191
require.NoError(t, suite.Client.Delete(context.TODO(), existingSP))
192+
suite.Applier.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, securityPolicyManifest, false)
182193
SecurityPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: sp, Namespace: ns}, suite.ControllerName, ancestorRef)
183194
return false, nil
184195
}

0 commit comments

Comments
 (0)