forked from TrueCloudLab/lego
chore: update golangci-lint. (#782)
This commit is contained in:
parent
f05aa4c241
commit
6fdf45c474
15 changed files with 44 additions and 43 deletions
|
@ -41,6 +41,7 @@
|
||||||
"cyclomatic complexity (.+) of func `NewDNSChallengeProviderByName` is high (.+)", # providers/dns/dns_providers.go
|
"cyclomatic complexity (.+) of func `NewDNSChallengeProviderByName` is high (.+)", # providers/dns/dns_providers.go
|
||||||
"string `(lego\\.wtf|manhattan)` has (\\d+) occurrences, make it a constant", #providers/dns/gcloud/googlecloud_test.go
|
"string `(lego\\.wtf|manhattan)` has (\\d+) occurrences, make it a constant", #providers/dns/gcloud/googlecloud_test.go
|
||||||
|
|
||||||
|
"(dnsHelp|createRenew\\$1|createRun\\$1|run) - result 0 \\(error\\) is always nil", # cmd/
|
||||||
"`(tlsFeatureExtensionOID|ocspMustStapleFeature)` is a global variable", # certcrypto/crypto.go
|
"`(tlsFeatureExtensionOID|ocspMustStapleFeature)` is a global variable", # certcrypto/crypto.go
|
||||||
"`(defaultNameservers|recursiveNameservers|dnsTimeout|fqdnToZone|muFqdnToZone)` is a global variable", # challenge/dns01/nameserver.go
|
"`(defaultNameservers|recursiveNameservers|dnsTimeout|fqdnToZone|muFqdnToZone)` is a global variable", # challenge/dns01/nameserver.go
|
||||||
"`idPeAcmeIdentifierV1` is a global variable", # challenge/tlsalpn01/tls_alpn_challenge.go
|
"`idPeAcmeIdentifierV1` is a global variable", # challenge/tlsalpn01/tls_alpn_challenge.go
|
||||||
|
|
|
@ -30,7 +30,7 @@ before_install:
|
||||||
- go get -u github.com/letsencrypt/pebble/...
|
- go get -u github.com/letsencrypt/pebble/...
|
||||||
|
|
||||||
# Install linters and misspell
|
# Install linters and misspell
|
||||||
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.12.5
|
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.13.2
|
||||||
- golangci-lint --version
|
- golangci-lint --version
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
|
|
@ -77,7 +77,7 @@ func TestCertificateService_Get_issuerRelUp(t *testing.T) {
|
||||||
mux, apiURL, tearDown := tester.SetupFakeAPI()
|
mux, apiURL, tearDown := tester.SetupFakeAPI()
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
mux.HandleFunc("/certificate", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/certificate", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.Header().Set("Link", "<"+apiURL+`/issuer>; rel="up"`)
|
w.Header().Set("Link", "<"+apiURL+`/issuer>; rel="up"`)
|
||||||
_, err := w.Write([]byte(certResponseMock))
|
_, err := w.Write([]byte(certResponseMock))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -85,7 +85,7 @@ func TestCertificateService_Get_issuerRelUp(t *testing.T) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc("/issuer", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/issuer", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
p, _ := pem.Decode([]byte(issuerMock))
|
p, _ := pem.Decode([]byte(issuerMock))
|
||||||
_, err := w.Write(p.Bytes)
|
_, err := w.Write(p.Bytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -109,7 +109,7 @@ func TestCertificateService_Get_embeddedIssuer(t *testing.T) {
|
||||||
mux, apiURL, tearDown := tester.SetupFakeAPI()
|
mux, apiURL, tearDown := tester.SetupFakeAPI()
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
mux.HandleFunc("/certificate", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/certificate", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := w.Write([]byte(certResponseMock))
|
_, err := w.Write([]byte(certResponseMock))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNotHoldingLockWhileMakingHTTPRequests(t *testing.T) {
|
func TestNotHoldingLockWhileMakingHTTPRequests(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
time.Sleep(250 * time.Millisecond)
|
time.Sleep(250 * time.Millisecond)
|
||||||
w.Header().Add("Replay-Nonce", "12345")
|
w.Header().Add("Replay-Nonce", "12345")
|
||||||
w.Header().Add("Retry-After", "0")
|
w.Header().Add("Retry-After", "0")
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNotHoldingLockWhileMakingHTTPRequests(t *testing.T) {
|
func TestNotHoldingLockWhileMakingHTTPRequests(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
time.Sleep(250 * time.Millisecond)
|
time.Sleep(250 * time.Millisecond)
|
||||||
w.Header().Add("Replay-Nonce", "12345")
|
w.Header().Add("Replay-Nonce", "12345")
|
||||||
w.Header().Add("Retry-After", "0")
|
w.Header().Add("Retry-After", "0")
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
func TestDo_UserAgentOnAllHTTPMethod(t *testing.T) {
|
func TestDo_UserAgentOnAllHTTPMethod(t *testing.T) {
|
||||||
var ua, method string
|
var ua, method string
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
|
||||||
ua = r.Header.Get("User-Agent")
|
ua = r.Header.Get("User-Agent")
|
||||||
method = r.Method
|
method = r.Method
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -80,7 +80,7 @@ func Test_checkResponse(t *testing.T) {
|
||||||
mux, apiURL, tearDown := tester.SetupFakeAPI()
|
mux, apiURL, tearDown := tester.SetupFakeAPI()
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
mux.HandleFunc("/certificate", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/certificate", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := w.Write([]byte(certResponseMock))
|
_, err := w.Write([]byte(certResponseMock))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
@ -119,7 +119,7 @@ func Test_checkResponse_issuerRelUp(t *testing.T) {
|
||||||
mux, apiURL, tearDown := tester.SetupFakeAPI()
|
mux, apiURL, tearDown := tester.SetupFakeAPI()
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
mux.HandleFunc("/certificate", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/certificate", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.Header().Set("Link", "<"+apiURL+`/issuer>; rel="up"`)
|
w.Header().Set("Link", "<"+apiURL+`/issuer>; rel="up"`)
|
||||||
_, err := w.Write([]byte(certResponseMock))
|
_, err := w.Write([]byte(certResponseMock))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -127,7 +127,7 @@ func Test_checkResponse_issuerRelUp(t *testing.T) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc("/issuer", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/issuer", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
p, _ := pem.Decode([]byte(issuerMock))
|
p, _ := pem.Decode([]byte(issuerMock))
|
||||||
_, err := w.Write(p.Bytes)
|
_, err := w.Write(p.Bytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -167,7 +167,7 @@ func Test_checkResponse_embeddedIssuer(t *testing.T) {
|
||||||
mux, apiURL, tearDown := tester.SetupFakeAPI()
|
mux, apiURL, tearDown := tester.SetupFakeAPI()
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
mux.HandleFunc("/certificate", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/certificate", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := w.Write([]byte(certResponseMock))
|
_, err := w.Write([]byte(certResponseMock))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
|
|
@ -111,7 +111,7 @@ func TestNewDNSProviderConfig(t *testing.T) {
|
||||||
tenantID: "C",
|
tenantID: "C",
|
||||||
subscriptionID: "",
|
subscriptionID: "",
|
||||||
resourceGroup: "",
|
resourceGroup: "",
|
||||||
handler: func(w http.ResponseWriter, r *http.Request) {
|
handler: func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := w.Write([]byte("foo"))
|
_, err := w.Write([]byte("foo"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
|
|
@ -184,13 +184,13 @@ func TestClient_Login_errors(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
desc: "HTTP error",
|
desc: "HTTP error",
|
||||||
handler: func(rw http.ResponseWriter, req *http.Request) {
|
handler: func(rw http.ResponseWriter, _ *http.Request) {
|
||||||
http.Error(rw, "error message", http.StatusInternalServerError)
|
http.Error(rw, "error message", http.StatusInternalServerError)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "API error",
|
desc: "API error",
|
||||||
handler: func(rw http.ResponseWriter, req *http.Request) {
|
handler: func(rw http.ResponseWriter, _ *http.Request) {
|
||||||
response := `
|
response := `
|
||||||
{
|
{
|
||||||
"serverrequestid":"YxTr4EzdbJ101T211zR4yzUEMVE",
|
"serverrequestid":"YxTr4EzdbJ101T211zR4yzUEMVE",
|
||||||
|
@ -210,7 +210,7 @@ func TestClient_Login_errors(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "responsedata marshaling error",
|
desc: "responsedata marshaling error",
|
||||||
handler: func(rw http.ResponseWriter, req *http.Request) {
|
handler: func(rw http.ResponseWriter, _ *http.Request) {
|
||||||
response := `
|
response := `
|
||||||
{
|
{
|
||||||
"serverrequestid": "srv-request-id",
|
"serverrequestid": "srv-request-id",
|
||||||
|
@ -289,13 +289,13 @@ func TestClient_Logout_errors(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
desc: "HTTP error",
|
desc: "HTTP error",
|
||||||
handler: func(rw http.ResponseWriter, req *http.Request) {
|
handler: func(rw http.ResponseWriter, _ *http.Request) {
|
||||||
http.Error(rw, "error message", http.StatusInternalServerError)
|
http.Error(rw, "error message", http.StatusInternalServerError)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "API error",
|
desc: "API error",
|
||||||
handler: func(rw http.ResponseWriter, req *http.Request) {
|
handler: func(rw http.ResponseWriter, _ *http.Request) {
|
||||||
response := `
|
response := `
|
||||||
{
|
{
|
||||||
"serverrequestid":"YxTr4EzdbJ101T211zR4yzUEMVE",
|
"serverrequestid":"YxTr4EzdbJ101T211zR4yzUEMVE",
|
||||||
|
@ -417,13 +417,13 @@ func TestClient_GetDNSRecords_errors(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
desc: "HTTP error",
|
desc: "HTTP error",
|
||||||
handler: func(rw http.ResponseWriter, req *http.Request) {
|
handler: func(rw http.ResponseWriter, _ *http.Request) {
|
||||||
http.Error(rw, "error message", http.StatusInternalServerError)
|
http.Error(rw, "error message", http.StatusInternalServerError)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "API error",
|
desc: "API error",
|
||||||
handler: func(rw http.ResponseWriter, req *http.Request) {
|
handler: func(rw http.ResponseWriter, _ *http.Request) {
|
||||||
response := `
|
response := `
|
||||||
{
|
{
|
||||||
"serverrequestid":"YxTr4EzdbJ101T211zR4yzUEMVE",
|
"serverrequestid":"YxTr4EzdbJ101T211zR4yzUEMVE",
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func runTestServer(responseBody string, statusCode int) *httptest.Server {
|
func runTestServer(responseBody string, statusCode int) *httptest.Server {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.WriteHeader(statusCode)
|
w.WriteHeader(statusCode)
|
||||||
fmt.Fprintln(w, responseBody)
|
fmt.Fprintln(w, responseBody)
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (m *DNSServerMock) ShutdownServer() {
|
||||||
|
|
||||||
// HandleAuthSuccessfully Handle auth successfully
|
// HandleAuthSuccessfully Handle auth successfully
|
||||||
func (m *DNSServerMock) HandleAuthSuccessfully() {
|
func (m *DNSServerMock) HandleAuthSuccessfully() {
|
||||||
m.Mux.HandleFunc("/v3/auth/token", func(w http.ResponseWriter, r *http.Request) {
|
m.Mux.HandleFunc("/v3/auth/token", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.Header().Set("X-Subject-Token", fakeOTCToken)
|
w.Header().Set("X-Subject-Token", fakeOTCToken)
|
||||||
|
|
||||||
fmt.Fprintf(w, `{
|
fmt.Fprintf(w, `{
|
||||||
|
|
|
@ -135,7 +135,7 @@ func identityHandler(dnsEndpoint string) http.Handler {
|
||||||
|
|
||||||
resp := strings.Replace(identityResponseMock, "https://dns.api.rackspacecloud.com/v1.0/123456", dnsEndpoint, 1)
|
resp := strings.Replace(identityResponseMock, "https://dns.api.rackspacecloud.com/v1.0/123456", dnsEndpoint, 1)
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, resp)
|
fmt.Fprint(w, resp)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ func dnsHandler() *http.ServeMux {
|
||||||
mux.HandleFunc("/123456/domains", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/123456/domains", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.Query().Get("name") == "example.com" {
|
if r.URL.Query().Get("name") == "example.com" {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, zoneDetailsMock)
|
fmt.Fprint(w, zoneDetailsMock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
@ -168,12 +168,12 @@ func dnsHandler() *http.ServeMux {
|
||||||
}
|
}
|
||||||
|
|
||||||
w.WriteHeader(http.StatusAccepted)
|
w.WriteHeader(http.StatusAccepted)
|
||||||
fmt.Fprintf(w, recordResponseMock)
|
fmt.Fprint(w, recordResponseMock)
|
||||||
// Used by `findTxtRecord()` finding `record.ID` "?type=TXT&name=_acme-challenge.example.com"
|
// Used by `findTxtRecord()` finding `record.ID` "?type=TXT&name=_acme-challenge.example.com"
|
||||||
case http.MethodGet:
|
case http.MethodGet:
|
||||||
if r.URL.Query().Get("type") == "TXT" && r.URL.Query().Get("name") == "_acme-challenge.example.com" {
|
if r.URL.Query().Get("type") == "TXT" && r.URL.Query().Get("name") == "_acme-challenge.example.com" {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, recordDetailsMock)
|
fmt.Fprint(w, recordDetailsMock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
@ -182,7 +182,7 @@ func dnsHandler() *http.ServeMux {
|
||||||
case http.MethodDelete:
|
case http.MethodDelete:
|
||||||
if r.URL.Query().Get("id") == "TXT-654321" {
|
if r.URL.Query().Get("id") == "TXT-654321" {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, recordDeleteMock)
|
fmt.Fprint(w, recordDeleteMock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
|
|
@ -157,7 +157,7 @@ func TestDNSProvider_getZoneRecords(t *testing.T) {
|
||||||
provider, mux, tearDown := setupMockAPITest()
|
provider, mux, tearDown := setupMockAPITest()
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
mux.HandleFunc("/STACK_ID/zones/A/records", func(w http.ResponseWriter, req *http.Request) {
|
mux.HandleFunc("/STACK_ID/zones/A/records", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
content := `
|
content := `
|
||||||
{
|
{
|
||||||
"records": [
|
"records": [
|
||||||
|
@ -188,7 +188,7 @@ func TestDNSProvider_getZoneRecords_apiError(t *testing.T) {
|
||||||
provider, mux, tearDown := setupMockAPITest()
|
provider, mux, tearDown := setupMockAPITest()
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
mux.HandleFunc("/STACK_ID/zones/A/records", func(w http.ResponseWriter, req *http.Request) {
|
mux.HandleFunc("/STACK_ID/zones/A/records", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
content := `
|
content := `
|
||||||
{
|
{
|
||||||
"code": 401,
|
"code": 401,
|
||||||
|
@ -213,7 +213,7 @@ func TestDNSProvider_getZones(t *testing.T) {
|
||||||
provider, mux, tearDown := setupMockAPITest()
|
provider, mux, tearDown := setupMockAPITest()
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
mux.HandleFunc("/STACK_ID/zones", func(w http.ResponseWriter, req *http.Request) {
|
mux.HandleFunc("/STACK_ID/zones", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
content := `
|
content := `
|
||||||
{
|
{
|
||||||
"pageInfo": {
|
"pageInfo": {
|
||||||
|
|
|
@ -145,7 +145,7 @@ func muxSuccess() *http.ServeMux {
|
||||||
mux.HandleFunc("/1.0/token", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/1.0/token", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == http.MethodPost {
|
if r.Method == http.MethodPost {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, tokenResponseMock)
|
fmt.Fprint(w, tokenResponseMock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
@ -154,7 +154,7 @@ func muxSuccess() *http.ServeMux {
|
||||||
mux.HandleFunc("/1.0/domains", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/1.0/domains", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.Query().Get("search") == "example.com" {
|
if r.URL.Query().Get("search") == "example.com" {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, domainsResponseMock)
|
fmt.Fprint(w, domainsResponseMock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
@ -165,14 +165,14 @@ func muxSuccess() *http.ServeMux {
|
||||||
case http.MethodGet:
|
case http.MethodGet:
|
||||||
if r.URL.Query().Get("domain_id") == "1" {
|
if r.URL.Query().Get("domain_id") == "1" {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, recordsResponseMock)
|
fmt.Fprint(w, recordsResponseMock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
case http.MethodPost:
|
case http.MethodPost:
|
||||||
w.WriteHeader(http.StatusCreated)
|
w.WriteHeader(http.StatusCreated)
|
||||||
fmt.Fprintf(w, recordCreatedResponseMock)
|
fmt.Fprint(w, recordCreatedResponseMock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
@ -181,7 +181,7 @@ func muxSuccess() *http.ServeMux {
|
||||||
mux.HandleFunc("/1.0/records/3", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/1.0/records/3", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == http.MethodDelete {
|
if r.Method == http.MethodDelete {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, recordDeletedResponseMock)
|
fmt.Fprint(w, recordDeletedResponseMock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
@ -201,13 +201,13 @@ func muxFailToFindZone() *http.ServeMux {
|
||||||
mux.HandleFunc("/1.0/token", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/1.0/token", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == http.MethodPost {
|
if r.Method == http.MethodPost {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, tokenResponseMock)
|
fmt.Fprint(w, tokenResponseMock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc("/1.0/domains", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/1.0/domains", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ func muxFailToCreateTXT() *http.ServeMux {
|
||||||
mux.HandleFunc("/1.0/token", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/1.0/token", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == http.MethodPost {
|
if r.Method == http.MethodPost {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, tokenResponseMock)
|
fmt.Fprint(w, tokenResponseMock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
@ -229,7 +229,7 @@ func muxFailToCreateTXT() *http.ServeMux {
|
||||||
mux.HandleFunc("/1.0/domains", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/1.0/domains", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.Query().Get("search") == testDomain {
|
if r.URL.Query().Get("search") == testDomain {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, domainsResponseMock)
|
fmt.Fprint(w, domainsResponseMock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
@ -240,7 +240,7 @@ func muxFailToCreateTXT() *http.ServeMux {
|
||||||
case http.MethodGet:
|
case http.MethodGet:
|
||||||
if r.URL.Query().Get("domain_id") == "1" {
|
if r.URL.Query().Get("domain_id") == "1" {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, recordsResponseMock)
|
fmt.Fprint(w, recordsResponseMock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
@ -261,7 +261,7 @@ func muxFailToGetRecordID() *http.ServeMux {
|
||||||
mux.HandleFunc("/1.0/token", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/1.0/token", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == http.MethodPost {
|
if r.Method == http.MethodPost {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, tokenResponseMock)
|
fmt.Fprint(w, tokenResponseMock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
@ -270,7 +270,7 @@ func muxFailToGetRecordID() *http.ServeMux {
|
||||||
mux.HandleFunc("/1.0/domains", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/1.0/domains", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.Query().Get("search") == testDomain {
|
if r.URL.Query().Get("search") == testDomain {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, domainsResponseMock)
|
fmt.Fprint(w, domainsResponseMock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
|
|
@ -17,7 +17,7 @@ func TestRegistrar_ResolveAccountByKey(t *testing.T) {
|
||||||
mux, apiURL, tearDown := tester.SetupFakeAPI()
|
mux, apiURL, tearDown := tester.SetupFakeAPI()
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
mux.HandleFunc("/account", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/account", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.Header().Set("Location", apiURL+"/account_recovery")
|
w.Header().Set("Location", apiURL+"/account_recovery")
|
||||||
_, err := w.Write([]byte("{}"))
|
_, err := w.Write([]byte("{}"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -25,7 +25,7 @@ func TestRegistrar_ResolveAccountByKey(t *testing.T) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc("/account_recovery", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/account_recovery", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
err := tester.WriteJSONResponse(w, acme.Account{
|
err := tester.WriteJSONResponse(w, acme.Account{
|
||||||
Status: "valid",
|
Status: "valid",
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue