augment acmedns unit testing
Signed-off-by: JuanJo Ciarlante <juanjosec@gmail.com>
This commit is contained in:
parent
ef2924c26a
commit
225a37ce7c
@ -39,6 +39,34 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidJsonAccount(t *testing.T) {
|
||||
accountJson := []byte(`{
|
||||
"domain": {
|
||||
"fulldomain": "fooldom",
|
||||
"password": "secret",
|
||||
"subdomain": "subdoom",
|
||||
"username": "usernom"
|
||||
}
|
||||
}`)
|
||||
provider, err := NewDNSProviderHostBytes("http://localhost/", accountJson, util.RecursiveNameservers)
|
||||
assert.NoError(t, err, "Expected no error constructing DNSProvider")
|
||||
|
||||
assert.NoError(t, err, "Expected account to be set from JSON")
|
||||
assert.Equal(t, provider.accounts["domain"].FullDomain, "fooldom")
|
||||
}
|
||||
|
||||
func TestNoValidJsonAccount(t *testing.T) {
|
||||
accountJson := []byte(`{"duck": "quack"}`)
|
||||
_, err := NewDNSProviderHostBytes("http://localhost/", accountJson, util.RecursiveNameservers)
|
||||
assert.Error(t, err, "Expected no error constructing DNSProvider")
|
||||
}
|
||||
|
||||
func TestNoValidJson(t *testing.T) {
|
||||
accountJson := []byte("b00m")
|
||||
_, err := NewDNSProviderHostBytes("http://localhost/", accountJson, util.RecursiveNameservers)
|
||||
assert.Error(t, err, "Expected no error constructing DNSProvider")
|
||||
}
|
||||
|
||||
func TestLiveAcmeDnsPresent(t *testing.T) {
|
||||
if !acmednsLiveTest {
|
||||
t.Skip("skipping live test")
|
||||
|
||||
@ -27,6 +27,7 @@ import (
|
||||
"github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha1"
|
||||
"github.com/jetstack/cert-manager/pkg/controller"
|
||||
"github.com/jetstack/cert-manager/pkg/controller/test"
|
||||
"github.com/jetstack/cert-manager/pkg/issuer/acme/dns/acmedns"
|
||||
"github.com/jetstack/cert-manager/pkg/issuer/acme/dns/cloudflare"
|
||||
"github.com/jetstack/cert-manager/pkg/issuer/acme/dns/util"
|
||||
)
|
||||
@ -208,6 +209,40 @@ func TestSolverFor(t *testing.T) {
|
||||
domain: "example.com",
|
||||
expectErr: true,
|
||||
},
|
||||
"loads json for acmedns provider": {
|
||||
solverFixture: &solverFixture{
|
||||
Builder: &test.Builder{
|
||||
KubeObjects: []runtime.Object{
|
||||
newSecret("acmedns-key", "default", map[string][]byte{
|
||||
"acmedns.json": []byte("{x}"),
|
||||
}),
|
||||
},
|
||||
},
|
||||
Issuer: newIssuer("test", "default", []v1alpha1.ACMEIssuerDNS01Provider{
|
||||
{
|
||||
Name: "fake-acmedns",
|
||||
AcmeDNS: &v1alpha1.ACMEIssuerDNS01ProviderAcmeDNS{
|
||||
Host: "http://127.0.0.1/",
|
||||
AccountSecret: v1alpha1.SecretKeySelector{
|
||||
LocalObjectReference: v1alpha1.LocalObjectReference{
|
||||
Name: "acmedns-key",
|
||||
},
|
||||
Key: "acmedns.json",
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
Challenge: v1alpha1.ACMEOrderChallenge{
|
||||
SolverConfig: v1alpha1.SolverConfig{
|
||||
DNS01: &v1alpha1.DNS01SolverConfig{
|
||||
Provider: "fake-acmedns",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
domain: "example.com",
|
||||
expectedSolverType: reflect.TypeOf(&acmedns.DNSProvider{}),
|
||||
},
|
||||
}
|
||||
testFn := func(test testT) func(*testing.T) {
|
||||
return func(t *testing.T) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user