Skip to content

Commit 7646bdd

Browse files
committed
apiserver: test security context of oauth-apiserver only when authentication type is OAuth
1 parent fc008f2 commit 7646bdd

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

test/extended/apiserver/security_context.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,18 @@ import (
1212
e2e "k8s.io/kubernetes/test/e2e/framework"
1313
admissionapi "k8s.io/pod-security-admission/api"
1414

15+
configv1 "github.com/openshift/api/config/v1"
1516
exutil "github.com/openshift/origin/test/extended/util"
1617
)
1718

19+
type itemUnderTest struct {
20+
namespace string
21+
containerName string
22+
expectedHostPath string
23+
expectHostNetwork bool
24+
requireHostPathMount bool
25+
}
26+
1827
var _ = g.Describe("[sig-auth][Feature:ControlPlaneSecurity]", func() {
1928
defer g.GinkgoRecover()
2029
ctx := context.Background()
@@ -40,13 +49,7 @@ var _ = g.Describe("[sig-auth][Feature:ControlPlaneSecurity]", func() {
4049
g.Skip("Hypershift control plane pods are not accessible from hosted cluster")
4150
}
4251

43-
checkItems := []struct {
44-
namespace string
45-
containerName string
46-
expectedHostPath string
47-
expectHostNetwork bool
48-
requireHostPathMount bool
49-
}{
52+
checkItems := []itemUnderTest{
5053
{
5154
namespace: "openshift-kube-apiserver",
5255
containerName: "kube-apiserver",
@@ -61,13 +64,18 @@ var _ = g.Describe("[sig-auth][Feature:ControlPlaneSecurity]", func() {
6164
expectHostNetwork: false,
6265
requireHostPathMount: false,
6366
},
64-
{
67+
}
68+
69+
authn, err := oc.AdminConfigClient().ConfigV1().Authentications().Get(ctx, "cluster", metav1.GetOptions{})
70+
o.Expect(err).NotTo(o.HaveOccurred())
71+
if len(authn.Spec.Type) == 0 || authn.Spec.Type == configv1.AuthenticationTypeIntegratedOAuth {
72+
checkItems = append(checkItems, itemUnderTest{
6573
namespace: "openshift-oauth-apiserver",
6674
containerName: "oauth-apiserver",
6775
expectedHostPath: "",
6876
expectHostNetwork: false,
6977
requireHostPathMount: false,
70-
},
78+
})
7179
}
7280

7381
for _, checkItem := range checkItems {

0 commit comments

Comments
 (0)