@@ -40,7 +40,16 @@ func TestContainersImagePuller_Pull(t *testing.T) {
4040 defer shutdown ()
4141
4242 myModTime := time .Date (1985 , 10 , 25 , 7 , 53 , 0 , 0 , time .FixedZone ("PDT" , - 8 * 60 * 60 ))
43- defaultContextFunc := func (context.Context ) (* types.SystemContext , error ) { return & types.SystemContext {}, nil }
43+
44+ // Create a default context with insecure policy for tests that don't use buildSourceContextFunc
45+ configDir := t .TempDir ()
46+ policyPath := filepath .Join (configDir , "policy.json" )
47+ insecurePolicy := `{"default":[{"type":"insecureAcceptAnything"}]}`
48+ require .NoError (t , os .WriteFile (policyPath , []byte (insecurePolicy ), 0644 ))
49+
50+ defaultContextFunc := func (context.Context ) (* types.SystemContext , error ) {
51+ return & types.SystemContext {SignaturePolicyPath : policyPath }, nil
52+ }
4453
4554 testCases := []struct {
4655 name string
@@ -298,8 +307,15 @@ func buildSourceContextFunc(t *testing.T, ref reference.Named) func(context.Cont
298307 require .NoError (t , enc .Encode (registriesConf ))
299308 require .NoError (t , f .Close ())
300309
310+ // Create an insecure policy for testing to override any system-level policy
311+ // that might reject unsigned images
312+ policyPath := filepath .Join (configDir , "policy.json" )
313+ insecurePolicy := `{"default":[{"type":"insecureAcceptAnything"}]}`
314+ require .NoError (t , os .WriteFile (policyPath , []byte (insecurePolicy ), 0644 ))
315+
301316 return & types.SystemContext {
302317 SystemRegistriesConfPath : registriesConfPath ,
318+ SignaturePolicyPath : policyPath ,
303319 }, nil
304320 }
305321}
0 commit comments