From 55ad8ed61c28f500161ead89f2b52d4d89fdba67 Mon Sep 17 00:00:00 2001 From: Barnaby Gray Date: Sat, 10 Sep 2016 09:11:07 +0100 Subject: [PATCH] Group alias records by target type. Fixes #195. --- commands.go | 5 +++++ internal/features/import.feature | 5 +++++ tests/alias_multiple_types.txt | 4 ++++ 3 files changed, 14 insertions(+) create mode 100644 tests/alias_multiple_types.txt diff --git a/commands.go b/commands.go index ded41fdc..f27d64c9 100644 --- a/commands.go +++ b/commands.go @@ -211,6 +211,11 @@ func groupRecords(records []dns.RR) map[Key][]dns.RR { if aws, ok := record.(*AWSRR); ok { identifier = aws.Identifier } + if alias, ok := record.(*dns.PrivateRR); ok { + // issue #195: alias records need to be keyed by the type of the alias too + rdata := alias.Data.(*ALIASRdata) + identifier += "@" + rdata.Type + } key := Key{record.Header().Name, record.Header().Rrtype, identifier} grouped[key] = append(grouped[key], record) } diff --git a/internal/features/import.feature b/internal/features/import.feature index 78147d8b..19ab3632 100644 --- a/internal/features/import.feature +++ b/internal/features/import.feature @@ -55,6 +55,11 @@ Feature: import When I run "cli53 import --file tests/alias.txt $domain" Then the domain "$domain" export matches file "tests/alias.txt" + Scenario: I can import a zone with an alias with multiple types + Given I have a domain "$domain" + When I run "cli53 import --file tests/alias_multiple_types.txt $domain" + Then the domain "$domain" export matches file "tests/alias_multiple_types.txt" + Scenario: I can import (replace) a zone Given I have a domain "$domain" When I run "cli53 import --file tests/replace1.txt $domain" diff --git a/tests/alias_multiple_types.txt b/tests/alias_multiple_types.txt new file mode 100644 index 00000000..f52bcd74 --- /dev/null +++ b/tests/alias_multiple_types.txt @@ -0,0 +1,4 @@ +www 86400 IN A 127.0.0.1 +www 86400 IN AAAA ::1 +alias 86400 AWS ALIAS A www $self false +alias 86400 AWS ALIAS AAAA www $self false