Skip to content

Commit 5cfb904

Browse files
Merge pull request #29915 from QiWang19/wip-timeouttest
OCPBUGS-58132: OCPFeatureGate:SigstoreImageVerification use multi arch image for testing
2 parents ba35eab + 64eb31d commit 5cfb904

File tree

1 file changed

+23
-58
lines changed

1 file changed

+23
-58
lines changed

test/extended/imagepolicy/imagepolicy.go

Lines changed: 23 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ import (
1616
"k8s.io/client-go/util/retry"
1717
e2e "k8s.io/kubernetes/test/e2e/framework"
1818
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
19-
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
2019
admissionapi "k8s.io/pod-security-admission/api"
2120
)
2221

2322
const (
24-
testReleaseImageScope = "quay.io/openshift-release-dev/ocp-release@sha256:fbad931c725b2e5b937b295b58345334322bdabb0b67da1c800a53686d7397da"
25-
testReferenceImageScope = "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:4db234f37ae6712e2f7ed8d13f7fb49971c173d0e4f74613d0121672fa2e01f5"
23+
testSignedPolicyScope = "quay.io/openshifttest/busybox-testsigstoresigned@sha256:c5439d7db88ab5423999530349d327b04279ad3161d7596d2126dfb5b02bfd1f"
2624
registriesWorkerPoolMachineConfig = "99-worker-generated-registries"
2725
registriesMasterPoolMachineConfig = "99-master-generated-registries"
2826
testPodName = "signature-validation-test-pod"
@@ -52,12 +50,6 @@ var _ = g.Describe("[sig-imagepolicy][OCPFeatureGate:SigstoreImageVerification][
5250
if !exutil.IsTechPreviewNoUpgrade(tctx, oc.AdminConfigClient()) {
5351
g.Skip("skipping, this feature is only supported on TechPreviewNoUpgrade clusters")
5452
}
55-
56-
outStr, err := oc.Run("adm", "release", "info", testReleaseImageScope).Args("-o=go-template", "--template={{.digest}}").Output()
57-
if err != nil || outStr == "" {
58-
o.Expect(err).ToNot(o.HaveOccurred())
59-
e2eskipper.Skipf("can't validate %s release image for testing, consider updating the test", testReleaseImageScope)
60-
}
6153
})
6254

6355
g.It("Should fail clusterimagepolicy signature validation root of trust does not match the identity in the signature", func() {
@@ -66,7 +58,7 @@ var _ = g.Describe("[sig-imagepolicy][OCPFeatureGate:SigstoreImageVerification][
6658

6759
waitForPoolComplete(oc)
6860

69-
pod, err := launchTestPod(tctx, clif, testPodName, testReleaseImageScope)
61+
pod, err := launchTestPod(tctx, clif, testPodName, testSignedPolicyScope)
7062
o.Expect(err).NotTo(o.HaveOccurred())
7163
g.DeferCleanup(deleteTestPod, tctx, clif, testPodName)
7264

@@ -75,8 +67,8 @@ var _ = g.Describe("[sig-imagepolicy][OCPFeatureGate:SigstoreImageVerification][
7567
})
7668

7769
g.It("Should fail clusterimagepolicy signature validation when scope in allowedRegistries list does not skip signature verification", func() {
78-
// Ensure allowedRegistries do not skip signature verification by adding testReleaseImageScope to the list
79-
allowedRegistries := []string{"quay.io", "registry.redhat.io", "image-registry.openshift-image-registry.svc:5000", testReleaseImageScope}
70+
// Ensure allowedRegistries do not skip signature verification by adding testSignedPolicyScope to the list.
71+
allowedRegistries := []string{"quay.io", "registry.redhat.io", "image-registry.openshift-image-registry.svc:5000", testSignedPolicyScope}
8072
updateImageConfig(oc, allowedRegistries)
8173
g.DeferCleanup(cleanupImageConfig, oc)
8274

@@ -85,7 +77,7 @@ var _ = g.Describe("[sig-imagepolicy][OCPFeatureGate:SigstoreImageVerification][
8577

8678
waitForPoolComplete(oc)
8779

88-
pod, err := launchTestPod(tctx, clif, testPodName, testReleaseImageScope)
80+
pod, err := launchTestPod(tctx, clif, testPodName, testSignedPolicyScope)
8981
o.Expect(err).NotTo(o.HaveOccurred())
9082
g.DeferCleanup(deleteTestPod, tctx, clif, testPodName)
9183

@@ -99,7 +91,7 @@ var _ = g.Describe("[sig-imagepolicy][OCPFeatureGate:SigstoreImageVerification][
9991

10092
waitForPoolComplete(oc)
10193

102-
pod, err := launchTestPod(tctx, clif, testPodName, testReleaseImageScope)
94+
pod, err := launchTestPod(tctx, clif, testPodName, testSignedPolicyScope)
10395
o.Expect(err).NotTo(o.HaveOccurred())
10496
g.DeferCleanup(deleteTestPod, tctx, clif, testPodName)
10597

@@ -110,20 +102,21 @@ var _ = g.Describe("[sig-imagepolicy][OCPFeatureGate:SigstoreImageVerification][
110102
g.It("Should fail imagepolicy signature validation in different namespaces root of trust does not match the identity in the signature", func() {
111103
createImagePolicy(oc, testImagePolicies[invalidPublicKeyImagePolicyName], imgpolicyClif.Namespace.Name)
112104
g.DeferCleanup(deleteImagePolicy, oc, invalidPublicKeyImagePolicyName, imgpolicyClif.Namespace.Name)
105+
waitForPoolComplete(oc)
113106

114107
createImagePolicy(oc, testImagePolicies[invalidPublicKeyImagePolicyName], clif.Namespace.Name)
115108
g.DeferCleanup(deleteImagePolicy, oc, invalidPublicKeyImagePolicyName, clif.Namespace.Name)
116109

117110
waitForPoolComplete(oc)
118111

119-
pod, err := launchTestPod(tctx, imgpolicyClif, testPodName, testReferenceImageScope)
112+
pod, err := launchTestPod(tctx, imgpolicyClif, testPodName, testSignedPolicyScope)
120113
o.Expect(err).NotTo(o.HaveOccurred())
121114
g.DeferCleanup(deleteTestPod, tctx, imgpolicyClif, testPodName)
122115

123116
err = waitForTestPodContainerToFailSignatureValidation(tctx, imgpolicyClif, pod)
124117
o.Expect(err).NotTo(o.HaveOccurred())
125118

126-
pod, err = launchTestPod(tctx, clif, testPodName, testReferenceImageScope)
119+
pod, err = launchTestPod(tctx, clif, testPodName, testSignedPolicyScope)
127120
o.Expect(err).NotTo(o.HaveOccurred())
128121
g.DeferCleanup(deleteTestPod, tctx, clif, testPodName)
129122

@@ -134,20 +127,21 @@ var _ = g.Describe("[sig-imagepolicy][OCPFeatureGate:SigstoreImageVerification][
134127
g.It("Should pass imagepolicy signature validation with signed image in namespaces", func() {
135128
createImagePolicy(oc, testImagePolicies[publiKeyRekorImagePolicyName], clif.Namespace.Name)
136129
g.DeferCleanup(deleteImagePolicy, oc, publiKeyRekorImagePolicyName, clif.Namespace.Name)
130+
waitForPoolComplete(oc)
137131

138132
createImagePolicy(oc, testImagePolicies[publiKeyRekorImagePolicyName], imgpolicyClif.Namespace.Name)
139133
g.DeferCleanup(deleteImagePolicy, oc, publiKeyRekorImagePolicyName, imgpolicyClif.Namespace.Name)
140134

141135
waitForPoolComplete(oc)
142136

143-
pod, err := launchTestPod(tctx, clif, testPodName, testReferenceImageScope)
137+
pod, err := launchTestPod(tctx, clif, testPodName, testSignedPolicyScope)
144138
o.Expect(err).NotTo(o.HaveOccurred())
145139
g.DeferCleanup(deleteTestPod, tctx, clif, testPodName)
146140

147141
err = e2epod.WaitForPodSuccessInNamespace(tctx, clif.ClientSet, pod.Name, pod.Namespace)
148142
o.Expect(err).NotTo(o.HaveOccurred())
149143

150-
pod, err = launchTestPod(tctx, imgpolicyClif, testPodName, testReferenceImageScope)
144+
pod, err = launchTestPod(tctx, imgpolicyClif, testPodName, testSignedPolicyScope)
151145
o.Expect(err).NotTo(o.HaveOccurred())
152146
g.DeferCleanup(deleteTestPod, tctx, imgpolicyClif, testPodName)
153147

@@ -215,6 +209,7 @@ func launchTestPod(ctx context.Context, f *e2e.Framework, podName, image string)
215209
Name: contName,
216210
Image: image,
217211
ImagePullPolicy: kapiv1.PullAlways,
212+
Command: []string{"/bin/sh", "-c", "exit 0"},
218213
},
219214
},
220215
RestartPolicy: kapiv1.RestartPolicyNever,
@@ -263,7 +258,7 @@ func generateClusterImagePolicies() map[string]configv1alpha1.ClusterImagePolicy
263258
invalidPublicKeyClusterImagePolicyName: {
264259
ObjectMeta: metav1.ObjectMeta{Name: invalidPublicKeyClusterImagePolicyName},
265260
Spec: configv1alpha1.ClusterImagePolicySpec{
266-
Scopes: []configv1alpha1.ImageScope{testReleaseImageScope},
261+
Scopes: []configv1alpha1.ImageScope{testSignedPolicyScope},
267262
Policy: configv1alpha1.Policy{
268263
RootOfTrust: configv1alpha1.PolicyRootOfTrust{
269264
PolicyType: configv1alpha1.PublicKeyRootOfTrust,
@@ -280,34 +275,19 @@ func generateClusterImagePolicies() map[string]configv1alpha1.ClusterImagePolicy
280275
publiKeyRekorClusterImagePolicyName: {
281276
ObjectMeta: metav1.ObjectMeta{Name: publiKeyRekorClusterImagePolicyName},
282277
Spec: configv1alpha1.ClusterImagePolicySpec{
283-
Scopes: []configv1alpha1.ImageScope{testReleaseImageScope},
278+
Scopes: []configv1alpha1.ImageScope{testSignedPolicyScope},
284279
Policy: configv1alpha1.Policy{
285280
RootOfTrust: configv1alpha1.PolicyRootOfTrust{
286281
PolicyType: configv1alpha1.PublicKeyRootOfTrust,
287282
PublicKey: &configv1alpha1.PublicKey{
288283
KeyData: []byte(`-----BEGIN PUBLIC KEY-----
289-
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0ASyuH2TLWvBUqPHZ4Ip
290-
75g7EncBkgQHdJnjzxAW5KQTMh/siBoB/BoSrtiPMwnChbTCnQOIQeZuDiFnhuJ7
291-
M/D3b7JoX0m123NcCSn67mAdjBa6Bg6kukZgCP4ZUZeESajWX/EjylFcRFOXW57p
292-
RDCEN42J/jYlVqt+g9+Grker8Sz86H3l0tbqOdjbz/VxHYhwF0ctUMHsyVRDq2QP
293-
tqzNXlmlMhS/PoFr6R4u/7HCn/K+LegcO2fAFOb40KvKSKKVD6lewUZErhop1CgJ
294-
XjDtGmmO9dGMF71mf6HEfaKSdy+EE6iSF2A2Vv9QhBawMiq2kOzEiLg4nAdJT8wg
295-
ZrMAmPCqGIsXNGZ4/Q+YTwwlce3glqb5L9tfNozEdSR9N85DESfQLQEdY3CalwKM
296-
BT1OEhEX1wHRCU4drMOej6BNW0VtscGtHmCrs74jPezhwNT8ypkyS+T0zT4Tsy6f
297-
VXkJ8YSHyenSzMB2Op2bvsE3grY+s74WhG9UIA6DBxcTie15NSzKwfzaoNWODcLF
298-
p7BY8aaHE2MqFxYFX+IbjpkQRfaeQQsouDFdCkXEFVfPpbD2dk6FleaMTPuyxtIT
299-
gjVEtGQK2qGCFGiQHFd4hfV+eCA63Jro1z0zoBM5BbIIQ3+eVFwt3AlZp5UVwr6d
300-
secqki/yrmv3Y0dqZ9VOn3UCAwEAAQ==
301-
-----END PUBLIC KEY-----`),
302-
RekorKeyData: []byte(`-----BEGIN PUBLIC KEY-----
303-
MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEDk0ElgGvMrsJULkg/ji1XX7EngDl2WY7
304-
c75kKKy/SwWQ8n3Zymomy4DtkXzjsju204Mgjtdc7dVSPGSBn7VLLdDIzqSd1mLE
305-
2ybPRzY8g742Mn/5hgH4eBzNKBjZ3wv1
284+
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEKvZH0CXTk8XQkETuxkzkl3Bi4ms5
285+
60l1/qUU0fRATNSCVORCog5PDFo5z0ZLeblWgwbn4c8xpvuo9jQFwpeOsg==
306286
-----END PUBLIC KEY-----`),
307287
},
308288
},
309289
SignedIdentity: configv1alpha1.PolicyIdentity{
310-
MatchPolicy: configv1alpha1.IdentityMatchPolicyMatchRepoDigestOrExact,
290+
MatchPolicy: configv1alpha1.IdentityMatchPolicyMatchRepository,
311291
},
312292
},
313293
},
@@ -321,7 +301,7 @@ func generateImagePolicies() map[string]configv1alpha1.ImagePolicy {
321301
invalidPublicKeyImagePolicyName: {
322302
ObjectMeta: metav1.ObjectMeta{Name: invalidPublicKeyImagePolicyName},
323303
Spec: configv1alpha1.ImagePolicySpec{
324-
Scopes: []configv1alpha1.ImageScope{testReferenceImageScope},
304+
Scopes: []configv1alpha1.ImageScope{testSignedPolicyScope},
325305
Policy: configv1alpha1.Policy{
326306
RootOfTrust: configv1alpha1.PolicyRootOfTrust{
327307
PolicyType: configv1alpha1.PublicKeyRootOfTrust,
@@ -338,34 +318,19 @@ func generateImagePolicies() map[string]configv1alpha1.ImagePolicy {
338318
publiKeyRekorImagePolicyName: {
339319
ObjectMeta: metav1.ObjectMeta{Name: publiKeyRekorImagePolicyName},
340320
Spec: configv1alpha1.ImagePolicySpec{
341-
Scopes: []configv1alpha1.ImageScope{testReferenceImageScope},
321+
Scopes: []configv1alpha1.ImageScope{testSignedPolicyScope},
342322
Policy: configv1alpha1.Policy{
343323
RootOfTrust: configv1alpha1.PolicyRootOfTrust{
344324
PolicyType: configv1alpha1.PublicKeyRootOfTrust,
345325
PublicKey: &configv1alpha1.PublicKey{
346326
KeyData: []byte(`-----BEGIN PUBLIC KEY-----
347-
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0ASyuH2TLWvBUqPHZ4Ip
348-
75g7EncBkgQHdJnjzxAW5KQTMh/siBoB/BoSrtiPMwnChbTCnQOIQeZuDiFnhuJ7
349-
M/D3b7JoX0m123NcCSn67mAdjBa6Bg6kukZgCP4ZUZeESajWX/EjylFcRFOXW57p
350-
RDCEN42J/jYlVqt+g9+Grker8Sz86H3l0tbqOdjbz/VxHYhwF0ctUMHsyVRDq2QP
351-
tqzNXlmlMhS/PoFr6R4u/7HCn/K+LegcO2fAFOb40KvKSKKVD6lewUZErhop1CgJ
352-
XjDtGmmO9dGMF71mf6HEfaKSdy+EE6iSF2A2Vv9QhBawMiq2kOzEiLg4nAdJT8wg
353-
ZrMAmPCqGIsXNGZ4/Q+YTwwlce3glqb5L9tfNozEdSR9N85DESfQLQEdY3CalwKM
354-
BT1OEhEX1wHRCU4drMOej6BNW0VtscGtHmCrs74jPezhwNT8ypkyS+T0zT4Tsy6f
355-
VXkJ8YSHyenSzMB2Op2bvsE3grY+s74WhG9UIA6DBxcTie15NSzKwfzaoNWODcLF
356-
p7BY8aaHE2MqFxYFX+IbjpkQRfaeQQsouDFdCkXEFVfPpbD2dk6FleaMTPuyxtIT
357-
gjVEtGQK2qGCFGiQHFd4hfV+eCA63Jro1z0zoBM5BbIIQ3+eVFwt3AlZp5UVwr6d
358-
secqki/yrmv3Y0dqZ9VOn3UCAwEAAQ==
359-
-----END PUBLIC KEY-----`),
360-
RekorKeyData: []byte(`-----BEGIN PUBLIC KEY-----
361-
MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEDk0ElgGvMrsJULkg/ji1XX7EngDl2WY7
362-
c75kKKy/SwWQ8n3Zymomy4DtkXzjsju204Mgjtdc7dVSPGSBn7VLLdDIzqSd1mLE
363-
2ybPRzY8g742Mn/5hgH4eBzNKBjZ3wv1
327+
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEKvZH0CXTk8XQkETuxkzkl3Bi4ms5
328+
60l1/qUU0fRATNSCVORCog5PDFo5z0ZLeblWgwbn4c8xpvuo9jQFwpeOsg==
364329
-----END PUBLIC KEY-----`),
365330
},
366331
},
367332
SignedIdentity: configv1alpha1.PolicyIdentity{
368-
MatchPolicy: configv1alpha1.IdentityMatchPolicyMatchRepoDigestOrExact,
333+
MatchPolicy: configv1alpha1.IdentityMatchPolicyMatchRepository,
369334
},
370335
},
371336
},

0 commit comments

Comments
 (0)