added
This commit is contained in:
parent
dc4e9cb532
commit
c1adb1a6cf
1 changed files with 41 additions and 0 deletions
41
pkg/cmd/attestation/verification/extensions_test.go
Normal file
41
pkg/cmd/attestation/verification/extensions_test.go
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package verification
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/sigstore/sigstore-go/pkg/fulcio/certificate"
|
||||
"github.com/sigstore/sigstore-go/pkg/verify"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestVerifyCertExtensions(t *testing.T) {
|
||||
results := []*AttestationProcessingResult{
|
||||
{
|
||||
VerificationResult: &verify.VerificationResult{
|
||||
Signature: &verify.SignatureVerificationResult{
|
||||
Certificate: &certificate.Summary{
|
||||
Extensions: certificate.Extensions{
|
||||
SourceRepositoryOwnerURI: "https://github.com/owner",
|
||||
SourceRepositoryURI: "https://github.com/owner/repo",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := VerifyCertExtensions(results, "owner", "owner/repo")
|
||||
require.NoError(t, err)
|
||||
|
||||
err = VerifyCertExtensions(results, "", "owner/repo")
|
||||
require.NoError(t, err)
|
||||
|
||||
err = VerifyCertExtensions(results, "owner", "")
|
||||
require.NoError(t, err)
|
||||
|
||||
err = VerifyCertExtensions(results, "wrong", "")
|
||||
require.ErrorContains(t, err, "expected SourceRepositoryOwnerURI to be https://github.com/wrong, got https://github.com/owner")
|
||||
|
||||
err = VerifyCertExtensions(results, "", "wrong")
|
||||
require.ErrorContains(t, err, "expected SourceRepositoryURI to be https://github.com/wrong, got https://github.com/owner/repo")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue