(t *testing.T)
| 40 | } |
| 41 | |
| 42 | func TestCreateSignatures(t *testing.T) { |
| 43 | stubSigner := internalSigner.NewSigner(&stubSignerImpl{}) |
| 44 | defer stubSigner.Close() |
| 45 | |
| 46 | manifestBlob := []byte("Something") |
| 47 | // Set up dir: and docker: destinations |
| 48 | tempDir := t.TempDir() |
| 49 | dirRef, err := directory.NewReference(tempDir) |
| 50 | require.NoError(t, err) |
| 51 | dirDest, err := dirRef.NewImageDestination(context.Background(), nil) |
| 52 | require.NoError(t, err) |
| 53 | defer dirDest.Close() |
| 54 | dockerRef, err := docker.ParseReference("//busybox") |
| 55 | require.NoError(t, err) |
| 56 | dockerDest, err := dockerRef.NewImageDestination(context.Background(), |
| 57 | &types.SystemContext{RegistriesDirPath: "/this/does/not/exist", DockerPerHostCertDirPath: "/this/does/not/exist"}) |
| 58 | require.NoError(t, err) |
| 59 | defer dockerDest.Close() |
| 60 | |
| 61 | workingOptions := Options{Signers: []*signer.Signer{stubSigner}} |
| 62 | for _, cc := range []struct { |
| 63 | name string |
| 64 | dest types.ImageDestination |
| 65 | options *Options |
| 66 | identity string |
| 67 | successWithNoSigs bool |
| 68 | successfullySignedIdentity string // Set to expect a successful signing with workingOptions |
| 69 | }{ |
| 70 | { |
| 71 | name: "signing fails", |
| 72 | dest: dockerDest, |
| 73 | options: &Options{ |
| 74 | Signers: []*signer.Signer{ |
| 75 | internalSigner.NewSigner(&stubSignerImpl{signingFailure: errors.New("fails")}), |
| 76 | }, |
| 77 | }, |
| 78 | }, |
| 79 | { |
| 80 | name: "second signing fails", |
| 81 | dest: dockerDest, |
| 82 | options: &Options{ |
| 83 | Signers: []*signer.Signer{ |
| 84 | stubSigner, |
| 85 | internalSigner.NewSigner(&stubSignerImpl{signingFailure: errors.New("fails")}), |
| 86 | }, |
| 87 | }, |
| 88 | }, |
| 89 | { |
| 90 | name: "not a full reference", |
| 91 | dest: dockerDest, |
| 92 | identity: "myregistry.io/myrepo", |
| 93 | }, |
| 94 | { |
| 95 | name: "dir: with no identity specified, but no signing request", |
| 96 | dest: dirDest, |
| 97 | options: &Options{}, |
| 98 | successWithNoSigs: true, |
| 99 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…