| 1 | package exoscalescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/ |
| 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/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/" |
| 9 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/" |
| 10 | ) |
| 11 | |
| 12 | const envDomainscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/envDomain. = envNamespacescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/envNamespace. + "DOMAIN" |
| 13 | |
| 14 | var envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/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().( |
| 15 | EnvAPISecretscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/EnvAPISecret., |
| 16 | EnvAPIKeyscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/EnvAPIKey.). |
| 17 | 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/exoscale`/envDomain.) |
| 18 | |
| 19 | func TestNewDNSProviderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/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#) { |
| 20 | testCases := []struct { |
| 21 | desc string |
| 22 | envVars map[string]string |
| 23 | expected string |
| 24 | }{ |
| 25 | { |
| 26 | desc: "success", |
| 27 | envVars: map[string]string{ |
| 28 | EnvAPIKeyscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/EnvAPIKey.: "123", |
| 29 | EnvAPISecretscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/EnvAPISecret.: "456", |
| 30 | }, |
| 31 | }, |
| 32 | { |
| 33 | desc: "missing credentials", |
| 34 | envVars: map[string]string{ |
| 35 | EnvAPIKeyscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/EnvAPIKey.: "", |
| 36 | EnvAPISecretscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/EnvAPISecret.: "", |
| 37 | }, |
| 38 | expected: "exoscale: some credentials information are missing: EXOSCALE_API_KEY,EXOSCALE_API_SECRET", |
| 39 | }, |
| 40 | { |
| 41 | desc: "missing access key", |
| 42 | envVars: map[string]string{ |
| 43 | EnvAPIKeyscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/EnvAPIKey.: "", |
| 44 | EnvAPISecretscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/EnvAPISecret.: "456", |
| 45 | }, |
| 46 | expected: "exoscale: some credentials information are missing: EXOSCALE_API_KEY", |
| 47 | }, |
| 48 | { |
| 49 | desc: "missing secret key", |
| 50 | envVars: map[string]string{ |
| 51 | EnvAPIKeyscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/EnvAPIKey.: "123", |
| 52 | EnvAPISecretscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/EnvAPISecret.: "", |
| 53 | }, |
| 54 | expected: "exoscale: some credentials information are missing: EXOSCALE_API_SECRET", |
| 55 | }, |
| 56 | } |
| 57 | |
| 58 | for _, test := range testCases { |
| 59 | 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#) { |
| 60 | defer envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/envTest..RestoreEnvscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#RestoreEnv().() |
| 61 | |
| 62 | envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/envTest..ClearEnvscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#ClearEnv().() |
| 63 | |
| 64 | envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/envTest..Applyscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#Apply().(test.envVars) |
| 65 | |
| 66 | p, err := NewDNSProviderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/NewDNSProvider().() |
| 67 | |
| 68 | if test.expected == "" { |
| 69 | 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) |
| 70 | 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) |
| 71 | 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/exoscale`/DNSProvider#config.) |
| 72 | 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/exoscale`/DNSProvider#client.) |
| 73 | } else { |
| 74 | 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) |
| 75 | } |
| 76 | }) |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | func TestNewDNSProviderConfigscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/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#) { |
| 81 | testCases := []struct { |
| 82 | desc string |
| 83 | apiKey string |
| 84 | apiSecret string |
| 85 | expected string |
| 86 | }{ |
| 87 | { |
| 88 | desc: "success", |
| 89 | apiKey: "123", |
| 90 | apiSecret: "456", |
| 91 | }, |
| 92 | { |
| 93 | desc: "missing credentials", |
| 94 | expected: "exoscale: credentials missing", |
| 95 | }, |
| 96 | { |
| 97 | desc: "missing api key", |
| 98 | apiSecret: "456", |
| 99 | expected: "exoscale: credentials missing", |
| 100 | }, |
| 101 | { |
| 102 | desc: "missing secret key", |
| 103 | apiKey: "123", |
| 104 | expected: "exoscale: credentials missing", |
| 105 | }, |
| 106 | } |
| 107 | |
| 108 | for _, test := range testCases { |
| 109 | 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#) { |
| 110 | config := NewDefaultConfigscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/NewDefaultConfig().() |
| 111 | config.APIKeyscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/Config#APIKey. = test.apiKey |
| 112 | config.APISecretscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/Config#APISecret. = test.apiSecret |
| 113 | |
| 114 | p, err := NewDNSProviderConfigscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/NewDNSProviderConfig().(config) |
| 115 | |
| 116 | if test.expected == "" { |
| 117 | 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) |
| 118 | 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) |
| 119 | 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/exoscale`/DNSProvider#config.) |
| 120 | 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/exoscale`/DNSProvider#client.) |
| 121 | } else { |
| 122 | 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) |
| 123 | } |
| 124 | }) |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | func TestDNSProvider_FindZoneAndRecordNamescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/TestDNSProvider_FindZoneAndRecordName().(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#) { |
| 129 | config := NewDefaultConfigscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/NewDefaultConfig().() |
| 130 | config.APIKeyscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/Config#APIKey. = "[email protected]" |
| 131 | config.APISecretscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/Config#APISecret. = "123" |
| 132 | |
| 133 | provider, err := NewDNSProviderConfigscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/NewDNSProviderConfig().(config) |
| 134 | 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) |
| 135 | |
| 136 | type expected struct { |
| 137 | zone string |
| 138 | recordName string |
| 139 | } |
| 140 | |
| 141 | testCases := []struct { |
| 142 | desc string |
| 143 | fqdn string |
| 144 | expected expected |
| 145 | }{ |
| 146 | { |
| 147 | desc: "Extract root record name", |
| 148 | fqdn: "_acme-challenge.example.com.", |
| 149 | expected: expected{ |
| 150 | zone: "example.com", |
| 151 | recordName: "_acme-challenge", |
| 152 | }, |
| 153 | }, |
| 154 | { |
| 155 | desc: "Extract sub record name", |
| 156 | fqdn: "_acme-challenge.foo.example.com.", |
| 157 | expected: expected{ |
| 158 | zone: "example.com", |
| 159 | recordName: "_acme-challenge.foo", |
| 160 | }, |
| 161 | }, |
| 162 | } |
| 163 | |
| 164 | for _, test := range testCases { |
| 165 | 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#) { |
| 166 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 167 | |
| 168 | zone, recordName, err := provider.findZoneAndRecordNamescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/DNSProvider#findZoneAndRecordName().(test.fqdn) |
| 169 | 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) |
| 170 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, test.expected.zone, zone) |
| 171 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, test.expected.recordName, recordName) |
| 172 | }) |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | func TestLivePresentscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/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#) { |
| 177 | if !envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/envTest..IsLiveTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#IsLiveTest().() { |
| 178 | t.Skipscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Skip().("skipping live test") |
| 179 | } |
| 180 | |
| 181 | envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/envTest..RestoreEnvscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#RestoreEnv().() |
| 182 | |
| 183 | provider, err := NewDNSProviderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/NewDNSProvider().() |
| 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 | |
| 186 | err = provider.Presentscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/DNSProvider#Present().(envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/envTest..GetDomainscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#GetDomain().(), "", "123d==") |
| 187 | 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) |
| 188 | |
| 189 | // Present Twice to handle create / update |
| 190 | err = provider.Presentscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/DNSProvider#Present().(envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/envTest..GetDomainscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#GetDomain().(), "", "123d==") |
| 191 | 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) |
| 192 | } |
| 193 | |
| 194 | func TestLiveCleanUpscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/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#) { |
| 195 | if !envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/envTest..IsLiveTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#IsLiveTest().() { |
| 196 | t.Skipscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Skip().("skipping live test") |
| 197 | } |
| 198 | |
| 199 | envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/envTest..RestoreEnvscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#RestoreEnv().() |
| 200 | |
| 201 | provider, err := NewDNSProviderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/NewDNSProvider().() |
| 202 | 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) |
| 203 | |
| 204 | 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.) |
| 205 | |
| 206 | err = provider.CleanUpscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/DNSProvider#CleanUp().(envTestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/exoscale`/envTest..GetDomainscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester`/EnvTest#GetDomain().(), "", "123d==") |
| 207 | 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) |
| 208 | } |