forked from TrueCloudLab/lego
47219adc00
Different DNS providers were handling credentials in different ways. Some were reading credential environment variables in cli_handlers.go and then passing them into the NewDNSProvider function, while others were reading the environment variables within their NewDNSProvider functions. This change replaces each DNS challenge's NewDNSProvider function with two new functions: (1) a NewDNSProvider function that takes no parameters and uses the environment to read credentials, and (2) a NewDNSProviderCredentials that takes credentials as parameters.
53 lines
1,017 B
Go
53 lines
1,017 B
Go
package dyn
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
var (
|
|
dynLiveTest bool
|
|
dynCustomerName string
|
|
dynUserName string
|
|
dynPassword string
|
|
dynDomain string
|
|
)
|
|
|
|
func init() {
|
|
dynCustomerName = os.Getenv("DYN_CUSTOMER_NAME")
|
|
dynUserName = os.Getenv("DYN_USER_NAME")
|
|
dynPassword = os.Getenv("DYN_PASSWORD")
|
|
dynDomain = os.Getenv("DYN_DOMAIN")
|
|
if len(dynCustomerName) > 0 && len(dynUserName) > 0 && len(dynPassword) > 0 && len(dynDomain) > 0 {
|
|
dynLiveTest = true
|
|
}
|
|
}
|
|
|
|
func TestLiveDynPresent(t *testing.T) {
|
|
if !dynLiveTest {
|
|
t.Skip("skipping live test")
|
|
}
|
|
|
|
provider, err := NewDNSProvider()
|
|
assert.NoError(t, err)
|
|
|
|
err = provider.Present(dynDomain, "", "123d==")
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
func TestLiveDynCleanUp(t *testing.T) {
|
|
if !dynLiveTest {
|
|
t.Skip("skipping live test")
|
|
}
|
|
|
|
time.Sleep(time.Second * 1)
|
|
|
|
provider, err := NewDNSProvider()
|
|
assert.NoError(t, err)
|
|
|
|
err = provider.CleanUp(dynDomain, "", "123d==")
|
|
assert.NoError(t, err)
|
|
}
|