2016-01-26 11:14:10 +00:00
|
|
|
package acme
|
|
|
|
|
|
|
|
import (
|
2016-01-26 11:42:44 +00:00
|
|
|
"os"
|
2016-01-26 11:14:10 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2016-01-26 11:42:44 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2016-01-26 11:14:10 +00:00
|
|
|
func TestNewDNSProviderDNSimpleValid(t *testing.T) {
|
2016-01-26 11:42:44 +00:00
|
|
|
os.Setenv("DNSIMPLE_EMAIL", "")
|
|
|
|
os.Setenv("DNSIMPLE_API_KEY", "")
|
2016-01-26 11:14:10 +00:00
|
|
|
_, err := NewDNSProviderDNSimple("example@example.com", "123")
|
|
|
|
assert.NoError(t, err)
|
2016-01-26 11:42:44 +00:00
|
|
|
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()
|
2016-01-26 11:14:10 +00:00
|
|
|
}
|
2016-01-26 11:25:51 +00:00
|
|
|
|
|
|
|
func TestNewDNSProviderDNSimpleMissingCredErr(t *testing.T) {
|
2016-01-26 11:42:44 +00:00
|
|
|
os.Setenv("DNSIMPLE_EMAIL", "")
|
|
|
|
os.Setenv("DNSIMPLE_API_KEY", "")
|
2016-01-26 11:25:51 +00:00
|
|
|
_, err := NewDNSProviderDNSimple("", "")
|
|
|
|
assert.EqualError(t, err, "DNSimple credentials missing")
|
2016-01-26 11:42:44 +00:00
|
|
|
restoreDNSimpleEnv()
|
2016-01-26 11:25:51 +00:00
|
|
|
}
|