Skip to content

Commit 59ae773

Browse files
committed
Allow osd-admin user with cluster-admins group for e2e tests
Add exemption for the osd-admin user when it has the cluster-admins group to support OpenShift CI e2e tests. This is a targeted exemption that requires both the specific username AND group membership. Security rationale: - In production OSD clusters, customers cannot arbitrarily assign users to the cluster-admins group as it's managed by the OAuth infrastructure - The exemption only applies when BOTH conditions are met: username is osd-admin AND user is in cluster-admins group - This is more restrictive than the previous blanket cluster-admins group exemption that was removed in SREP-1565 This fixes CI test failures in openshift/origin endpoint admission tests where the osd-admin user needs to create privileged namespaces like kube-system for testing purposes.
1 parent fa1bfbb commit 59ae773

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

pkg/webhooks/namespace/namespace.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,15 @@ func amIAdmin(request admissionctl.Request) bool {
371371
}
372372
}
373373

374+
// Allow osd-admin user only when it's in the cluster-admins group
375+
// This is specifically for OpenShift CI e2e tests
376+
// Note: This is a security trade-off - we're allowing this specific combination
377+
// for e2e test compatibility. In production OSD clusters, customers cannot
378+
// create users with the cluster-admins group as it's managed by OAuth.
379+
if request.UserInfo.Username == "osd-admin" && slices.Contains(request.UserInfo.Groups, "cluster-admins") {
380+
return true
381+
}
382+
374383
return false
375384
}
376385

pkg/webhooks/namespace/namespace_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,3 +1162,37 @@ func TestGetURI(t *testing.T) {
11621162
t.Fatalf("Hook URI does not begin with a /")
11631163
}
11641164
}
1165+
1166+
// TestE2EAdminUser tests the e2e test user exemption
1167+
func TestE2EAdminUser(t *testing.T) {
1168+
tests := []namespaceTestSuites{
1169+
{
1170+
// osd-admin with cluster-admins group should be allowed (for CI e2e tests)
1171+
testID: "e2e-osd-admin-with-cluster-admins",
1172+
targetNamespace: "kube-system",
1173+
username: "osd-admin",
1174+
userGroups: []string{"cluster-admins", "system:authenticated:oauth", "system:authenticated"},
1175+
operation: admissionv1.Create,
1176+
shouldBeAllowed: true,
1177+
},
1178+
{
1179+
// osd-admin without cluster-admins group should be denied
1180+
testID: "osd-admin-without-cluster-admins",
1181+
targetNamespace: "kube-system",
1182+
username: "osd-admin",
1183+
userGroups: []string{"system:authenticated:oauth", "system:authenticated"},
1184+
operation: admissionv1.Create,
1185+
shouldBeAllowed: false,
1186+
},
1187+
{
1188+
// Different user with cluster-admins should still be denied (cluster-admins exemption was removed)
1189+
testID: "other-user-with-cluster-admins",
1190+
targetNamespace: "kube-system",
1191+
username: "some-other-user",
1192+
userGroups: []string{"cluster-admins", "system:authenticated:oauth", "system:authenticated"},
1193+
operation: admissionv1.Create,
1194+
shouldBeAllowed: false,
1195+
},
1196+
}
1197+
runNamespaceTests(t, tests)
1198+
}

0 commit comments

Comments
 (0)