@@ -21,6 +21,7 @@ import (
2121 "fmt"
2222 "net/http"
2323 "net/url"
24+ "os"
2425 "reflect"
2526 "testing"
2627
@@ -191,3 +192,69 @@ func TestPrivateKeyVerificationWithProxy(t *testing.T) {
191192 })
192193 }
193194}
195+
196+ func TestPKBundleAttestations (t * testing.T ) {
197+ g := NewWithT (t )
198+
199+ // registryAddr := testregistry.New(t)
200+
201+ // proxyAddr, proxyPort := testproxy.New(t)
202+
203+ pubKey , err := os .ReadFile ("/Users/stealthybox/hack/cosign/cosign.pub" )
204+ g .Expect (err ).NotTo (HaveOccurred ())
205+
206+ tests := []struct {
207+ name string
208+ tagURL string
209+ }{
210+ {
211+ name : "v2" ,
212+ tagURL : "localhost:5558/v2-zot" ,
213+ },
214+ {
215+ name : "v2" ,
216+ tagURL : "localhost:5559/v2-reg" ,
217+ },
218+ {
219+ name : "v3 bundle oci 1.1 referrers" ,
220+ tagURL : "localhost:5558/v3-bundle-zot" ,
221+ },
222+ {
223+ name : "v3 bundle oci 1.0 fallback" ,
224+ tagURL : "localhost:5559/v3-bundle-reg" ,
225+ },
226+ {
227+ name : "v2-v3 bundle oci 1.1 referrers" ,
228+ tagURL : "localhost:5558/v2-v3-bundle-zot" ,
229+ },
230+ {
231+ name : "v2-v3 bundle oci 1.0 fallback" ,
232+ tagURL : "localhost:5559/v2-v3-bundle-reg" ,
233+ },
234+ }
235+
236+ for _ , tt := range tests {
237+ t .Run (tt .name , func (t * testing.T ) {
238+ g := NewWithT (t )
239+
240+ ctx := context .Background ()
241+
242+ // tagURL := fmt.Sprintf(tag, registryAddr)
243+ ref , err := name .ParseReference (tt .tagURL )
244+ g .Expect (err ).NotTo (HaveOccurred ())
245+
246+ transport := http .DefaultTransport .(* http.Transport ).Clone ()
247+ // transport.Proxy = http.ProxyURL(tt.proxyURL)
248+
249+ var opts []Options
250+ opts = append (opts , WithRemoteOptions (remote .WithTransport (transport )))
251+ opts = append (opts , WithPublicKey (pubKey ))
252+
253+ verifier , err := NewCosignVerifier (ctx , opts ... )
254+ g .Expect (err ).NotTo (HaveOccurred ())
255+
256+ _ , err = verifier .Verify (ctx , ref )
257+ g .Expect (err ).NotTo (HaveOccurred ())
258+ })
259+ }
260+ }
0 commit comments