Skip to content

Commit

Permalink
Merge pull request #243 from tri-adam/test-file-rename
Browse files Browse the repository at this point in the history
Rename PGP test files
  • Loading branch information
tri-adam authored Nov 1, 2022
2 parents 5b1317c + 1cd04cf commit 831d6b6
Show file tree
Hide file tree
Showing 22 changed files with 67 additions and 62 deletions.
48 changes: 24 additions & 24 deletions internal/app/siftool/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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",
Expand All @@ -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) {
Expand Down Expand Up @@ -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"),
Expand All @@ -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",
Expand All @@ -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) {
Expand Down Expand Up @@ -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,
},
}
Expand Down Expand Up @@ -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,
},
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/integrity/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/sif/descriptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions pkg/siftool/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/siftool/header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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",
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/siftool/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 8 additions & 8 deletions pkg/siftool/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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",
Expand All @@ -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) {
Expand Down
27 changes: 16 additions & 11 deletions test/gen_sifs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
{
Expand Down Expand Up @@ -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.
Expand All @@ -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),
},
},
}

Expand Down Expand Up @@ -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
}
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 831d6b6

Please sign in to comment.