2022-10-11 07:57:52 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
2023-08-01 10:48:13 -04:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/sigstore"
|
|
|
|
)
|
2022-10-11 07:57:52 -04:00
|
|
|
|
|
|
|
// singleUUIDVerifier constructs a RekorVerifier that returns a single UUID and no errors,
|
|
|
|
// and should work for most tests on the happy path.
|
|
|
|
func singleUUIDVerifier() *stubRekorVerifier {
|
|
|
|
return &stubRekorVerifier{
|
|
|
|
SearchByHashUUIDs: []string{"11111111111111111111111111111111111111111111111111111111111111111111111111111111"},
|
|
|
|
SearchByHashError: nil,
|
|
|
|
VerifyEntryError: nil,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SubRekorVerifier is a stub for RekorVerifier.
|
|
|
|
type stubRekorVerifier struct {
|
|
|
|
SearchByHashUUIDs []string
|
|
|
|
SearchByHashError error
|
|
|
|
VerifyEntryError error
|
|
|
|
}
|
|
|
|
|
|
|
|
// SearchByHash returns the exported fields SearchByHashUUIDs, SearchByHashError.
|
|
|
|
func (v *stubRekorVerifier) SearchByHash(context.Context, string) ([]string, error) {
|
|
|
|
return v.SearchByHashUUIDs, v.SearchByHashError
|
|
|
|
}
|
|
|
|
|
|
|
|
// VerifyEntry returns the exported field VerifyEntryError.
|
|
|
|
func (v *stubRekorVerifier) VerifyEntry(context.Context, string, string) error {
|
|
|
|
return v.VerifyEntryError
|
|
|
|
}
|
2023-05-26 11:49:46 -04:00
|
|
|
|
|
|
|
type stubCosignVerifier struct {
|
|
|
|
verifyError error
|
|
|
|
}
|
|
|
|
|
2023-08-01 10:48:13 -04:00
|
|
|
func newStubCosignVerifier(_ []byte) (sigstore.Verifier, error) {
|
|
|
|
return &stubCosignVerifier{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *stubCosignVerifier) VerifySignature(_, _ []byte) error {
|
2023-05-26 11:49:46 -04:00
|
|
|
return v.verifyError
|
|
|
|
}
|