Debian Codegraph @

providers/dns/wedos/internal/client_test.go

raw symbols SCIP
1 package internalscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/"
5 "net/httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/"
6 "net/http/httptestscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/"
7 "regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/"
8 "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/"
9
10 "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`/"
11 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/"
12 "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/"
13 )
14
15 func mockBuilderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/mockBuilder().() *servermockscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/.Builderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/Builder#[*Clientscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/Client#] {
16 return 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/wedos/internal`/Client#](
17 func(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/wedos/internal`/Client#, error) {
18 client := NewClientscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/NewClient().("user", "secret")
19 client.baseURLscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/Client#baseURL. = server.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#URL.
20 client.HTTPClientscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/Client#HTTPClient. = server.Clientscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#Client().()
21
22 return client, nil
23 },
24 servermockscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/.CheckHeaderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/CheckHeader().().
25 WithContentTypeFromURLEncodedscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/HeaderLink#WithContentTypeFromURLEncoded().())
26 }
27
28 func TestClient_GetRecordsscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/TestClient_GetRecords().(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#) {
29 client := mockBuilderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/mockBuilder().().
30 Routescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/Builder#Route().("POST /",
31 servermockscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/.ResponseFromFixturescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/ResponseFromFixture().(commandDNSRowsListscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/commandDNSRowsList.+".json"),
32 checkFormRequestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/checkFormRequest().(`{"request":{"user":"user","auth":"xxx","command":"dns-rows-list","data":{"domain":"example.com"}}}`)).
33 Buildscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/Builder#Build().(t)
34
35 records, err := client.GetRecordsscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/Client#GetRecords().(t.Contextscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Context().(), "example.com.")
36 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)
37
38 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Lenscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Len().(t, records, 4)
39
40 expected := []DNSRowscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#{
41 {
42 IDscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#ID.: "911",
43 TTLscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#TTL.: "1800",
44 Typescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#Type.: "A",
45 Datascip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#Data.: "1.2.3.4",
46 },
47 {
48 IDscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#ID.: "913",
49 TTLscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#TTL.: "1800",
50 Typescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#Type.: "MX",
51 Datascip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#Data.: "1 mail1.wedos.net",
52 },
53 {
54 IDscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#ID.: "914",
55 TTLscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#TTL.: "1800",
56 Typescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#Type.: "MX",
57 Datascip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#Data.: "10 mailbackup.wedos.net",
58 },
59 {
60 IDscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#ID.: "912",
61 Namescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#Name.: "*",
62 TTLscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#TTL.: "1800",
63 Typescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#Type.: "A",
64 Datascip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#Data.: "1.2.3.4",
65 },
66 }
67
68 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, expected, records)
69 }
70
71 func TestClient_AddRecordscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/TestClient_AddRecord().(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#) {
72 client := mockBuilderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/mockBuilder().().
73 Routescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/Builder#Route().("POST /",
74 servermockscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/.ResponseFromFixturescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/ResponseFromFixture().(commandDNSRowAddscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/commandDNSRowAdd.+".json"),
75 checkFormRequestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/checkFormRequest().(`{"request":{"user":"user","auth":"xxx","command":"dns-row-add","data":{"domain":"example.com","name":"foo","ttl":1800,"type":"TXT","rdata":"foobar"}}}`)).
76 Buildscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/Builder#Build().(t)
77
78 record := DNSRowscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#{
79 IDscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#ID.: "",
80 Namescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#Name.: "foo",
81 TTLscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#TTL.: "1800",
82 Typescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#Type.: "TXT",
83 Datascip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#Data.: "foobar",
84 }
85
86 err := client.AddRecordscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/Client#AddRecord().(t.Contextscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Context().(), "example.com.", record)
87 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)
88 }
89
90 func TestClient_AddRecord_updatescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/TestClient_AddRecord_update().(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#) {
91 client := mockBuilderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/mockBuilder().().
92 Routescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/Builder#Route().("POST /",
93 servermockscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/.ResponseFromFixturescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/ResponseFromFixture().(commandDNSRowUpdatescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/commandDNSRowUpdate.+".json"),
94 checkFormRequestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/checkFormRequest().(`{"request":{"user":"user","auth":"xxx","command":"dns-row-update","data":{"row_id":"1","domain":"example.com","ttl":1800,"type":"TXT","rdata":"foobar"}}}`)).
95 Buildscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/Builder#Build().(t)
96
97 record := DNSRowscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#{
98 IDscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#ID.: "1",
99 Namescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#Name.: "foo",
100 TTLscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#TTL.: "1800",
101 Typescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#Type.: "TXT",
102 Datascip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/DNSRow#Data.: "foobar",
103 }
104
105 err := client.AddRecordscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/Client#AddRecord().(t.Contextscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Context().(), "example.com.", record)
106 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)
107 }
108
109 func TestClient_DeleteRecordscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/TestClient_DeleteRecord().(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 client := mockBuilderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/mockBuilder().().
111 Routescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/Builder#Route().("POST /",
112 servermockscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/.ResponseFromFixturescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/ResponseFromFixture().(commandDNSRowDeletescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/commandDNSRowDelete.+".json"),
113 checkFormRequestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/checkFormRequest().(`{"request":{"user":"user","auth":"xxx","command":"dns-row-delete","data":{"row_id":"1","domain":"example.com","rdata":""}}}`)).
114 Buildscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/Builder#Build().(t)
115
116 err := client.DeleteRecordscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/Client#DeleteRecord().(t.Contextscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Context().(), "example.com.", "1")
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 }
119
120 func TestClient_Commitscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/TestClient_Commit().(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#) {
121 client := mockBuilderscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/mockBuilder().().
122 Routescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/Builder#Route().("POST /",
123 servermockscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/.ResponseFromFixturescip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/ResponseFromFixture().(commandDNSDomainCommitscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/commandDNSDomainCommit.+".json"),
124 checkFormRequestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/checkFormRequest().(`{"request":{"user":"user","auth":"xxx","command":"dns-domain-commit","data":{"name":"example.com"}}}`)).
125 Buildscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/Builder#Build().(t)
126
127 err := client.Commitscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/Client#Commit().(t.Contextscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Context().(), "example.com.")
128 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)
129 }
130
131 func checkFormRequestscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/providers/dns/wedos/internal`/checkFormRequest().(data string) servermockscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/.LinkFuncscip-go gomod github.com/go-acme/lego/v4 . `github.com/go-acme/lego/v4/platform/tester/servermock`/LinkFunc# {
132 return func(next httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Handlerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Handler#) httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Handlerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Handler# {
133 return httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.HandlerFuncscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/HandlerFunc#(func(rw httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#, req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) {
134 err := req.ParseFormscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#ParseForm().()
135 if err != nil {
136 httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Errorscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Error().(rw, err.Error(), httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.StatusBadRequestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/StatusBadRequest.)
137 return
138 }
139
140 form := regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.25.0 regexp/MustCompile().(`"auth":"\w+",`).
141 ReplaceAllStringscip-go gomod github.com/golang/go/src go1.25.0 regexp/Regexp#ReplaceAllString().(req.PostFormscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#PostForm..Getscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/Values#Get().("request"), `"auth":"xxx",`)
142
143 if form != data {
144 httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Errorscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Error().(rw, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("invalid form data: %s", req.PostFormscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#PostForm..Getscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/Values#Get().("request")), httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.StatusBadRequestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/StatusBadRequest.)
145 return
146 }
147
148 next.ServeHTTPscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Handler#ServeHTTP().(rw, req)
149 })
150 }
151 }