Skip to content

Commit

Permalink
DNSimpleProvider: Check valid credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Jan 26, 2016
1 parent 3f4b078 commit bcfce08
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 11 additions & 1 deletion acme/dns_challenge_dnsimple.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package acme

import (
"fmt"

"github.com/weppos/go-dnsimple/dnsimple"
)

Expand All @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion acme/dns_challenge_dnsimple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ import (
"github.com/stretchr/testify/assert"
)


func TestNewDNSProviderDNSimpleValid(t *testing.T) {
_, err := NewDNSProviderDNSimple("[email protected]", "123")
assert.NoError(t, err)
}

func TestNewDNSProviderDNSimpleMissingCredErr(t *testing.T) {
_, err := NewDNSProviderDNSimple("", "")
assert.EqualError(t, err, "DNSimple credentials missing")
}

0 comments on commit bcfce08

Please sign in to comment.