corrige bug com registro txt e tradução

This commit is contained in:
2026-07-12 03:41:49 -03:00
parent 1901055e25
commit e629b829a3
9 changed files with 362 additions and 222 deletions

View File

@@ -18,6 +18,7 @@ func TestValidateRRSetAcceptsSupportedRecords(t *testing.T) {
{"SOA", "ns1.example.org. hostmaster.example.org. 2026010101 3600 600 604800 300"},
{"SRV", "10 20 443 service.example.org."},
{"TXT", `"v=spf1 -all"`},
{"TXT", `"v=DMARC1; p=reject; rua=mailto:postmaster@example.org; ruf=mailto:postmaster@example.org"`},
}
for _, tc := range cases {
@@ -56,6 +57,68 @@ func TestValidateRRSetRejectsInvalidRecords(t *testing.T) {
}
}
func TestValidateRRSetAcceptsUnderscoresInOwnerNames(t *testing.T) {
v := newTestValidator(t)
cases := []struct {
name string
recordType string
content string
wantName string
}{
{
name: "_dmarc.example.org",
recordType: "TXT",
content: `"v=DMARC1; p=reject; rua=mailto:postmaster@example.org; ruf=mailto:postmaster@example.org"`,
wantName: "_dmarc.example.org.",
},
{
name: "_sip._tcp.example.org",
recordType: "SRV",
content: "10 20 5060 sip.example.org.",
wantName: "_sip._tcp.example.org.",
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
rrset, err := v.ValidateRRSet(tc.name, tc.recordType, 300, []string{tc.content})
if err != nil {
t.Fatalf("ValidateRRSet returned error: %v", err)
}
if rrset.Name != tc.wantName {
t.Fatalf("unexpected normalized name: %q", rrset.Name)
}
if rrset.Records[0].Content != tc.content {
t.Fatalf("unexpected content: %q", rrset.Records[0].Content)
}
})
}
}
func TestValidateRRSetRejectsUnderscoresInHostnameTargets(t *testing.T) {
v := newTestValidator(t)
cases := []struct {
recordType string
content string
}{
{"CNAME", "_target.example.org."},
{"MX", "10 _mail.example.org."},
{"NS", "_ns.example.org."},
{"SOA", "_ns.example.org. hostmaster.example.org. 2026010101 3600 600 604800 300"},
{"SRV", "10 20 5060 _sip.example.org."},
}
for _, tc := range cases {
t.Run(tc.recordType, func(t *testing.T) {
if _, err := v.ValidateRRSet("www.example.org.", tc.recordType, 300, []string{tc.content}); err == nil {
t.Fatal("expected validation error")
}
})
}
}
func TestValidateRRSetRequiresTTL(t *testing.T) {
v := newTestValidator(t)