Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade CRL revocation factory interface #2028

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions pkg/keymanagementprovider/refresh/kubeRefresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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},
Expand Down
4 changes: 2 additions & 2 deletions pkg/verifier/notation/notation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down
12 changes: 0 additions & 12 deletions pkg/verifier/notation/notation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
6 changes: 0 additions & 6 deletions pkg/verifier/notation/notationrevocationfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
9 changes: 0 additions & 9 deletions pkg/verifier/notation/notationrevocationfactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions pkg/verifier/notation/revocationfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
Loading