diff --git a/test/acme/dns/fixture.go b/test/acme/dns/fixture.go index 43bd998ae..8e2a7b30c 100644 --- a/test/acme/dns/fixture.go +++ b/test/acme/dns/fixture.go @@ -24,12 +24,10 @@ import ( "time" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes" "sigs.k8s.io/controller-runtime/pkg/envtest" "github.com/cert-manager/cert-manager/pkg/acme/webhook" - "github.com/cert-manager/cert-manager/pkg/issuer/acme/dns/rfc2136" "github.com/cert-manager/cert-manager/test/internal/apiserver" ) @@ -44,9 +42,7 @@ func init() { type fixture struct { // testSolver is the actual DNS solver that is under test. // It is set when calling the NewFixture function. - testSolver webhook.Solver - testSolverType string - + testSolver webhook.Solver resolvedFQDN string resolvedZone string allowAmbientCredentials bool @@ -126,27 +122,7 @@ func (f *fixture) setup(t *testing.T) func() { stopCh := make(chan struct{}) - var testSolver webhook.Solver - switch f.testSolverType { - case rfc2136.SolverName: - cl, err := kubernetes.NewForConfig(env.Config) - if err != nil { - t.Errorf("error initializing solver: %#+v", err) - } - - // obtain a secret lister and start the informer factory to populate the - // secret cache - factory := informers.NewSharedInformerFactoryWithOptions(cl, time.Minute*5) - secretLister := factory.Core().V1().Secrets().Lister() - factory.Start(stopCh) - factory.WaitForCacheSync(stopCh) - testSolver = rfc2136.New(rfc2136.WithSecretsLister(secretLister)) - f.testSolver = testSolver - default: - t.Errorf("unknown solver type: %s", f.testSolverType) - } - - testSolver.Initialize(env.Config, stopCh) + f.testSolver.Initialize(env.Config, stopCh) return func() { close(stopCh) diff --git a/test/acme/dns/options.go b/test/acme/dns/options.go index 053eb358e..d5c36bffc 100644 --- a/test/acme/dns/options.go +++ b/test/acme/dns/options.go @@ -23,6 +23,7 @@ import ( "strings" "time" + "github.com/cert-manager/cert-manager/pkg/acme/webhook" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" ) @@ -30,10 +31,13 @@ import ( type Option func(*fixture) // NewFixture constructs a new *fixture, applying the given Options before -// returning. -func NewFixture(solverType string, opts ...Option) *fixture { +// returning. Solver is an implementation of +// https://github.com/cert-manager/cert-manager/blob/v1.11.0/pkg/acme/webhook/webhook.go#L27-L45 +// and could be RFC2136 solver or any of external solvers that run these +// conformance tests. +func NewFixture(solver webhook.Solver, opts ...Option) *fixture { f := &fixture{ - testSolverType: solverType, + testSolver: solver, } for _, o := range opts { o(f) diff --git a/test/integration/rfc2136_dns01/provider_test.go b/test/integration/rfc2136_dns01/provider_test.go index e22128b68..b950657b1 100644 --- a/test/integration/rfc2136_dns01/provider_test.go +++ b/test/integration/rfc2136_dns01/provider_test.go @@ -59,7 +59,7 @@ func TestRunSuiteWithTSIG(t *testing.T) { TSIGKeyName: rfc2136TestTsigKeyName, } - fixture := dns.NewFixture(rfc2136.SolverName, + fixture := dns.NewFixture(rfc2136.New(rfc2136.InitializeResetLister()), dns.SetResolvedZone(rfc2136TestZone), dns.SetResolvedFQDN(rfc2136TestFqdn), dns.SetAllowAmbientCredentials(false), @@ -91,7 +91,7 @@ func TestRunSuiteNoTSIG(t *testing.T) { Nameserver: server.ListenAddr(), } - fixture := dns.NewFixture(rfc2136.SolverName, + fixture := dns.NewFixture(rfc2136.New(rfc2136.InitializeResetLister()), dns.SetResolvedZone(rfc2136TestZone), dns.SetResolvedFQDN(rfc2136TestFqdn), dns.SetAllowAmbientCredentials(false),