mirror of
https://github.com/go-acme/lego.git
synced 2025-01-26 06:55:18 +02:00
DNSimpleProvider: Check valid credentials
This commit is contained in:
parent
3f4b078329
commit
bcfce0809a
@ -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.
|
||||
|
@ -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")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user