Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions registry/mapper/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
endpoint.RecordTypePTR,
endpoint.RecordTypeSRV,
endpoint.RecordTypeNAPTR,
endpoint.RecordTypeTXT,
}
)

Expand Down
32 changes: 30 additions & 2 deletions registry/mapper/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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}", ""),
Expand All @@ -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"),
Expand All @@ -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("", "", ""),
Expand Down Expand Up @@ -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 {
Expand Down