diff --git a/registry/mapper/mapper.go b/registry/mapper/mapper.go index 594348b4d6..7c8af9c455 100644 --- a/registry/mapper/mapper.go +++ b/registry/mapper/mapper.go @@ -36,6 +36,7 @@ var ( endpoint.RecordTypePTR, endpoint.RecordTypeSRV, endpoint.RecordTypeNAPTR, + endpoint.RecordTypeTXT, } ) diff --git a/registry/mapper/mapper_test.go b/registry/mapper/mapper_test.go index 9e17866bff..83a29c8df1 100644 --- a/registry/mapper/mapper_test.go +++ b/registry/mapper/mapper_test.go @@ -167,8 +167,8 @@ func TestAffixNameMapper_ToEndpointName(t *testing.T) { name: "suffix with txt record", mapper: NewAffixNameMapper("", "", ""), input: "txt-foo.example.com", - wantEndpointName: "txt-foo.example.com", - wantRecordType: "", + wantEndpointName: "foo.example.com", + wantRecordType: endpoint.RecordTypeTXT, }, { name: "both prefix and suffix set returns empty", @@ -264,6 +264,13 @@ func TestAffixNameMapper_ToTXTName(t *testing.T) { recordType: endpoint.RecordTypeNAPTR, wantTXTName: "naptr-foo.example.com", }, + { + name: "prefix with TXT record type in affix", + mapper: NewAffixNameMapper("%{record_type}-", "", ""), + dns: "foo.example.com", + recordType: endpoint.RecordTypeTXT, + wantTXTName: "txt-foo.example.com", + }, { name: "suffix with A record type in affix", mapper: NewAffixNameMapper("", "-%{record_type}", ""), @@ -278,6 +285,13 @@ func TestAffixNameMapper_ToTXTName(t *testing.T) { recordType: endpoint.RecordTypeCNAME, wantTXTName: "foo-cname.example.com", }, + { + name: "suffix with TXT record type in affix", + mapper: NewAffixNameMapper("", "-%{record_type}", ""), + dns: "foo.example.com", + recordType: endpoint.RecordTypeTXT, + wantTXTName: "foo-txt.example.com", + }, { name: "wildcard replacement with A record", mapper: NewAffixNameMapper("txt-", "", "wild"), @@ -292,6 +306,13 @@ func TestAffixNameMapper_ToTXTName(t *testing.T) { recordType: endpoint.RecordTypeMX, wantTXTName: "txt-mx-wild.example.com", }, + { + name: "wildcard replacement with TXT record", + mapper: NewAffixNameMapper("txt-", "", "wild"), + dns: "*.example.com", + recordType: endpoint.RecordTypeTXT, + wantTXTName: "txt-txt-wild.example.com", + }, { name: "no affix with A record", mapper: NewAffixNameMapper("", "", ""), @@ -348,6 +369,13 @@ func TestAffixNameMapper_ToTXTName(t *testing.T) { recordType: endpoint.RecordTypeNAPTR, wantTXTName: "naptr-foo.example.com", }, + { + name: "no affix with TXT record", + mapper: NewAffixNameMapper("", "", ""), + dns: "foo.example.com", + recordType: endpoint.RecordTypeTXT, + wantTXTName: "txt-foo.example.com", + }, } for _, tt := range tests {