2018-07-01 00:13:22 +00:00
|
|
|
package nifcloud
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2018-09-24 19:07:20 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2018-07-01 00:13:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
nifcloudLiveTest bool
|
|
|
|
nifcloudAccessKey string
|
|
|
|
nifcloudSecretKey string
|
|
|
|
nifcloudDomain string
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
nifcloudAccessKey = os.Getenv("NIFCLOUD_ACCESS_KEY_ID")
|
|
|
|
nifcloudSecretKey = os.Getenv("NIFCLOUD_SECRET_ACCESS_KEY")
|
|
|
|
nifcloudDomain = os.Getenv("NIFCLOUD_DOMAIN")
|
|
|
|
|
|
|
|
if len(nifcloudAccessKey) > 0 && len(nifcloudSecretKey) > 0 && len(nifcloudDomain) > 0 {
|
|
|
|
nifcloudLiveTest = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLivenifcloudPresent(t *testing.T) {
|
|
|
|
if !nifcloudLiveTest {
|
|
|
|
t.Skip("skipping live test")
|
|
|
|
}
|
|
|
|
|
|
|
|
provider, err := NewDNSProvider()
|
2018-09-24 19:07:20 +00:00
|
|
|
require.NoError(t, err)
|
2018-07-01 00:13:22 +00:00
|
|
|
|
|
|
|
err = provider.Present(nifcloudDomain, "", "123d==")
|
2018-09-24 19:07:20 +00:00
|
|
|
require.NoError(t, err)
|
2018-07-01 00:13:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestLivenifcloudCleanUp(t *testing.T) {
|
|
|
|
if !nifcloudLiveTest {
|
|
|
|
t.Skip("skipping live test")
|
|
|
|
}
|
|
|
|
|
|
|
|
time.Sleep(time.Second * 1)
|
|
|
|
|
|
|
|
provider, err := NewDNSProvider()
|
2018-09-24 19:07:20 +00:00
|
|
|
require.NoError(t, err)
|
2018-07-01 00:13:22 +00:00
|
|
|
|
|
|
|
err = provider.CleanUp(nifcloudDomain, "", "123d==")
|
2018-09-24 19:07:20 +00:00
|
|
|
require.NoError(t, err)
|
2018-07-01 00:13:22 +00:00
|
|
|
}
|