Merge branch 'master' into registry-746

# Conflicts:
#	test/fixtures/contacts.yml
This commit is contained in:
Artur Beljajev 2018-03-06 07:04:06 +02:00
commit c733c0910d
34 changed files with 721 additions and 215 deletions

View file

@ -0,0 +1,27 @@
require 'test_helper'
class NameserverGlueRecordTest < ActiveSupport::TestCase
def setup
@nameserver = nameservers(:shop_ns1)
end
def test_invalid_without_ip_if_glue_record_is_required
@nameserver.hostname = 'ns1.shop.test'
@nameserver.ipv4 = @nameserver.ipv6 = ''
assert @nameserver.invalid?
assert_includes @nameserver.errors.full_messages, 'Either IPv4 or IPv6 is required' \
' for glue record generation'
end
def test_valid_with_ip_if_glue_record_is_required
@nameserver.hostname = 'ns1.shop.test'
@nameserver.ipv4 = ['192.0.2.1']
@nameserver.ipv6 = ''
assert @nameserver.valid?
end
def test_valid_without_ip_if_glue_record_is_not_required
@nameserver.ipv4 = @nameserver.ipv6 = ''
assert @nameserver.valid?
end
end

View file

@ -0,0 +1,81 @@
require 'test_helper'
class NameserverTest < ActiveSupport::TestCase
def setup
@nameserver = nameservers(:shop_ns1)
end
def test_valid
assert @nameserver.valid?
end
def test_invalid_without_domain
@nameserver.domain = nil
assert @nameserver.invalid?
end
def test_invalid_without_hostname
@nameserver.hostname = ''
assert @nameserver.invalid?
end
def test_hostname_format_validation
@nameserver.hostname = 'foo.bar'
assert @nameserver.valid?
@nameserver.hostname = 'äöüõšž.ÄÖÜÕŠŽ.umlauts'
assert @nameserver.valid?
@nameserver.hostname = 'foo_bar'
assert @nameserver.invalid?
end
def test_ipv4_format_validation
@nameserver.ipv4 = ['192.0.2.1']
assert @nameserver.valid?
@nameserver.ipv4 = ['0.0.0.256']
assert @nameserver.invalid?
@nameserver.ipv4 = ['192.168.0.0/24']
assert @nameserver.invalid?
end
def test_ipv6_format_validation
@nameserver.ipv6 = ['2001:db8::1']
assert @nameserver.valid?
@nameserver.ipv6 = ['3ffe:0b00:0000:0001:0000:0000:000a']
assert @nameserver.invalid?
end
def test_hostnames
assert_equal %w[ns1.bestnames.test
ns2.bestnames.test
ns1.bestnames.test
ns1.bestnames.test], Nameserver.hostnames
end
def test_normalizes_hostname
@nameserver.hostname = ' ns1.bestnameS.test.'
@nameserver.validate
assert_equal 'ns1.bestnames.test', @nameserver.hostname
end
def test_normalizes_ipv4
@nameserver.ipv4 = [' 192.0.2.1']
@nameserver.validate
assert_equal ['192.0.2.1'], @nameserver.ipv4
end
def test_normalizes_ipv6
@nameserver.ipv6 = [' 2001:db8::1']
@nameserver.validate
assert_equal ['2001:DB8::1'], @nameserver.ipv6
end
def test_encodes_hostname_to_punycode
@nameserver.hostname = 'ns1.münchen.de'
assert_equal 'ns1.xn--mnchen-3ya.de', @nameserver.hostname_puny
end
end