Add creation of csync inputs based on name_puny

This commit is contained in:
Alex Sherman 2021-05-25 13:28:16 +05:00
parent 82c048b316
commit d887bcd734
3 changed files with 39 additions and 4 deletions

View file

@ -1,5 +1,6 @@
shop_ns1:
hostname: ns1.bestnames.test
hostname_puny: ns1.bestnames.test
ipv4:
- 192.0.2.1
ipv6:
@ -8,6 +9,7 @@ shop_ns1:
shop_ns2:
hostname: ns2.bestnames.test
hostname_puny: ns2.bestnames.test
ipv4:
- 192.0.2.2
ipv6:
@ -16,6 +18,7 @@ shop_ns2:
airport_ns1:
hostname: ns1.bestnames.test
hostname_puny: ns1.bestnames.test
ipv4:
- 192.0.2.2
ipv6:
@ -24,6 +27,7 @@ airport_ns1:
airport_ns2:
hostname: ns2.bestnames.test
hostname_puny: ns2.bestnames.test
ipv4:
- 192.0.2.0
- 192.0.2.3
@ -34,4 +38,5 @@ airport_ns2:
metro_ns1:
hostname: ns1.bestnames.test
hostname_puny: ns1.bestnames.test
domain: metro

View file

@ -6,6 +6,10 @@ class CsyncJobTest < ActiveSupport::TestCase
setup do
@dnskey = dnskeys(:one)
@domain = domains(:shop)
dirname = File.dirname(ENV['cdns_scanner_input_file'])
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
FileUtils.touch(ENV['cdns_scanner_input_file']) unless File.exists?(ENV['cdns_scanner_input_file'])
end
def test_generates_input_file_for_cdnskey_scanner
@ -19,6 +23,21 @@ class CsyncJobTest < ActiveSupport::TestCase
assert_equal expected_contents, IO.read(ENV['cdns_scanner_input_file'])
end
def test_generates_input_file_from_name_puny
@domain.update(name: 'pööriöö.ee', name_puny: 'xn--pri-snaaca.ee')
@domain.save(validate: false)
@nameserver = @domain.nameservers.first
@nameserver.update(hostname: 'täpiline.ee', hostname_puny: 'xn--theke1-bua.ee')
@domain.reload
@dnskey.update(domain: @domain)
expected_contents = "[secure]\nns2.bestnames.test #{@domain.name_puny}\n#{@nameserver.hostname_puny} #{@domain.name_puny}\n" \
"[insecure]\nns2.bestnames.test airport.test\nns1.bestnames.test airport.test metro.test\n"
CsyncJob.perform_now(generate: true)
assert_equal expected_contents, IO.read(ENV['cdns_scanner_input_file'])
end
def test_creates_csync_record_when_new_cdnskey_discovered
assert_nil @domain.csync_record
CsyncJob.perform_now