forked from TrueCloudLab/lego
91b13b10b9
* add Name.com provider * add namedotcom provider env vars to output of cli.go
58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package namedotcom
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
func TestLivenamedotcomPresent(t *testing.T) {
|
|
if !namedotcomLiveTest {
|
|
t.Skip("skipping live test")
|
|
}
|
|
|
|
provider, err := NewDNSProviderCredentials(namedotcomUsername, namedotcomAPIToken, namedotcomServer)
|
|
assert.NoError(t, err)
|
|
|
|
err = provider.Present(namedotcomDomain, "", "123d==")
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
//
|
|
// Cleanup
|
|
//
|
|
|
|
func TestLivenamedotcomCleanUp(t *testing.T) {
|
|
if !namedotcomLiveTest {
|
|
t.Skip("skipping live test")
|
|
}
|
|
|
|
time.Sleep(time.Second * 1)
|
|
|
|
provider, err := NewDNSProviderCredentials(namedotcomUsername, namedotcomAPIToken, namedotcomServer)
|
|
assert.NoError(t, err)
|
|
|
|
err = provider.CleanUp(namedotcomDomain, "", "123d==")
|
|
assert.NoError(t, err)
|
|
}
|