Merge branch 'master' of github.com:domify/registry

This commit is contained in:
Martin Lensment 2015-06-02 15:10:40 +03:00
commit bf11806411
5 changed files with 94 additions and 1 deletions

View file

@ -70,6 +70,7 @@ class Domain < ActiveRecord::Base
after_save :update_whois_record after_save :update_whois_record
validates :name_dirty, domain_name: true, uniqueness: true validates :name_dirty, domain_name: true, uniqueness: true
validates :name_puny, length: { maximum: 66 }
validates :period, numericality: { only_integer: true } validates :period, numericality: { only_integer: true }
validates :registrant, :registrar, presence: true validates :registrant, :registrar, presence: true

View file

@ -55,7 +55,8 @@ class Epp::Domain < Domain
] ]
], ],
'2005' => [ # Parameter value syntax error '2005' => [ # Parameter value syntax error
[:name_dirty, :invalid, { obj: 'name', val: name_dirty }] [:name_dirty, :invalid, { obj: 'name', val: name_dirty }],
[:name_puny, :too_long, { obj: 'name', val: name_puny }]
], ],
'2201' => [ # Authorisation error '2201' => [ # Authorisation error
[:auth_info, :wrong_pw] [:auth_info, :wrong_pw]

View file

@ -64,6 +64,8 @@ en:
invalid: 'Domain name is invalid' invalid: 'Domain name is invalid'
reserved: 'Domain name is reserved or restricted' reserved: 'Domain name is reserved or restricted'
taken: 'Domain name already exists' taken: 'Domain name already exists'
name_puny:
too_long: 'Domain name is too long (maximum is 63 characters)'
registrant: registrant:
blank: 'Registrant is missing' blank: 'Registrant is missing'
not_found: 'Registrant not found' not_found: 'Registrant not found'

View file

@ -189,6 +189,15 @@ describe 'EPP Domain', epp: true do
# response[:clTRID].should == 'ABC-12345' # response[:clTRID].should == 'ABC-12345'
# end # end
it 'does not create domain longer than 63 punicode characters' do
xml = domain_create_xml(name: { value: "#{'ä' * 63}.ee" })
response = epp_plain_request(xml)
response[:msg].should == 'Domain name is too long (maximum is 63 characters) [name_puny]'
response[:result_code].should == '2005'
response[:clTRID].should == 'ABC-12345'
end
it 'does not create reserved domain' do it 'does not create reserved domain' do
xml = domain_create_xml(name: { value: '1162.ee' }) xml = domain_create_xml(name: { value: '1162.ee' })

View file

@ -226,6 +226,86 @@ describe Domain do
expect(d.name_dirty).to eq('test.ee') expect(d.name_dirty).to eq('test.ee')
end end
it 'should be valid when name length is exatly 63 in characters' do
d = Fabricate(:domain, name: "#{'a' * 63}.ee")
d.valid?
d.errors.full_messages.should == []
end
it 'should not be valid when name length is longer than 63 characters' do
d = Fabricate.build(:domain, name: "#{'a' * 64}.ee")
d.valid?
d.errors.full_messages.should match_array([
"Domain name Domain name is invalid",
"Domain name Domain name is too long (maximum is 63 characters)"
])
end
it 'should not be valid when name length is longer than 63 characters' do
d = Fabricate.build(:domain,
name: "xn--4caaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ee")
d.valid?
d.errors.full_messages.should match_array([
"Domain name Domain name is invalid",
"Domain name Domain name is too long (maximum is 63 characters)"
])
end
it 'should not be valid when name length is longer than 63 punycode characters' do
d = Fabricate.build(:domain, name: "#{'ä' * 63}.ee")
d.valid?
d.errors.full_messages.should == [
"Domain name Domain name is too long (maximum is 63 characters)"
]
end
it 'should not be valid when name length is longer than 63 punycode characters' do
d = Fabricate.build(:domain, name: "#{'ä' * 64}.ee")
d.valid?
d.errors.full_messages.should match_array([
"Domain name Domain name is invalid",
"Domain name Domain name is too long (maximum is 63 characters)"
])
end
it 'should not be valid when name length is longer than 63 punycode characters' do
d = Fabricate.build(:domain, name: "#{'ä' * 63}.pri.ee")
d.valid?
d.errors.full_messages.should match_array([
"Domain name Domain name is too long (maximum is 63 characters)"
])
end
it 'should be valid when punycode name length is not longer than 63' do
d = Fabricate.build(:domain, name: "#{'ä' * 53}.pri.ee")
d.valid?
d.errors.full_messages.should == []
end
it 'should be valid when punycode name length is not longer than 63' do
d = Fabricate.build(:domain, name: "#{'ä' * 57}.ee")
d.valid?
d.errors.full_messages.should == []
end
it 'should not be valid when name length is one pynicode' do
d = Fabricate.build(:domain, name: "xn--4ca.ee")
d.valid?
d.errors.full_messages.should == ["Domain name Domain name is invalid"]
end
it 'should be valid when name length is two pynicodes' do
d = Fabricate.build(:domain, name: "xn--4caa.ee")
d.valid?
d.errors.full_messages.should == []
end
it 'should be valid when name length is two pynicodes' do
d = Fabricate.build(:domain, name: "xn--4ca0b.ee")
d.valid?
d.errors.full_messages.should == []
end
it 'normalizes ns attrs' do it 'normalizes ns attrs' do
d = Fabricate(:domain) d = Fabricate(:domain)
d.nameservers.build(hostname: 'BLA.EXAMPLE.EE', ipv4: ' 192.168.1.1', ipv6: '1080:0:0:0:8:800:200c:417a') d.nameservers.build(hostname: 'BLA.EXAMPLE.EE', ipv4: ' 192.168.1.1', ipv6: '1080:0:0:0:8:800:200c:417a')