From ad3957cb2e07e315081bc9e48c94438e28dcf359 Mon Sep 17 00:00:00 2001 From: Juncheng Zhu Date: Mon, 13 Jan 2025 16:14:42 +0000 Subject: [PATCH] chore: upgrade interface Signed-off-by: Juncheng Zhu --- .../refresh/kubeRefresh_test.go | 5 ----- pkg/verifier/notation/notation.go | 4 ++-- pkg/verifier/notation/notation_test.go | 12 ------------ pkg/verifier/notation/notationrevocationfactory.go | 6 ------ .../notation/notationrevocationfactory_test.go | 9 --------- pkg/verifier/notation/revocationfactory.go | 4 ---- 6 files changed, 2 insertions(+), 38 deletions(-) diff --git a/pkg/keymanagementprovider/refresh/kubeRefresh_test.go b/pkg/keymanagementprovider/refresh/kubeRefresh_test.go index 859180ed9..3c1bda1f4 100644 --- a/pkg/keymanagementprovider/refresh/kubeRefresh_test.go +++ b/pkg/keymanagementprovider/refresh/kubeRefresh_test.go @@ -26,7 +26,6 @@ import ( "testing" "time" - "github.com/notaryproject/notation-core-go/revocation" corecrl "github.com/notaryproject/notation-core-go/revocation/crl" re "github.com/ratify-project/ratify/errors" "github.com/ratify-project/ratify/pkg/keymanagementprovider" @@ -180,10 +179,6 @@ func (h *MockCRLHandler) NewFetcher() (corecrl.Fetcher, error) { return nil, re.ErrorCodeConfigInvalid.WithDetail("failed to create CRL fetcher") } -func (h *MockCRLHandler) NewValidator(_ revocation.Options) (revocation.Validator, error) { - return nil, nil -} - func TestKubeRefresher_GetResult(t *testing.T) { kr := &KubeRefresher{ Result: ctrl.Result{RequeueAfter: time.Minute}, diff --git a/pkg/verifier/notation/notation.go b/pkg/verifier/notation/notation.go index 24537190a..625a539bb 100644 --- a/pkg/verifier/notation/notation.go +++ b/pkg/verifier/notation/notation.go @@ -193,14 +193,14 @@ func getVerifierService(ctx context.Context, conf *NotationPluginVerifierConfig, if err != nil { logger.GetLogger(ctx, logOpt).Warnf("Unable to create CRL fetcher for notation verifier %s with error: %s", conf.Name, err) } - revocationCodeSigningValidator, err := revocationFactory.NewValidator(revocation.Options{ + revocationCodeSigningValidator, err := revocation.NewWithOptions(revocation.Options{ CRLFetcher: crlFetcher, CertChainPurpose: purpose.CodeSigning, }) if err != nil { return nil, err } - revocationTimestampingValidator, err := revocationFactory.NewValidator(revocation.Options{ + revocationTimestampingValidator, err := revocation.NewWithOptions(revocation.Options{ CRLFetcher: crlFetcher, CertChainPurpose: purpose.Timestamping, }) diff --git a/pkg/verifier/notation/notation_test.go b/pkg/verifier/notation/notation_test.go index c0ae0d226..90456bafe 100644 --- a/pkg/verifier/notation/notation_test.go +++ b/pkg/verifier/notation/notation_test.go @@ -23,9 +23,7 @@ import ( "reflect" "testing" - "github.com/notaryproject/notation-core-go/revocation" corecrl "github.com/notaryproject/notation-core-go/revocation/crl" - "github.com/notaryproject/notation-core-go/revocation/purpose" sig "github.com/notaryproject/notation-core-go/signature" "github.com/notaryproject/notation-go" "github.com/opencontainers/go-digest" @@ -651,13 +649,3 @@ func (m mockRevocationFactory) NewFetcher() (corecrl.Fetcher, error) { } return corecrl.NewHTTPFetcher(m.httpClient) } - -func (m mockRevocationFactory) NewValidator(opts revocation.Options) (revocation.Validator, error) { - if m.failCodeSigningValidator && opts.CertChainPurpose == purpose.CodeSigning { - return nil, fmt.Errorf("failed to create code signing validator") - } - if m.failTimestampingValidator && opts.CertChainPurpose == purpose.Timestamping { - return nil, fmt.Errorf("failed to create timestamping validator") - } - return revocation.NewWithOptions(opts) -} diff --git a/pkg/verifier/notation/notationrevocationfactory.go b/pkg/verifier/notation/notationrevocationfactory.go index 1a9683a32..b1a08982e 100644 --- a/pkg/verifier/notation/notationrevocationfactory.go +++ b/pkg/verifier/notation/notationrevocationfactory.go @@ -17,7 +17,6 @@ import ( "net/http" "sync" - "github.com/notaryproject/notation-core-go/revocation" corecrl "github.com/notaryproject/notation-core-go/revocation/crl" "github.com/notaryproject/notation-go/dir" "github.com/ratify-project/ratify/config" @@ -62,8 +61,3 @@ func (h *CRLHandler) NewFetcher() (corecrl.Fetcher, error) { } return globalFetcher, nil } - -// NewValidator returns a new validator instance -func (h *CRLHandler) NewValidator(opts revocation.Options) (revocation.Validator, error) { - return revocation.NewWithOptions(opts) -} diff --git a/pkg/verifier/notation/notationrevocationfactory_test.go b/pkg/verifier/notation/notationrevocationfactory_test.go index 1cbd43e52..40213131a 100644 --- a/pkg/verifier/notation/notationrevocationfactory_test.go +++ b/pkg/verifier/notation/notationrevocationfactory_test.go @@ -18,7 +18,6 @@ import ( "runtime" "testing" - "github.com/notaryproject/notation-core-go/revocation" "github.com/notaryproject/notation-go/dir" re "github.com/ratify-project/ratify/errors" "github.com/stretchr/testify/assert" @@ -72,14 +71,6 @@ func TestNewFetcher(t *testing.T) { globalFetcher, _ = CreateCRLFetcher(&http.Client{}, dir.PathCRLCache) } -func TestNewValidator(t *testing.T) { - factory := CreateCRLHandlerFromConfig() - opts := revocation.Options{} - - validator, err := factory.NewValidator(opts) - assert.NoError(t, err) - assert.NotNil(t, validator) -} func TestNewFileCache(t *testing.T) { tests := []struct { name string diff --git a/pkg/verifier/notation/revocationfactory.go b/pkg/verifier/notation/revocationfactory.go index 73486bb1b..01559855e 100644 --- a/pkg/verifier/notation/revocationfactory.go +++ b/pkg/verifier/notation/revocationfactory.go @@ -19,7 +19,6 @@ import ( "net/http" "sync" - "github.com/notaryproject/notation-core-go/revocation" corecrl "github.com/notaryproject/notation-core-go/revocation/crl" "github.com/notaryproject/notation-go/dir" "github.com/notaryproject/notation-go/verifier/crl" @@ -33,9 +32,6 @@ import ( type RevocationFactory interface { // NewFetcher returns a new fetcher instance NewFetcher() (corecrl.Fetcher, error) - - // NewValidator returns a new validator instance - NewValidator(revocation.Options) (revocation.Validator, error) } // CreateCRLFetcher returns a new fetcher instance