| 1 | package internalscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/ |
| 2 | |
| 3 | import ( |
| 4 | "net/http/httptestscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/" |
| 5 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 6 | |
| 7 | "github.com/go-acme/lego/v4/platform/tester/servermockscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/" |
| 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 | func setupClientscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/setupClient().(server *httptestscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/.Serverscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#) (*Clientscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/Client#, error) { |
| 13 | client := NewClientscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/NewClient().("secret") |
| 14 | client.baseURLscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/Client#baseURL. = server.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#URL. |
| 15 | client.HTTPClientscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/Client#HTTPClient. = server.Clientscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#Client().() |
| 16 | |
| 17 | return client, nil |
| 18 | } |
| 19 | |
| 20 | func TestClient_AddTXTRecordscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/TestClient_AddTXTRecord().(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#) { |
| 21 | client := servermockscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/.NewBuilderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/NewBuilder().[*Clientscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/Client#](setupClientscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/setupClient().). |
| 22 | Routescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/Builder#Route().("GET /", servermockscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/.RawStringResponsescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/RawStringResponse().("OK"), |
| 23 | servermockscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/.CheckQueryParameterscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/CheckQueryParameter().().Strictscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/QueryParameterLink#Strict().(). |
| 24 | Withscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/QueryParameterLink#With().("clear", "false"). |
| 25 | Withscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/QueryParameterLink#With().("domains", "com"). |
| 26 | Withscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/QueryParameterLink#With().("token", "secret"). |
| 27 | Withscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/QueryParameterLink#With().("txt", "value")). |
| 28 | Buildscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/Builder#Build().(t) |
| 29 | |
| 30 | err := client.AddTXTRecordscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/Client#AddTXTRecord().(t.Contextscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Context().(), "example.com", "value") |
| 31 | 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) |
| 32 | } |
| 33 | |
| 34 | func TestClient_RemoveTXTRecordscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/TestClient_RemoveTXTRecord().(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#) { |
| 35 | client := servermockscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/.NewBuilderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/NewBuilder().[*Clientscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/Client#](setupClientscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/setupClient().). |
| 36 | Routescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/Builder#Route().("GET /", servermockscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/.RawStringResponsescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/RawStringResponse().("OK"), |
| 37 | servermockscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/.CheckQueryParameterscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/CheckQueryParameter().().Strictscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/QueryParameterLink#Strict().(). |
| 38 | Withscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/QueryParameterLink#With().("clear", "true"). |
| 39 | Withscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/QueryParameterLink#With().("domains", "com"). |
| 40 | Withscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/QueryParameterLink#With().("token", "secret"). |
| 41 | Withscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/QueryParameterLink#With().("txt", "")). |
| 42 | Buildscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/Builder#Build().(t) |
| 43 | |
| 44 | err := client.RemoveTXTRecordscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/Client#RemoveTXTRecord().(t.Contextscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Context().(), "example.com") |
| 45 | 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) |
| 46 | } |
| 47 | |
| 48 | func Test_getMainDomainscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/Test_getMainDomain().(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#) { |
| 49 | testCases := []struct { |
| 50 | desc string |
| 51 | domain string |
| 52 | expected string |
| 53 | }{ |
| 54 | { |
| 55 | desc: "empty", |
| 56 | domain: "", |
| 57 | expected: "", |
| 58 | }, |
| 59 | { |
| 60 | desc: "missing sub domain", |
| 61 | domain: "duckdns.org", |
| 62 | expected: "", |
| 63 | }, |
| 64 | { |
| 65 | desc: "explicit domain: sub domain", |
| 66 | domain: "_acme-challenge.sub.duckdns.org", |
| 67 | expected: "sub.duckdns.org", |
| 68 | }, |
| 69 | { |
| 70 | desc: "explicit domain: subsub domain", |
| 71 | domain: "_acme-challenge.my.sub.duckdns.org", |
| 72 | expected: "sub.duckdns.org", |
| 73 | }, |
| 74 | { |
| 75 | desc: "explicit domain: subsubsub domain", |
| 76 | domain: "_acme-challenge.my.sub.sub.duckdns.org", |
| 77 | expected: "sub.duckdns.org", |
| 78 | }, |
| 79 | { |
| 80 | desc: "only subname: sub domain", |
| 81 | domain: "_acme-challenge.sub", |
| 82 | expected: "sub", |
| 83 | }, |
| 84 | { |
| 85 | desc: "only subname: subsub domain", |
| 86 | domain: "_acme-challenge.my.sub", |
| 87 | expected: "sub", |
| 88 | }, |
| 89 | { |
| 90 | desc: "only subname: subsubsub domain", |
| 91 | domain: "_acme-challenge.my.sub.sub", |
| 92 | expected: "sub", |
| 93 | }, |
| 94 | } |
| 95 | |
| 96 | for _, test := range testCases { |
| 97 | 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#) { |
| 98 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 99 | |
| 100 | wDomain := getMainDomainscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/duckdns/internal`/getMainDomain().(test.domain) |
| 101 | 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, wDomain) |
| 102 | }) |
| 103 | } |
| 104 | } |