From dbc1d3c70c5a655943fa2c16580fabf46eff2ba5 Mon Sep 17 00:00:00 2001 From: Brian Cunnie Date: Sat, 24 May 2025 07:51:03 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20Nameservers=20test:=20whois=20is?= =?UTF-8?q?=20a=20subset=20of=20NS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Slight tweak: I want every WHOIS nameserver to be reflected in the NS records, but I also want to allow for additional NS records. Specifically, I've paid the Google Cloud Platform (GCP) "Committed Use Discounts" for `ns-gce.sslip.io`, but it attracts *lots* of traffic, and that can easily incur $100+ in bandwidth charges per month. To tamp down on traffic, I don't include `ns-gce` in the whois nameservers, but I do include it in the NS records. But then my tests fail, so this commit tweaks the tests so that as long as the NS records are a superset of the whois records, I'm fine (previously they had to match). Fixes, when running `DOMAIN=sslip.io rspec --format documentation --color spec/`: ``` rspec './spec/check-dns_spec.rb[1:3]' # sslip.io nameserver ns-ovh.sslip.io.'s NS records match whois's ["ns-ovh.sslip.io.", "ns-hetzner.sslip.io.", "ns-do-sg.sslip.io."], `dig @ns-ovh.sslip.io. ns sslip.io +short` rspec './spec/check-dns_spec.rb[1:18]' # sslip.io nameserver ns-hetzner.sslip.io.'s NS records match whois's ["ns-ovh.sslip.io.", "ns-hetzner.sslip.io.", "ns-do-sg.sslip.io."], `dig @ns-hetzner.sslip.io. ns sslip.io +short` rspec './spec/check-dns_spec.rb[1:33]' # sslip.io nameserver ns-do-sg.sslip.io.'s NS records match whois's ["ns-ovh.sslip.io.", "ns-hetzner.sslip.io.", "ns-do-sg.sslip.io."], `dig @ns-do-sg.sslip.io. ns sslip.io +short` ``` --- spec/check-dns_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/check-dns_spec.rb b/spec/check-dns_spec.rb index 285a797..81c2fe9 100644 --- a/spec/check-dns_spec.rb +++ b/spec/check-dns_spec.rb @@ -39,10 +39,10 @@ describe domain do end whois_nameservers.each do |whois_nameserver| - it "nameserver #{whois_nameserver}'s NS records match whois's #{whois_nameservers}, " + + it "nameserver #{whois_nameserver}'s NS records include all whois nameservers #{whois_nameservers}, " + "`dig @#{whois_nameserver} ns #{domain} +short`" do dig_nameservers = `dig @#{whois_nameserver} ns #{domain} +short`.split(/\n+/) - expect(dig_nameservers.sort).to eq(whois_nameservers.sort) + expect(whois_nameservers - dig_nameservers).to be_empty end it "nameserver #{whois_nameserver}'s SOA record match" do