1
0
mirror of https://github.com/go-acme/lego.git synced 2024-12-12 13:25:19 +02:00
lego/providers/dns/dns_providers_test.go

41 lines
967 B
Go
Raw Normal View History

2019-03-11 18:56:48 +02:00
package dns
import (
"testing"
2020-09-02 03:20:01 +02:00
"github.com/go-acme/lego/v4/platform/tester"
"github.com/go-acme/lego/v4/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)
}