diff --git a/service.go b/service.go index 5c9104d..2ffb6fd 100644 --- a/service.go +++ b/service.go @@ -188,7 +188,7 @@ func NewService(options ServiceOptions) *Service { } hsdClient := options.HSDClient - if hsdClient == nil && strings.TrimSpace(options.HSDURL) != "" { + if hsdClient == nil { hsdPassword := options.HSDPassword if hsdPassword == "" { hsdPassword = options.HSDApiKey diff --git a/service_test.go b/service_test.go index 5845e30..06f113e 100644 --- a/service_test.go +++ b/service_test.go @@ -1675,6 +1675,20 @@ func TestServiceDiscoverAliasesReturnsNilWithoutDiscovererOrHSDClient(t *testing } } +func TestServiceCreatesDefaultHSDClientWhenURLNotConfigured(t *testing.T) { + service := NewService(ServiceOptions{ + ChainAliasDiscoverer: func(_ context.Context) ([]string, error) { + return []string{"gateway.charon.lthn"}, nil + }, + }) + if service.hsdClient == nil { + t.Fatalf("expected default HSD client to be created when HSDURL is not configured") + } + if service.hsdClient.baseURL != "http://127.0.0.1:14037" { + t.Fatalf("expected default HSD base URL, got %q", service.hsdClient.baseURL) + } +} + func TestServiceServeResolvesAAndAAAARecords(t *testing.T) { service := NewService(ServiceOptions{ Records: map[string]NameRecords{