namecheap: fix panic. (#764)

This commit is contained in:
Ludovic Fernandez 2019-01-24 21:40:44 +01:00 committed by GitHub
parent 4f6d1077a2
commit 27f26ed3d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View file

@ -180,10 +180,12 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
// Find the challenge TXT record and remove it if found.
var found bool
for i, h := range records {
var newRecords []Record
for _, h := range records {
if h.Name == ch.key && h.Type == "TXT" {
records = append(records[:i], records[i+1:]...)
found = true
} else {
newRecords = append(newRecords, h)
}
}
@ -191,7 +193,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
return nil
}
err = d.setHosts(ch.sld, ch.tld, records)
err = d.setHosts(ch.sld, ch.tld, newRecords)
if err != nil {
return fmt.Errorf("namecheap: %v", err)
}

View file

@ -208,10 +208,10 @@ func mockServer(tc *testCase, t *testing.T) http.Handler {
case "namecheap.domains.dns.getHosts":
assertHdr(tc, t, &values)
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, tc.getHostsResponse)
fmt.Fprint(w, tc.getHostsResponse)
case "namecheap.domains.getTldList":
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, responseGetTlds)
fmt.Fprint(w, responseGetTlds)
default:
t.Errorf("Unexpected GET command: %s", cmd)
}