2018-03-14 17:43:09 +00:00
|
|
|
package namedotcom
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2018-09-24 19:07:20 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2018-03-14 17:43:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
namedotcomLiveTest bool
|
|
|
|
namedotcomUsername string
|
|
|
|
namedotcomAPIToken string
|
|
|
|
namedotcomDomain string
|
|
|
|
namedotcomServer string
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
namedotcomUsername = os.Getenv("NAMEDOTCOM_USERNAME")
|
|
|
|
namedotcomAPIToken = os.Getenv("NAMEDOTCOM_API_TOKEN")
|
|
|
|
namedotcomDomain = os.Getenv("NAMEDOTCOM_DOMAIN")
|
|
|
|
namedotcomServer = os.Getenv("NAMEDOTCOM_SERVER")
|
|
|
|
|
|
|
|
if len(namedotcomAPIToken) > 0 && len(namedotcomUsername) > 0 && len(namedotcomDomain) > 0 {
|
|
|
|
namedotcomLiveTest = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-11 15:32:50 +00:00
|
|
|
func TestLiveNamedotcomPresent(t *testing.T) {
|
2018-03-14 17:43:09 +00:00
|
|
|
if !namedotcomLiveTest {
|
|
|
|
t.Skip("skipping live test")
|
|
|
|
}
|
|
|
|
|
2018-09-15 17:07:24 +00:00
|
|
|
config := NewDefaultConfig()
|
|
|
|
config.Username = namedotcomUsername
|
|
|
|
config.APIToken = namedotcomAPIToken
|
|
|
|
config.Server = namedotcomServer
|
|
|
|
|
|
|
|
provider, err := NewDNSProviderConfig(config)
|
2018-09-24 19:07:20 +00:00
|
|
|
require.NoError(t, err)
|
2018-03-14 17:43:09 +00:00
|
|
|
|
|
|
|
err = provider.Present(namedotcomDomain, "", "123d==")
|
2018-09-24 19:07:20 +00:00
|
|
|
require.NoError(t, err)
|
2018-03-14 17:43:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Cleanup
|
|
|
|
//
|
|
|
|
|
2018-06-11 15:32:50 +00:00
|
|
|
func TestLiveNamedotcomCleanUp(t *testing.T) {
|
2018-03-14 17:43:09 +00:00
|
|
|
if !namedotcomLiveTest {
|
|
|
|
t.Skip("skipping live test")
|
|
|
|
}
|
|
|
|
|
|
|
|
time.Sleep(time.Second * 1)
|
|
|
|
|
2018-09-15 17:07:24 +00:00
|
|
|
config := NewDefaultConfig()
|
|
|
|
config.Username = namedotcomUsername
|
|
|
|
config.APIToken = namedotcomAPIToken
|
|
|
|
config.Server = namedotcomServer
|
|
|
|
|
|
|
|
provider, err := NewDNSProviderConfig(config)
|
2018-09-24 19:07:20 +00:00
|
|
|
require.NoError(t, err)
|
2018-03-14 17:43:09 +00:00
|
|
|
|
|
|
|
err = provider.CleanUp(namedotcomDomain, "", "123d==")
|
2018-09-24 19:07:20 +00:00
|
|
|
require.NoError(t, err)
|
2018-03-14 17:43:09 +00:00
|
|
|
}
|