-
Notifications
You must be signed in to change notification settings - Fork 26
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: Andrew Gillis <[email protected]>
- Loading branch information
1 parent
4f3ea5e
commit 16c52cd
Showing
5 changed files
with
60 additions
and
53 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 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 |
---|---|---|
|
@@ -22,8 +22,7 @@ import ( | |
"fmt" | ||
"testing" | ||
|
||
"github.com/in-toto/in-toto-golang/in_toto" | ||
"github.com/in-toto/in-toto-golang/in_toto/slsa_provenance/common" | ||
in_toto "github.com/in-toto/attestation/go/v1" | ||
"github.com/sigstore/sigstore-go/pkg/testing/ca" | ||
"github.com/sigstore/sigstore-go/pkg/verify" | ||
"github.com/stretchr/testify/assert" | ||
|
@@ -34,7 +33,7 @@ var SkipArtifactAndIdentitiesPolicy = verify.NewPolicy(verify.WithoutArtifactUns | |
func TestSignatureVerifier(t *testing.T) { | ||
virtualSigstore, err := ca.NewVirtualSigstore() | ||
assert.NoError(t, err) | ||
|
||
statement := []byte(`{"_type":"https://in-toto.io/Statement/v0.1","predicateType":"customFoo","subject":[{"name":"subject","digest":{"sha256":"deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"}}],"predicate":{}}`) | ||
entity, err := virtualSigstore.Attest("[email protected]", "issuer", statement) | ||
assert.NoError(t, err) | ||
|
@@ -121,17 +120,17 @@ func TestTooManySubjects(t *testing.T) { | |
virtualSigstore, err := ca.NewVirtualSigstore() | ||
assert.NoError(t, err) | ||
|
||
tooManySubjectsStatement := in_toto.Statement{} | ||
tooManySubjectsStatement := verify.Statement{} | ||
for i := 0; i < 1025; i++ { | ||
tooManySubjectsStatement.Subject = append(tooManySubjectsStatement.Subject, in_toto.Subject{ | ||
tooManySubjectsStatement.Subject = append(tooManySubjectsStatement.Subject, &in_toto.ResourceDescriptor{ | ||
Name: fmt.Sprintf("subject-%d", i), | ||
Digest: map[string]string{ | ||
"sha256": "", // actual content of digest does not matter for this test | ||
}, | ||
}) | ||
} | ||
|
||
tooManySubjectsStatementBytes, err := json.Marshal(tooManySubjectsStatement) | ||
tooManySubjectsStatementBytes, err := json.Marshal(&tooManySubjectsStatement) | ||
assert.NoError(t, err) | ||
|
||
tooManySubjectsEntity, err := virtualSigstore.Attest("[email protected]", "issuer", tooManySubjectsStatementBytes) | ||
|
@@ -149,19 +148,18 @@ func TestTooManyDigests(t *testing.T) { | |
virtualSigstore, err := ca.NewVirtualSigstore() | ||
assert.NoError(t, err) | ||
|
||
tooManyDigestsStatement := in_toto.Statement{} | ||
tooManyDigestsStatement.Subject = []in_toto.Subject{ | ||
tooManyDigestsStatement := verify.Statement{} | ||
tooManyDigestsStatement.Subject = []*in_toto.ResourceDescriptor{ | ||
{ | ||
Name: fmt.Sprintf("subject"), | ||
Digest: make(common.DigestSet), | ||
Digest: map[string]string{"sha512": ""}, | ||
}, | ||
} | ||
tooManyDigestsStatement.Subject[0].Digest["sha512"] = "" // verifier requires that at least one known hash algorithm is present in the digest map | ||
for i := 0; i < 32; i++ { | ||
tooManyDigestsStatement.Subject[0].Digest[fmt.Sprintf("digest-%d", i)] = "" | ||
} | ||
|
||
tooManySubjectsStatementBytes, err := json.Marshal(tooManyDigestsStatement) | ||
tooManySubjectsStatementBytes, err := json.Marshal(&tooManyDigestsStatement) | ||
assert.NoError(t, err) | ||
|
||
tooManySubjectsEntity, err := virtualSigstore.Attest("[email protected]", "issuer", tooManySubjectsStatementBytes) | ||
|
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