diff --git a/internal/app/siftool/info_test.go b/internal/app/siftool/info_test.go index d6deab38..456fc279 100644 --- a/internal/app/siftool/info_test.go +++ b/internal/app/siftool/info_test.go @@ -120,10 +120,6 @@ func TestApp_Header(t *testing.T) { name: "OneGroup", path: filepath.Join(corpus, "one-group.sif"), }, - { - name: "OneGroupSigned", - path: filepath.Join(corpus, "one-group-signed.sif"), - }, { name: "OneGroupSignedLegacy", path: filepath.Join(corpus, "one-group-signed-legacy.sif"), @@ -137,12 +133,12 @@ func TestApp_Header(t *testing.T) { path: filepath.Join(corpus, "one-group-signed-legacy-group.sif"), }, { - name: "TwoGroups", - path: filepath.Join(corpus, "two-groups.sif"), + name: "OneGroupSignedPGP", + path: filepath.Join(corpus, "one-group-signed-pgp.sif"), }, { - name: "TwoGroupsSigned", - path: filepath.Join(corpus, "two-groups-signed.sif"), + name: "TwoGroups", + path: filepath.Join(corpus, "two-groups.sif"), }, { name: "TwoGroupsSignedLegacy", @@ -156,6 +152,10 @@ func TestApp_Header(t *testing.T) { name: "TwoGroupsSignedLegacyGroup", path: filepath.Join(corpus, "two-groups-signed-legacy-group.sif"), }, + { + name: "TwoGroupsSignedPGP", + path: filepath.Join(corpus, "two-groups-signed-pgp.sif"), + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -222,10 +222,6 @@ func TestApp_List(t *testing.T) { name: "OneGroup", path: filepath.Join(corpus, "one-group.sif"), }, - { - name: "OneGroupSigned", - path: filepath.Join(corpus, "one-group-signed.sif"), - }, { name: "OneGroupSignedLegacy", path: filepath.Join(corpus, "one-group-signed-legacy.sif"), @@ -239,12 +235,12 @@ func TestApp_List(t *testing.T) { path: filepath.Join(corpus, "one-group-signed-legacy-group.sif"), }, { - name: "TwoGroups", - path: filepath.Join(corpus, "two-groups.sif"), + name: "OneGroupSignedPGP", + path: filepath.Join(corpus, "one-group-signed-pgp.sif"), }, { - name: "TwoGroupsSigned", - path: filepath.Join(corpus, "two-groups-signed.sif"), + name: "TwoGroups", + path: filepath.Join(corpus, "two-groups.sif"), }, { name: "TwoGroupsSignedLegacy", @@ -258,6 +254,10 @@ func TestApp_List(t *testing.T) { name: "TwoGroupsSignedLegacyGroup", path: filepath.Join(corpus, "two-groups-signed-legacy-group.sif"), }, + { + name: "TwoGroupsSignedPGP", + path: filepath.Join(corpus, "two-groups-signed-pgp.sif"), + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -314,22 +314,22 @@ func TestApp_Info(t *testing.T) { }, { name: "DataPartitionRaw", - path: filepath.Join(corpus, "two-groups-signed.sif"), + path: filepath.Join(corpus, "two-groups-signed-pgp.sif"), id: 1, }, { name: "DataPartitionSquashFS", - path: filepath.Join(corpus, "two-groups-signed.sif"), + path: filepath.Join(corpus, "two-groups-signed-pgp.sif"), id: 2, }, { name: "DataPartitionEXT3", - path: filepath.Join(corpus, "two-groups-signed.sif"), + path: filepath.Join(corpus, "two-groups-signed-pgp.sif"), id: 3, }, { name: "DataSignature", - path: filepath.Join(corpus, "two-groups-signed.sif"), + path: filepath.Join(corpus, "two-groups-signed-pgp.sif"), id: 4, }, } @@ -368,23 +368,23 @@ func TestApp_Dump(t *testing.T) { }, { name: "InvalidObjectID", - path: filepath.Join(corpus, "one-group-signed.sif"), + path: filepath.Join(corpus, "one-group-signed-pgp.sif"), id: 0, wantErr: sif.ErrInvalidObjectID, }, { name: "One", - path: filepath.Join(corpus, "one-group-signed.sif"), + path: filepath.Join(corpus, "one-group-signed-pgp.sif"), id: 1, }, { name: "Two", - path: filepath.Join(corpus, "one-group-signed.sif"), + path: filepath.Join(corpus, "one-group-signed-pgp.sif"), id: 2, }, { name: "Three", - path: filepath.Join(corpus, "one-group-signed.sif"), + path: filepath.Join(corpus, "one-group-signed-pgp.sif"), id: 3, }, } diff --git a/internal/app/siftool/testdata/TestApp_Header/OneGroupSigned.golden b/internal/app/siftool/testdata/TestApp_Header/OneGroupSignedPGP.golden similarity index 100% rename from internal/app/siftool/testdata/TestApp_Header/OneGroupSigned.golden rename to internal/app/siftool/testdata/TestApp_Header/OneGroupSignedPGP.golden diff --git a/internal/app/siftool/testdata/TestApp_Header/TwoGroupsSigned.golden b/internal/app/siftool/testdata/TestApp_Header/TwoGroupsSignedPGP.golden similarity index 100% rename from internal/app/siftool/testdata/TestApp_Header/TwoGroupsSigned.golden rename to internal/app/siftool/testdata/TestApp_Header/TwoGroupsSignedPGP.golden diff --git a/internal/app/siftool/testdata/TestApp_List/OneGroupSigned.golden b/internal/app/siftool/testdata/TestApp_List/OneGroupSignedPGP.golden similarity index 100% rename from internal/app/siftool/testdata/TestApp_List/OneGroupSigned.golden rename to internal/app/siftool/testdata/TestApp_List/OneGroupSignedPGP.golden diff --git a/internal/app/siftool/testdata/TestApp_List/TwoGroupsSigned.golden b/internal/app/siftool/testdata/TestApp_List/TwoGroupsSignedPGP.golden similarity index 100% rename from internal/app/siftool/testdata/TestApp_List/TwoGroupsSigned.golden rename to internal/app/siftool/testdata/TestApp_List/TwoGroupsSignedPGP.golden diff --git a/pkg/integrity/verify_test.go b/pkg/integrity/verify_test.go index 8c297823..66b17d95 100644 --- a/pkg/integrity/verify_test.go +++ b/pkg/integrity/verify_test.go @@ -21,7 +21,7 @@ import ( func TestGroupVerifier_signatures(t *testing.T) { oneGroupImage := loadContainer(t, filepath.Join(corpus, "one-group.sif")) - oneGroupSignedImage := loadContainer(t, filepath.Join(corpus, "one-group-signed.sif")) + oneGroupSignedImage := loadContainer(t, filepath.Join(corpus, "one-group-signed-pgp.sif")) sigs, err := oneGroupSignedImage.GetDescriptors(sif.WithDataType(sif.DataSignature)) if err != nil { @@ -71,7 +71,7 @@ func TestGroupVerifier_signatures(t *testing.T) { } func TestGroupVerifier_verify(t *testing.T) { - oneGroupSignedImage := loadContainer(t, filepath.Join(corpus, "one-group-signed.sif")) + oneGroupSignedImage := loadContainer(t, filepath.Join(corpus, "one-group-signed-pgp.sif")) sig, err := oneGroupSignedImage.GetDescriptor(sif.WithDataType(sif.DataSignature)) if err != nil { @@ -932,7 +932,7 @@ func TestVerifier_AllSignedBy(t *testing.T) { func TestVerifier_Verify(t *testing.T) { oneGroupImage := loadContainer(t, filepath.Join(corpus, "one-group.sif")) - oneGroupSignedImage := loadContainer(t, filepath.Join(corpus, "one-group-signed.sif")) + oneGroupSignedImage := loadContainer(t, filepath.Join(corpus, "one-group-signed-pgp.sif")) verified, err := oneGroupSignedImage.GetDescriptors(sif.WithGroupID(1)) if err != nil { diff --git a/pkg/sif/descriptor_test.go b/pkg/sif/descriptor_test.go index 21280d97..c6c305cd 100644 --- a/pkg/sif/descriptor_test.go +++ b/pkg/sif/descriptor_test.go @@ -19,7 +19,7 @@ import ( func TestDescriptor_GetData(t *testing.T) { f, err := LoadContainerFromPath( - filepath.Join(corpus, "one-group-signed.sif"), + filepath.Join(corpus, "one-group-signed-pgp.sif"), OptLoadWithFlag(os.O_RDONLY), ) if err != nil { @@ -49,7 +49,7 @@ func TestDescriptor_GetData(t *testing.T) { func TestDescriptor_GetReader(t *testing.T) { f, err := LoadContainerFromPath( - filepath.Join(corpus, "one-group-signed.sif"), + filepath.Join(corpus, "one-group-signed-pgp.sif"), OptLoadWithFlag(os.O_RDONLY), ) if err != nil { diff --git a/pkg/siftool/dump_test.go b/pkg/siftool/dump_test.go index fb13eb46..15529545 100644 --- a/pkg/siftool/dump_test.go +++ b/pkg/siftool/dump_test.go @@ -20,16 +20,16 @@ func Test_command_getDump(t *testing.T) { { name: "One", id: "1", - path: filepath.Join(corpus, "one-group-signed.sif"), + path: filepath.Join(corpus, "one-group-signed-pgp.sif"), }, { name: "Two", - path: filepath.Join(corpus, "one-group-signed.sif"), + path: filepath.Join(corpus, "one-group-signed-pgp.sif"), id: "2", }, { name: "Three", - path: filepath.Join(corpus, "one-group-signed.sif"), + path: filepath.Join(corpus, "one-group-signed-pgp.sif"), id: "3", }, } diff --git a/pkg/siftool/header_test.go b/pkg/siftool/header_test.go index 7aeb615d..d6209bbe 100644 --- a/pkg/siftool/header_test.go +++ b/pkg/siftool/header_test.go @@ -25,10 +25,6 @@ func Test_command_getHeader(t *testing.T) { name: "OneGroup", path: filepath.Join(corpus, "one-group.sif"), }, - { - name: "OneGroupSigned", - path: filepath.Join(corpus, "one-group-signed.sif"), - }, { name: "OneGroupSignedLegacy", path: filepath.Join(corpus, "one-group-signed-legacy.sif"), @@ -42,12 +38,12 @@ func Test_command_getHeader(t *testing.T) { path: filepath.Join(corpus, "one-group-signed-legacy-group.sif"), }, { - name: "TwoGroups", - path: filepath.Join(corpus, "two-groups.sif"), + name: "OneGroupSignedPGP", + path: filepath.Join(corpus, "one-group-signed-pgp.sif"), }, { - name: "TwoGroupsSigned", - path: filepath.Join(corpus, "two-groups-signed.sif"), + name: "TwoGroups", + path: filepath.Join(corpus, "two-groups.sif"), }, { name: "TwoGroupsSignedLegacy", @@ -61,6 +57,10 @@ func Test_command_getHeader(t *testing.T) { name: "TwoGroupsSignedLegacyGroup", path: filepath.Join(corpus, "two-groups-signed-legacy-group.sif"), }, + { + name: "TwoGroupsSignedPGP", + path: filepath.Join(corpus, "two-groups-signed-pgp.sif"), + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/siftool/info_test.go b/pkg/siftool/info_test.go index 963b00a0..9c0968da 100644 --- a/pkg/siftool/info_test.go +++ b/pkg/siftool/info_test.go @@ -20,17 +20,17 @@ func Test_command_getInfo(t *testing.T) { { name: "One", id: "1", - path: filepath.Join(corpus, "one-group-signed.sif"), + path: filepath.Join(corpus, "one-group-signed-pgp.sif"), }, { name: "Two", id: "2", - path: filepath.Join(corpus, "one-group-signed.sif"), + path: filepath.Join(corpus, "one-group-signed-pgp.sif"), }, { name: "Three", id: "3", - path: filepath.Join(corpus, "one-group-signed.sif"), + path: filepath.Join(corpus, "one-group-signed-pgp.sif"), }, } for _, tt := range tests { diff --git a/pkg/siftool/list_test.go b/pkg/siftool/list_test.go index 5a4a47b0..04ac82db 100644 --- a/pkg/siftool/list_test.go +++ b/pkg/siftool/list_test.go @@ -25,10 +25,6 @@ func Test_command_getList(t *testing.T) { name: "OneGroup", path: filepath.Join(corpus, "one-group.sif"), }, - { - name: "OneGroupSigned", - path: filepath.Join(corpus, "one-group-signed.sif"), - }, { name: "OneGroupSignedLegacy", path: filepath.Join(corpus, "one-group-signed-legacy.sif"), @@ -42,12 +38,12 @@ func Test_command_getList(t *testing.T) { path: filepath.Join(corpus, "one-group-signed-legacy-group.sif"), }, { - name: "TwoGroups", - path: filepath.Join(corpus, "two-groups.sif"), + name: "OneGroupSignedPGP", + path: filepath.Join(corpus, "one-group-signed-pgp.sif"), }, { - name: "TwoGroupsSigned", - path: filepath.Join(corpus, "two-groups-signed.sif"), + name: "TwoGroups", + path: filepath.Join(corpus, "two-groups.sif"), }, { name: "TwoGroupsSignedLegacy", @@ -61,6 +57,10 @@ func Test_command_getList(t *testing.T) { name: "TwoGroupsSignedLegacyGroup", path: filepath.Join(corpus, "two-groups-signed-legacy-group.sif"), }, + { + name: "TwoGroupsSignedPGP", + path: filepath.Join(corpus, "two-groups-signed-pgp.sif"), + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/siftool/testdata/Test_command_getHeader/OneGroupSigned/err.golden b/pkg/siftool/testdata/Test_command_getHeader/OneGroupSignedPGP/err.golden similarity index 100% rename from pkg/siftool/testdata/Test_command_getHeader/OneGroupSigned/err.golden rename to pkg/siftool/testdata/Test_command_getHeader/OneGroupSignedPGP/err.golden diff --git a/pkg/siftool/testdata/Test_command_getHeader/OneGroupSigned/out.golden b/pkg/siftool/testdata/Test_command_getHeader/OneGroupSignedPGP/out.golden similarity index 100% rename from pkg/siftool/testdata/Test_command_getHeader/OneGroupSigned/out.golden rename to pkg/siftool/testdata/Test_command_getHeader/OneGroupSignedPGP/out.golden diff --git a/pkg/siftool/testdata/Test_command_getHeader/TwoGroupsSigned/err.golden b/pkg/siftool/testdata/Test_command_getHeader/TwoGroupsSignedPGP/err.golden similarity index 100% rename from pkg/siftool/testdata/Test_command_getHeader/TwoGroupsSigned/err.golden rename to pkg/siftool/testdata/Test_command_getHeader/TwoGroupsSignedPGP/err.golden diff --git a/pkg/siftool/testdata/Test_command_getHeader/TwoGroupsSigned/out.golden b/pkg/siftool/testdata/Test_command_getHeader/TwoGroupsSignedPGP/out.golden similarity index 100% rename from pkg/siftool/testdata/Test_command_getHeader/TwoGroupsSigned/out.golden rename to pkg/siftool/testdata/Test_command_getHeader/TwoGroupsSignedPGP/out.golden diff --git a/pkg/siftool/testdata/Test_command_getList/OneGroupSigned/err.golden b/pkg/siftool/testdata/Test_command_getList/OneGroupSignedPGP/err.golden similarity index 100% rename from pkg/siftool/testdata/Test_command_getList/OneGroupSigned/err.golden rename to pkg/siftool/testdata/Test_command_getList/OneGroupSignedPGP/err.golden diff --git a/pkg/siftool/testdata/Test_command_getList/OneGroupSigned/out.golden b/pkg/siftool/testdata/Test_command_getList/OneGroupSignedPGP/out.golden similarity index 100% rename from pkg/siftool/testdata/Test_command_getList/OneGroupSigned/out.golden rename to pkg/siftool/testdata/Test_command_getList/OneGroupSignedPGP/out.golden diff --git a/pkg/siftool/testdata/Test_command_getList/TwoGroupsSigned/err.golden b/pkg/siftool/testdata/Test_command_getList/TwoGroupsSignedPGP/err.golden similarity index 100% rename from pkg/siftool/testdata/Test_command_getList/TwoGroupsSigned/err.golden rename to pkg/siftool/testdata/Test_command_getList/TwoGroupsSignedPGP/err.golden diff --git a/pkg/siftool/testdata/Test_command_getList/TwoGroupsSigned/out.golden b/pkg/siftool/testdata/Test_command_getList/TwoGroupsSignedPGP/out.golden similarity index 100% rename from pkg/siftool/testdata/Test_command_getList/TwoGroupsSigned/out.golden rename to pkg/siftool/testdata/Test_command_getList/TwoGroupsSignedPGP/out.golden diff --git a/test/gen_sifs.go b/test/gen_sifs.go index 73959518..19510c7e 100755 --- a/test/gen_sifs.go +++ b/test/gen_sifs.go @@ -100,10 +100,10 @@ func generateImages() error { } images := []struct { - path string - diFns []func() (sif.DescriptorInput, error) - opts []sif.CreateOpt - sign bool + path string + diFns []func() (sif.DescriptorInput, error) + opts []sif.CreateOpt + signOpts []integrity.SignerOpt }{ // Images with no objects. { @@ -160,12 +160,14 @@ func generateImages() error { }, }, { - path: "one-group-signed.sif", + path: "one-group-signed-pgp.sif", diFns: []func() (sif.DescriptorInput, error){ partSystem, partPrimSys, }, - sign: true, + signOpts: []integrity.SignerOpt{ + integrity.OptSignWithEntity(e), + }, }, // Images with three partitions in two groups. @@ -178,13 +180,15 @@ func generateImages() error { }, }, { - path: "two-groups-signed.sif", + path: "two-groups-signed-pgp.sif", diFns: []func() (sif.DescriptorInput, error){ partSystem, partPrimSys, partSystemGroup2, }, - sign: true, + signOpts: []integrity.SignerOpt{ + integrity.OptSignWithEntity(e), + }, }, } @@ -214,12 +218,13 @@ func generateImages() error { } }() - if image.sign { - s, err := integrity.NewSigner(f, - integrity.OptSignWithEntity(e), + if opts := image.signOpts; opts != nil { + opts = append(opts, integrity.OptSignWithTime(func() time.Time { return time.Date(2020, 6, 30, 0, 1, 56, 0, time.UTC) }), integrity.OptSignDeterministic(), ) + + s, err := integrity.NewSigner(f, opts...) if err != nil { return err } diff --git a/test/images/one-group-signed.sif b/test/images/one-group-signed-pgp.sif similarity index 100% rename from test/images/one-group-signed.sif rename to test/images/one-group-signed-pgp.sif diff --git a/test/images/two-groups-signed.sif b/test/images/two-groups-signed-pgp.sif similarity index 100% rename from test/images/two-groups-signed.sif rename to test/images/two-groups-signed-pgp.sif