forked from TrueCloudLab/lego
e7a90b9471
- chore: update dependencies: use version with go modules. - chore: remove dep. - chore: update backoff imports. - chore: init go module. - chore: update CI. - chore: mod v3 - chore: update docker image.
40 lines
967 B
Go
40 lines
967 B
Go
package dns
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/go-acme/lego/v3/platform/tester"
|
|
"github.com/go-acme/lego/v3/providers/dns/exec"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
var envTest = tester.NewEnvTest("EXEC_PATH")
|
|
|
|
func TestKnownDNSProviderSuccess(t *testing.T) {
|
|
defer envTest.RestoreEnv()
|
|
envTest.Apply(map[string]string{
|
|
"EXEC_PATH": "abc",
|
|
})
|
|
|
|
provider, err := NewDNSChallengeProviderByName("exec")
|
|
require.NoError(t, err)
|
|
assert.NotNil(t, provider)
|
|
|
|
assert.IsType(t, &exec.DNSProvider{}, provider, "The loaded DNS provider doesn't have the expected type.")
|
|
}
|
|
|
|
func TestKnownDNSProviderError(t *testing.T) {
|
|
defer envTest.RestoreEnv()
|
|
envTest.ClearEnv()
|
|
|
|
provider, err := NewDNSChallengeProviderByName("exec")
|
|
assert.Error(t, err)
|
|
assert.Nil(t, provider)
|
|
}
|
|
|
|
func TestUnknownDNSProvider(t *testing.T) {
|
|
provider, err := NewDNSChallengeProviderByName("foobar")
|
|
assert.Error(t, err)
|
|
assert.Nil(t, provider)
|
|
}
|