@@ -20,6 +20,7 @@ import (
20
20
"testing"
21
21
22
22
v1 "github.com/google/go-containerregistry/pkg/v1"
23
+ "github.com/google/go-containerregistry/pkg/v1/types"
23
24
"github.com/sigstore/cosign/v2/pkg/oci"
24
25
"github.com/sigstore/cosign/v2/pkg/oci/empty"
25
26
"github.com/sigstore/cosign/v2/pkg/oci/static"
@@ -87,6 +88,34 @@ func TestAppendSignatures(t *testing.T) {
87
88
}
88
89
}
89
90
91
+ func TestReplaceSignatures (t * testing.T ) {
92
+ base := empty .Signatures ()
93
+
94
+ s1 , err := static .NewSignature ([]byte {}, "s1" )
95
+ if err != nil {
96
+ t .Fatalf ("NewSignature() = %v" , err )
97
+ }
98
+
99
+ oneSig , err := AppendSignatures (base , false , s1 )
100
+ if err != nil {
101
+ t .Fatalf ("AppendSignatures() = %v" , err )
102
+ }
103
+ replaceSig , err := ReplaceSignatures (oneSig )
104
+ if err != nil {
105
+ t .Fatalf ("ReplaceSignatures() = %v" , err )
106
+ }
107
+ if sl , err := replaceSig .Get (); err != nil {
108
+ t .Fatalf ("Get() = %v" , err )
109
+ } else if got , want := len (sl ), 1 ; got != want {
110
+ t .Errorf ("len(Get()) = %d, wanted %d" , got , want )
111
+ }
112
+ if mt , err := replaceSig .MediaType (); err != nil {
113
+ t .Fatalf ("MediaType() = %v" , err )
114
+ } else if got , want := mt , types .OCIManifestSchema1 ; got != want {
115
+ t .Errorf ("MediaType() = %v, wanted %v" , got , want )
116
+ }
117
+ }
118
+
90
119
func TestGet (t * testing.T ) {
91
120
tests := []struct {
92
121
name string
0 commit comments