@@ -136,6 +136,9 @@ func TestValidatePodSpec(t *testing.T) {
136136 // Resolved via crane digest on 2022/09/29
137137 digestNewer := name .MustParseReference ("gcr.io/distroless/static:nonroot@sha256:2a9e2b4fa771d31fe3346a873be845bfc2159695b9f90ca08e950497006ccc2e" )
138138
139+ // Digest only reference (without tag)
140+ digestOnly := name .MustParseReference ("gcr.io/distroless/static@sha256:be5d77c62dbe7fedfb0a4e5ec2f91078080800ab1f18358e5f31fcc8faa023c4" )
141+
139142 ctx , _ := rtesting .SetupFakeContext (t )
140143
141144 // Non-existent URL for testing complete failure
@@ -681,6 +684,38 @@ func TestValidatePodSpec(t *testing.T) {
681684 },
682685 ),
683686 cvs : authorityPublicKeyCVS ,
687+ }, {
688+ name : "digest only" ,
689+ ps : & corev1.PodSpec {
690+ Containers : []corev1.Container {{
691+ Name : "user-container" ,
692+ Image : digestOnly .String (),
693+ }},
694+ },
695+ customContext : config .ToContext (context .Background (),
696+ & config.Config {
697+ ImagePolicyConfig : & config.ImagePolicyConfig {
698+ Policies : map [string ]webhookcip.ClusterImagePolicy {
699+ "cluster-image-policy" : {
700+ Images : []v1alpha1.ImagePattern {{
701+ Glob : "gcr.io/*/*" ,
702+ }},
703+ Authorities : []webhookcip.Authority {
704+ {
705+ Key : & webhookcip.KeyRef {
706+ Data : authorityKeyCosignPubString ,
707+ PublicKeys : []crypto.PublicKey {authorityKeyCosignPub },
708+ HashAlgorithm : signaturealgo .DefaultSignatureAlgorithm ,
709+ HashAlgorithmCode : crypto .SHA256 ,
710+ },
711+ },
712+ },
713+ },
714+ },
715+ },
716+ },
717+ ),
718+ cvs : pass ,
684719 }}
685720
686721 for _ , test := range tests {
0 commit comments