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

@ -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