MCPcopy Create free account
hub / github.com/containers/image / TestCreateSignatures

Function TestCreateSignatures

copy/sign_test.go:42–163  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func 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 },

Callers

nothing calls this directly

Calls 14

CloseMethod · 0.95
CloseMethod · 0.95
closeMethod · 0.95
setupSignersMethod · 0.95
createSignaturesMethod · 0.95
NewReferenceFunction · 0.92
ParseReferenceFunction · 0.92
ParseNormalizedNamedFunction · 0.92
FromPublicFunction · 0.92
UntrustedPayloadMethod · 0.80
UntrustedMIMETypeMethod · 0.80
EmptyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…