@@ -601,6 +601,23 @@ func imagePolicyTestCRs() map[string]apicfgv1alpha1.ImagePolicy {
601
601
},
602
602
},
603
603
},
604
+ "test-cr3" : {
605
+ ObjectMeta : metav1.ObjectMeta {
606
+ Name : "test-cr3" ,
607
+ Namespace : "test-1-namespace" ,
608
+ },
609
+ Spec : apicfgv1alpha1.ImagePolicySpec {
610
+ Scopes : []apicfgv1alpha1.ImageScope {"test3.com" },
611
+ Policy : apicfgv1alpha1.Policy {
612
+ RootOfTrust : apicfgv1alpha1.PolicyRootOfTrust {
613
+ PolicyType : apicfgv1alpha1 .PublicKeyRootOfTrust ,
614
+ PublicKey : & apicfgv1alpha1.PublicKey {
615
+ KeyData : testKeyData ,
616
+ },
617
+ },
618
+ },
619
+ },
620
+ },
604
621
}
605
622
return testImagePolicyCRs
606
623
}
@@ -1726,6 +1743,7 @@ func TestUpdateNamespacedPolicyJSONs(t *testing.T) {
1726
1743
testImagePolicyCR0 := clusterImagePolicyTestCRs ()["test-cr0" ]
1727
1744
testImagePolicyCR1 := clusterImagePolicyTestCRs ()["test-cr1" ]
1728
1745
testImagePolicyCR2 := imagePolicyTestCRs ()["test-cr0" ]
1746
+ testImagePolicyCR3 := imagePolicyTestCRs ()["test-cr3" ]
1729
1747
1730
1748
expectClusterPolicy := []byte (`
1731
1749
{
@@ -1825,7 +1843,7 @@ func TestUpdateNamespacedPolicyJSONs(t *testing.T) {
1825
1843
}
1826
1844
}
1827
1845
` )
1828
- expectnamespacedPolicy := []byte (`
1846
+ expectTestnamespacedPolicy := []byte (`
1829
1847
{
1830
1848
"default": [
1831
1849
{
@@ -1942,11 +1960,129 @@ func TestUpdateNamespacedPolicyJSONs(t *testing.T) {
1942
1960
}
1943
1961
` )
1944
1962
1963
+ expectTest1namespacedPolicy := []byte (`
1964
+ {
1965
+ "default": [
1966
+ {
1967
+ "type": "insecureAcceptAnything"
1968
+ }
1969
+ ],
1970
+ "transports": {
1971
+ "atomic": {
1972
+ "test0.com": [
1973
+ {
1974
+ "type": "sigstoreSigned",
1975
+ "fulcio": {
1976
+ "caData": "dGVzdC1jYS1kYXRhLWRhdGE=",
1977
+ "oidcIssuer": "https://OIDC.example.com",
1978
+ "subjectEmail": "[email protected] "
1979
+ },
1980
+ "rekorPublicKeyData": "dGVzdC1yZWtvci1rZXktZGF0YQ==",
1981
+ "signedIdentity": {
1982
+ "type": "remapIdentity",
1983
+ "prefix": "test-remap-prefix",
1984
+ "signedPrefix": "test-remap-signed-prefix"
1985
+ }
1986
+ },
1987
+ {
1988
+ "type": "sigstoreSigned",
1989
+ "keyData": "dGVzdC1rZXktZGF0YQ==",
1990
+ "rekorPublicKeyData": "dGVzdC1yZWtvci1rZXktZGF0YQ==",
1991
+ "signedIdentity": {
1992
+ "type": "remapIdentity",
1993
+ "prefix": "test-remap-prefix",
1994
+ "signedPrefix": "test-remap-signed-prefix"
1995
+ }
1996
+ }
1997
+ ],
1998
+ "test1.com": [
1999
+ {
2000
+ "type": "sigstoreSigned",
2001
+ "keyData": "dGVzdC1rZXktZGF0YQ==",
2002
+ "rekorPublicKeyData": "dGVzdC1yZWtvci1rZXktZGF0YQ==",
2003
+ "signedIdentity": {
2004
+ "type": "remapIdentity",
2005
+ "prefix": "test-remap-prefix",
2006
+ "signedPrefix": "test-remap-signed-prefix"
2007
+ }
2008
+ }
2009
+ ],
2010
+ "test3.com": [
2011
+ {
2012
+ "type": "sigstoreSigned",
2013
+ "keyData": "dGVzdC1rZXktZGF0YQ==",
2014
+ "signedIdentity": {
2015
+ "type": "matchRepoDigestOrExact"
2016
+ }
2017
+ }
2018
+ ]
2019
+ },
2020
+ "docker": {
2021
+ "test0.com": [
2022
+ {
2023
+ "type": "sigstoreSigned",
2024
+ "fulcio": {
2025
+ "caData": "dGVzdC1jYS1kYXRhLWRhdGE=",
2026
+ "oidcIssuer": "https://OIDC.example.com",
2027
+ "subjectEmail": "[email protected] "
2028
+ },
2029
+ "rekorPublicKeyData": "dGVzdC1yZWtvci1rZXktZGF0YQ==",
2030
+ "signedIdentity": {
2031
+ "type": "remapIdentity",
2032
+ "prefix": "test-remap-prefix",
2033
+ "signedPrefix": "test-remap-signed-prefix"
2034
+ }
2035
+ },
2036
+ {
2037
+ "type": "sigstoreSigned",
2038
+ "keyData": "dGVzdC1rZXktZGF0YQ==",
2039
+ "rekorPublicKeyData": "dGVzdC1yZWtvci1rZXktZGF0YQ==",
2040
+ "signedIdentity": {
2041
+ "type": "remapIdentity",
2042
+ "prefix": "test-remap-prefix",
2043
+ "signedPrefix": "test-remap-signed-prefix"
2044
+ }
2045
+ }
2046
+ ],
2047
+ "test1.com": [
2048
+ {
2049
+ "type": "sigstoreSigned",
2050
+ "keyData": "dGVzdC1rZXktZGF0YQ==",
2051
+ "rekorPublicKeyData": "dGVzdC1yZWtvci1rZXktZGF0YQ==",
2052
+ "signedIdentity": {
2053
+ "type": "remapIdentity",
2054
+ "prefix": "test-remap-prefix",
2055
+ "signedPrefix": "test-remap-signed-prefix"
2056
+ }
2057
+ }
2058
+ ],
2059
+ "test3.com": [
2060
+ {
2061
+ "type": "sigstoreSigned",
2062
+ "keyData": "dGVzdC1rZXktZGF0YQ==",
2063
+ "signedIdentity": {
2064
+ "type": "matchRepoDigestOrExact"
2065
+ }
2066
+ }
2067
+ ]
2068
+ },
2069
+ "docker-daemon": {
2070
+ "": [
2071
+ {
2072
+ "type": "insecureAcceptAnything"
2073
+ }
2074
+ ]
2075
+ }
2076
+ }
2077
+ }
2078
+ ` )
2079
+
1945
2080
expectRet := map [string ][]byte {
1946
- testImagePolicyCR2 .ObjectMeta .Namespace : expectnamespacedPolicy ,
2081
+ testImagePolicyCR2 .ObjectMeta .Namespace : expectTestnamespacedPolicy ,
2082
+ testImagePolicyCR3 .ObjectMeta .Namespace : expectTest1namespacedPolicy ,
1947
2083
}
1948
2084
1949
- clusterScopePolicies , scopeNamespacePolicies , err := getValidScopePolicies ([]* apicfgv1alpha1.ClusterImagePolicy {& testImagePolicyCR0 , & testImagePolicyCR1 }, []* apicfgv1alpha1.ImagePolicy {& testImagePolicyCR2 }, nil )
2085
+ clusterScopePolicies , scopeNamespacePolicies , err := getValidScopePolicies ([]* apicfgv1alpha1.ClusterImagePolicy {& testImagePolicyCR0 , & testImagePolicyCR1 }, []* apicfgv1alpha1.ImagePolicy {& testImagePolicyCR2 , & testImagePolicyCR3 }, nil )
1950
2086
require .NoError (t , err )
1951
2087
1952
2088
clusterOverridePolicyJSON , err := updatePolicyJSON (templatePolicyBytes , []string {}, []string {}, "release-reg.io/image/release" , clusterScopePolicies )
0 commit comments