CI: don't double-count the nameservers

On macOS, `whois` returns _two_ results for the domain `sslip.io` from
two different whois servers:

- whois.nic.io
- whois.namecheap.com

This means that every nameservers is double-counted. To fix, we remove
the duplicates.

fixes:
```
     Failure/Error: expect(dig_nameservers.sort).to eq(whois_nameservers.sort)

       expected: ["ns-aws.nono.io.", "ns-aws.nono.io.", "ns-azure.nono.io.", "ns-azure.nono.io.", "ns-gce.nono.io.", "ns-gce.nono.io."]
            got: ["ns-aws.nono.io.", "ns-azure.nono.io.", "ns-gce.nono.io."]

       (compared using ==)
     # ./spec/check-dns_spec.rb:44:in `block (3 levels) in <top (required)>'
```
This commit is contained in:
Brian Cunnie
2020-12-01 09:22:24 -08:00
parent 06f1556699
commit 09249be0a0

View File

@@ -11,7 +11,7 @@ def get_whois_nameservers(domain)
soa = nil
whois_lines = whois_output.split(/\n+/)
nameserver_lines = whois_lines.select { |line| line =~ /^Name Server:/ }
nameservers = nameserver_lines.map { |line| line.split.last.downcase }
nameservers = nameserver_lines.map { |line| line.split.last.downcase }.uniq
# whois records don't have trail '.'; NS records do; add trailing '.'
nameservers.map { |ns| ns << '.' }
nameservers