1
0
mirror of https://github.com/go-acme/lego.git synced 2025-11-29 08:56:53 +02:00

hostinger: fix Present (#2654)

This commit is contained in:
Ludovic Fernandez
2025-09-23 12:22:54 +02:00
committed by GitHub
parent ba156d5344
commit 95eb44ccbe
4 changed files with 65 additions and 2 deletions

View File

@@ -115,10 +115,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
for _, recordSet := range recordSets {
if recordSet.Name == subDomain && recordSet.Type == "TXT" {
recordSet.Records = append(recordSet.Records, internal.Record{Content: info.Value})
added = true
}
added = true
newRecordSet = append(newRecordSet, recordSet)
}

View File

@@ -1,6 +1,7 @@
package hostinger
import (
"net/http"
"net/http/httptest"
"net/url"
"testing"
@@ -126,6 +127,19 @@ func TestDNSProvider_Present(t *testing.T) {
require.NoError(t, err)
}
func TestDNSProvider_Present_empty(t *testing.T) {
provider := mockBuilder().
Route("GET /api/dns/v1/zones/example.com",
servermock.ResponseFromInternal("get_dns_records_empty.json")).
Route("PUT /api/dns/v1/zones/example.com",
servermock.ResponseFromInternal("update_dns_records.json"),
servermock.CheckRequestJSONBodyFromInternal("update_dns_records_empty-request.json")).
Build(t)
err := provider.Present("example.com", "", "123d==")
require.NoError(t, err)
}
func TestDNSProvider_CleanUp(t *testing.T) {
provider := mockBuilder().
Route("GET /api/dns/v1/zones/example.com",
@@ -139,6 +153,18 @@ func TestDNSProvider_CleanUp(t *testing.T) {
require.NoError(t, err)
}
func TestDNSProvider_CleanUp_empty(t *testing.T) {
provider := mockBuilder().
Route("GET /api/dns/v1/zones/example.com",
servermock.ResponseFromInternal("get_dns_records_empty.json")).
Route("PUT /api/dns/v1/zones/example.com",
servermock.Noop().WithStatusCode(http.StatusServiceUnavailable)).
Build(t)
err := provider.CleanUp("example.com", "", "123d==")
require.NoError(t, err)
}
func TestLivePresent(t *testing.T) {
if !envTest.IsLiveTest() {
t.Skip("skipping live test")

View File

@@ -0,0 +1,13 @@
[
{
"name": "_acme-challenge",
"records": [
{
"content": "example.com.",
"is_disabled": false
}
],
"ttl": 14400,
"type": "A"
}
]

View File

@@ -0,0 +1,25 @@
{
"overwrite": false,
"zone": [
{
"name": "_acme-challenge",
"records": [
{
"content": "example.com."
}
],
"ttl": 14400,
"type": "A"
},
{
"name": "_acme-challenge",
"records": [
{
"content": "ADw2sEd82DUgXcQ9hNBZThJs7zVJkR5v9JeSbAb9mZY"
}
],
"ttl": 120,
"type": "TXT"
}
]
}