forked from TrueCloudLab/lego
6a3297e36f
I also had to rename the `envAuth()` in the Cloudflare implementation to avoid the "redeclared" error acme/dns_challenge_dnsimple.go:41: envAuth redeclared in this block previous declaration at acme/dns_challenge_cloudflare.go:154
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package acme
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
var (
|
|
dnsimpleEmail string
|
|
dnsimpleAPIKey string
|
|
)
|
|
|
|
func init() {
|
|
dnsimpleEmail = os.Getenv("DNSIMPLE_EMAIL")
|
|
dnsimpleAPIKey = os.Getenv("DNSIMPLE_API_KEY")
|
|
}
|
|
|
|
func restoreDNSimpleEnv() {
|
|
os.Setenv("DNSIMPLE_EMAIL", dnsimpleEmail)
|
|
os.Setenv("DNSIMPLE_API_KEY", dnsimpleAPIKey)
|
|
}
|
|
|
|
func TestNewDNSProviderDNSimpleValid(t *testing.T) {
|
|
os.Setenv("DNSIMPLE_EMAIL", "")
|
|
os.Setenv("DNSIMPLE_API_KEY", "")
|
|
_, err := NewDNSProviderDNSimple("example@example.com", "123")
|
|
assert.NoError(t, err)
|
|
restoreDNSimpleEnv()
|
|
}
|
|
func TestNewDNSProviderDNSimpleValidEnv(t *testing.T) {
|
|
os.Setenv("DNSIMPLE_EMAIL", "example@example.com")
|
|
os.Setenv("DNSIMPLE_API_KEY", "123")
|
|
_, err := NewDNSProviderDNSimple("", "")
|
|
assert.NoError(t, err)
|
|
restoreDNSimpleEnv()
|
|
}
|
|
|
|
func TestNewDNSProviderDNSimpleMissingCredErr(t *testing.T) {
|
|
os.Setenv("DNSIMPLE_EMAIL", "")
|
|
os.Setenv("DNSIMPLE_API_KEY", "")
|
|
_, err := NewDNSProviderDNSimple("", "")
|
|
assert.EqualError(t, err, "DNSimple credentials missing")
|
|
restoreDNSimpleEnv()
|
|
}
|