policy: add mock signature unit test

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2026-02-09 18:27:29 -08:00
parent 22b3d36de3
commit 6d2e4952b5
3 changed files with 176 additions and 5 deletions
+8 -3
View File
@@ -14,12 +14,17 @@ import (
gwpb "github.com/moby/buildkit/frontend/gateway/pb"
policyverifier "github.com/moby/policy-helpers"
policyimage "github.com/moby/policy-helpers/image"
policytypes "github.com/moby/policy-helpers/types"
"github.com/opencontainers/go-digest"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)
type PolicyVerifierProvider func() (*policyverifier.Verifier, error)
type PolicyVerifier interface {
VerifyImage(context.Context, policyimage.ReferrersProvider, ocispecs.Descriptor, *ocispecs.Platform) (*policytypes.SignatureInfo, error)
}
type PolicyVerifierProvider func() (PolicyVerifier, error)
func SignatureVerifier(cfg *confutil.Config) PolicyVerifierProvider {
if cfg == nil {
@@ -27,9 +32,9 @@ func SignatureVerifier(cfg *confutil.Config) PolicyVerifierProvider {
}
var (
mu sync.Mutex
v *policyverifier.Verifier
v PolicyVerifier
)
return func() (*policyverifier.Verifier, error) {
return func() (PolicyVerifier, error) {
mu.Lock()
defer mu.Unlock()