-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: laurentsimon <[email protected]>
- Loading branch information
1 parent
297cc11
commit c872a88
Showing
12 changed files
with
88 additions
and
511 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
verifiers/internal/gcb/slsaprovenance/v0.1/provenance_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package v01 | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
"github.com/google/go-cmp/cmp/cmpopts" | ||
|
||
serrors "github.com/slsa-framework/slsa-verifier/v2/errors" | ||
) | ||
|
||
func Test_New(t *testing.T) { | ||
t.Parallel() | ||
tests := []struct { | ||
name string | ||
path string | ||
expected error | ||
}{ | ||
{ | ||
name: "valid gcb provenance", | ||
path: "./testdata/gcloud-container-github.json", | ||
}, | ||
{ | ||
name: "valid gcb provenance gcs", | ||
path: "./testdata/gcloud-container-gcs.json", | ||
}, | ||
{ | ||
name: "invalid intoto header", | ||
path: "./testdata/gcloud-container-invalid-intotoheader.json", | ||
expected: serrors.ErrorInvalidDssePayload, | ||
}, | ||
{ | ||
name: "invalid provenance header", | ||
path: "./testdata/gcloud-container-invalid-slsaheader.json", | ||
expected: serrors.ErrorInvalidDssePayload, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
tt := tt // Re-initializing variable so it is not changed while executing the closure below | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
content, err := os.ReadFile(tt.path) | ||
if err != nil { | ||
panic(fmt.Errorf("os.ReadFile: %w", err)) | ||
} | ||
fmt.Println(string(content)) | ||
_, err = New(content) | ||
if !cmp.Equal(err, tt.expected, cmpopts.EquateErrors()) { | ||
t.Errorf(cmp.Diff(err, tt.expected, cmpopts.EquateErrors())) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.