diff --git a/acme/dns_challenge_dnsimple.go b/acme/dns_challenge_dnsimple.go index 4cd862a8..754cce63 100644 --- a/acme/dns_challenge_dnsimple.go +++ b/acme/dns_challenge_dnsimple.go @@ -1,6 +1,8 @@ package acme import ( + "fmt" + "github.com/weppos/go-dnsimple/dnsimple" ) @@ -12,7 +14,15 @@ type DNSProviderDNSimple struct { // NewDNSProviderDNSimple returns a DNSProviderDNSimple instance with a configured dnsimple client. // Authentication is either done using the passed credentials. func NewDNSProviderDNSimple(dnsimpleEmail, dnsimpleApiKey string) (*DNSProviderDNSimple, error) { - return nil, nil + if dnsimpleEmail == "" || dnsimpleApiKey == "" { + return nil, fmt.Errorf("DNSimple credentials missing") + } + + c := &DNSProviderDNSimple{ + client: dnsimple.NewClient(dnsimpleApiKey, dnsimpleEmail), + } + + return c, nil } // Present creates a TXT record to fulfil the dns-01 challenge. diff --git a/acme/dns_challenge_dnsimple_test.go b/acme/dns_challenge_dnsimple_test.go index 9e7e4d9b..6fa1b76f 100644 --- a/acme/dns_challenge_dnsimple_test.go +++ b/acme/dns_challenge_dnsimple_test.go @@ -6,8 +6,12 @@ import ( "github.com/stretchr/testify/assert" ) - func TestNewDNSProviderDNSimpleValid(t *testing.T) { _, err := NewDNSProviderDNSimple("example@example.com", "123") assert.NoError(t, err) } + +func TestNewDNSProviderDNSimpleMissingCredErr(t *testing.T) { + _, err := NewDNSProviderDNSimple("", "") + assert.EqualError(t, err, "DNSimple credentials missing") +}