| 1 | package nicmanagerscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/ |
| 2 | |
| 3 | import ( |
| 4 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 5 | "timescip-go gomod github.com/golang/go/src go1.25.0 time/" |
| 6 | |
| 7 | "github.com/go-acme/lego/v4/platform/testerscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/" |
| 8 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/" |
| 9 | ) |
| 10 | |
| 11 | const envDomainscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/envDomain. = envNamespacescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/envNamespace. + "DOMAIN" |
| 12 | |
| 13 | var envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/envTest. = testerscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/.NewEnvTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/NewEnvTest().(EnvUsernamescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/EnvUsername., EnvLoginscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/EnvLogin., EnvEmailscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/EnvEmail., EnvPasswordscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/EnvPassword., EnvOTPscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/EnvOTP.). |
| 14 | WithDomainscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#WithDomain().(envDomainscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/envDomain.) |
| 15 | |
| 16 | func TestNewDNSProviderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/TestNewDNSProvider().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 17 | testCases := []struct { |
| 18 | desc string |
| 19 | envVars map[string]string |
| 20 | expected string |
| 21 | }{ |
| 22 | { |
| 23 | desc: "success (email)", |
| 24 | envVars: map[string]string{ |
| 25 | EnvEmailscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/EnvEmail.: "[email protected]", |
| 26 | EnvPasswordscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/EnvPassword.: "secret", |
| 27 | }, |
| 28 | }, |
| 29 | { |
| 30 | desc: "success (login.username)", |
| 31 | envVars: map[string]string{ |
| 32 | EnvLoginscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/EnvLogin.: "foo", |
| 33 | EnvUsernamescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/EnvUsername.: "bar", |
| 34 | EnvPasswordscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/EnvPassword.: "secret", |
| 35 | }, |
| 36 | }, |
| 37 | { |
| 38 | desc: "missing credentials", |
| 39 | expected: "nicmanager: some credentials information are missing: NICMANAGER_API_PASSWORD", |
| 40 | }, |
| 41 | { |
| 42 | desc: "missing password", |
| 43 | envVars: map[string]string{ |
| 44 | EnvEmailscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/EnvEmail.: "[email protected]", |
| 45 | }, |
| 46 | expected: "nicmanager: some credentials information are missing: NICMANAGER_API_PASSWORD", |
| 47 | }, |
| 48 | { |
| 49 | desc: "missing username", |
| 50 | envVars: map[string]string{ |
| 51 | EnvLoginscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/EnvLogin.: "foo", |
| 52 | EnvPasswordscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/EnvPassword.: "secret", |
| 53 | }, |
| 54 | expected: "nicmanager: credentials missing", |
| 55 | }, |
| 56 | { |
| 57 | desc: "missing login", |
| 58 | envVars: map[string]string{ |
| 59 | EnvUsernamescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/EnvUsername.: "bar", |
| 60 | EnvPasswordscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/EnvPassword.: "secret", |
| 61 | }, |
| 62 | expected: "nicmanager: credentials missing", |
| 63 | }, |
| 64 | } |
| 65 | |
| 66 | for _, test := range testCases { |
| 67 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(test.desc, func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 68 | defer envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/envTest..RestoreEnvscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#RestoreEnv().() |
| 69 | |
| 70 | envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/envTest..ClearEnvscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#ClearEnv().() |
| 71 | |
| 72 | envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/envTest..Applyscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#Apply().(test.envVars) |
| 73 | |
| 74 | p, err := NewDNSProviderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/NewDNSProvider().() |
| 75 | |
| 76 | if test.expected == "" { |
| 77 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 78 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NotNil().(t, p) |
| 79 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NotNil().(t, p.configscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/DNSProvider#config.) |
| 80 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NotNil().(t, p.clientscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/DNSProvider#client.) |
| 81 | } else { |
| 82 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.EqualErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/EqualError().(t, err, test.expected) |
| 83 | } |
| 84 | }) |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | func TestNewDNSProviderConfigscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/TestNewDNSProviderConfig().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 89 | testCases := []struct { |
| 90 | desc string |
| 91 | login string |
| 92 | username string |
| 93 | email string |
| 94 | password string |
| 95 | otpSecret string |
| 96 | expected string |
| 97 | }{ |
| 98 | { |
| 99 | desc: "success (email)", |
| 100 | email: "[email protected]", |
| 101 | password: "secret", |
| 102 | }, |
| 103 | { |
| 104 | desc: "success (login.username)", |
| 105 | login: "john", |
| 106 | username: "doe", |
| 107 | password: "secret", |
| 108 | }, |
| 109 | { |
| 110 | desc: "missing credentials", |
| 111 | expected: "nicmanager: credentials missing", |
| 112 | }, |
| 113 | { |
| 114 | desc: "missing password", |
| 115 | email: "[email protected]", |
| 116 | expected: "nicmanager: credentials missing", |
| 117 | }, |
| 118 | { |
| 119 | desc: "missing login", |
| 120 | login: "", |
| 121 | username: "doe", |
| 122 | password: "secret", |
| 123 | expected: "nicmanager: credentials missing", |
| 124 | }, |
| 125 | { |
| 126 | desc: "missing username", |
| 127 | login: "john", |
| 128 | username: "", |
| 129 | password: "secret", |
| 130 | expected: "nicmanager: credentials missing", |
| 131 | }, |
| 132 | } |
| 133 | |
| 134 | for _, test := range testCases { |
| 135 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(test.desc, func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 136 | config := NewDefaultConfigscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/NewDefaultConfig().() |
| 137 | config.Loginscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/Config#Login. = test.login |
| 138 | config.Usernamescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/Config#Username. = test.username |
| 139 | config.Emailscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/Config#Email. = test.email |
| 140 | config.Passwordscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/Config#Password. = test.password |
| 141 | config.OTPSecretscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/Config#OTPSecret. = test.otpSecret |
| 142 | |
| 143 | p, err := NewDNSProviderConfigscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/NewDNSProviderConfig().(config) |
| 144 | |
| 145 | if test.expected == "" { |
| 146 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 147 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NotNil().(t, p) |
| 148 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NotNil().(t, p.configscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/DNSProvider#config.) |
| 149 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NotNil().(t, p.clientscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/DNSProvider#client.) |
| 150 | } else { |
| 151 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.EqualErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/EqualError().(t, err, test.expected) |
| 152 | } |
| 153 | }) |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | func TestLivePresentscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/TestLivePresent().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 158 | if !envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/envTest..IsLiveTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#IsLiveTest().() { |
| 159 | t.Skipscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Skip().("skipping live test") |
| 160 | } |
| 161 | |
| 162 | envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/envTest..RestoreEnvscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#RestoreEnv().() |
| 163 | |
| 164 | provider, err := NewDNSProviderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/NewDNSProvider().() |
| 165 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 166 | |
| 167 | err = provider.Presentscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/DNSProvider#Present().(envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/envTest..GetDomainscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#GetDomain().(), "", "123d==") |
| 168 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 169 | } |
| 170 | |
| 171 | func TestLiveCleanUpscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/TestLiveCleanUp().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 172 | if !envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/envTest..IsLiveTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#IsLiveTest().() { |
| 173 | t.Skipscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Skip().("skipping live test") |
| 174 | } |
| 175 | |
| 176 | envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/envTest..RestoreEnvscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#RestoreEnv().() |
| 177 | |
| 178 | provider, err := NewDNSProviderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/NewDNSProvider().() |
| 179 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 180 | |
| 181 | timescip-go gomod github.com/golang/go/src go1.25.0 time/.Sleepscip-go gomod github.com/golang/go/src go1.25.0 time/Sleep().(1 * timescip-go gomod github.com/golang/go/src go1.25.0 time/.Secondscip-go gomod github.com/golang/go/src go1.25.0 time/Second.) |
| 182 | |
| 183 | err = provider.CleanUpscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/DNSProvider#CleanUp().(envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/nicmanager`/envTest..GetDomainscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#GetDomain().(), "", "123d==") |
| 184 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 185 | } |