From 466ffe336d39fd34d8012191879ab86bc804734b Mon Sep 17 00:00:00 2001 From: Jonathan Prates Date: Mon, 15 Mar 2021 11:09:30 +0000 Subject: [PATCH] tests: allow setting dnsname and acme challenge key for webhook integration tests Signed-off-by: Jonathan Simon Prates --- test/acme/dns/fixture.go | 10 ++++++++++ test/acme/dns/options.go | 21 +++++++++++++++++++++ test/acme/dns/util.go | 5 ++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/test/acme/dns/fixture.go b/test/acme/dns/fixture.go index 7fd25f365..51f99df59 100644 --- a/test/acme/dns/fixture.go +++ b/test/acme/dns/fixture.go @@ -62,6 +62,16 @@ type fixture struct { // Default: 8.8.8.8:53 testDNSServer string + // dnsName is the domain name used in the request in tests. + // This field can be set using the SetDNSName Option. + // Default: "example.com" + dnsName string + + // dnsChallengeKey is the value of TXT record in tests. + // This field can be set using the SetDNSChallengeKey Option. + // Default: "123d==" + dnsChallengeKey string + // controlPlane is a reference to the control plane that is used to run the // test suite. // It is constructed when a Run* method is called. diff --git a/test/acme/dns/options.go b/test/acme/dns/options.go index b5e99ee7c..d699e02d8 100644 --- a/test/acme/dns/options.go +++ b/test/acme/dns/options.go @@ -52,6 +52,12 @@ func applyDefaults(f *fixture) { if f.resolvedFQDN == "" { f.resolvedFQDN = "cert-manager-dns01-tests." + f.resolvedZone } + if f.dnsName == "" { + f.dnsName = "example.com" + } + if f.dnsChallengeKey == "" { + f.dnsChallengeKey = "123d==" + } runfiles := os.Getenv("TEST_SRCDIR") if f.binariesPath == "" { if runfiles != "" { @@ -170,3 +176,18 @@ func SetPropagationLimit(d time.Duration) Option { f.propagationLimit = d } } + +// SetDNSChallengeKey defines the value of the acme challenge string. +func SetDNSChallengeKey(s string) Option { + return func(f *fixture) { + f.dnsChallengeKey = s + } +} + +// SetDNSName defines the domain name to be used in the webhook +// integration tests. +func SetDNSName(s string) Option { + return func(f *fixture) { + f.dnsName = s + } +} diff --git a/test/acme/dns/util.go b/test/acme/dns/util.go index 065df32d4..e26d9b020 100644 --- a/test/acme/dns/util.go +++ b/test/acme/dns/util.go @@ -87,9 +87,8 @@ func (f *fixture) buildChallengeRequest(t *testing.T, ns string) *whapi.Challeng ResolvedZone: f.resolvedZone, AllowAmbientCredentials: f.allowAmbientCredentials, Config: f.jsonConfig, - // TODO - DNSName: "example.com", - Key: "123d==", + DNSName: f.dnsName, + Key: f.dnsChallengeKey, } }