mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Add new element, error messages, fix tests #2565
This commit is contained in:
parent
94adc9496f
commit
bfdabaacf3
7 changed files with 77 additions and 25 deletions
|
@ -96,8 +96,17 @@ class Domain < ActiveRecord::Base
|
||||||
validate :validate_reservation
|
validate :validate_reservation
|
||||||
def validate_reservation
|
def validate_reservation
|
||||||
return if persisted?
|
return if persisted?
|
||||||
return if !in_reserved_list? || reserved_pw == auth_info
|
return if !in_reserved_list?
|
||||||
errors.add(:base, :domain_is_reserved_and_requires_correct_auth_info)
|
|
||||||
|
if reserved_pw.blank?
|
||||||
|
errors.add(:base, :required_parameter_missing_reserved)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if ReservedDomain.pw_for(name) != reserved_pw
|
||||||
|
errors.add(:base, :invalid_auth_information_reserved)
|
||||||
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
validates :nameservers, object_count: {
|
validates :nameservers, object_count: {
|
||||||
|
@ -149,7 +158,7 @@ class Domain < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor :registrant_typeahead, :update_me, :deliver_emails,
|
attr_accessor :registrant_typeahead, :update_me, :deliver_emails,
|
||||||
:epp_pending_update, :epp_pending_delete
|
:epp_pending_update, :epp_pending_delete, :reserved_pw
|
||||||
|
|
||||||
def subordinate_nameservers
|
def subordinate_nameservers
|
||||||
nameservers.select { |x| x.hostname.end_with?(name) }
|
nameservers.select { |x| x.hostname.end_with?(name) }
|
||||||
|
@ -263,11 +272,7 @@ class Domain < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def in_reserved_list?
|
def in_reserved_list?
|
||||||
reserved_pw.present?
|
ReservedDomain.pw_for(name).present?
|
||||||
end
|
|
||||||
|
|
||||||
def reserved_pw
|
|
||||||
ReservedDomain.pw_for(name)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pending_transfer
|
def pending_transfer
|
||||||
|
|
|
@ -25,7 +25,8 @@ class Epp::Domain < Domain
|
||||||
],
|
],
|
||||||
'2003' => [ # Required parameter missing
|
'2003' => [ # Required parameter missing
|
||||||
[:registrant, :blank],
|
[:registrant, :blank],
|
||||||
[:registrar, :blank]
|
[:registrar, :blank],
|
||||||
|
[:base, :required_parameter_missing_reserved]
|
||||||
],
|
],
|
||||||
'2004' => [ # Parameter value range error
|
'2004' => [ # Parameter value range error
|
||||||
[:nameservers, :out_of_range,
|
[:nameservers, :out_of_range,
|
||||||
|
@ -60,14 +61,16 @@ class Epp::Domain < Domain
|
||||||
'2201' => [ # Authorisation error
|
'2201' => [ # Authorisation error
|
||||||
[:auth_info, :wrong_pw]
|
[:auth_info, :wrong_pw]
|
||||||
],
|
],
|
||||||
|
'2202' => [
|
||||||
|
[:base, :invalid_auth_information_reserved]
|
||||||
|
],
|
||||||
'2302' => [ # Object exists
|
'2302' => [ # Object exists
|
||||||
[:name_dirty, :taken, { value: { obj: 'name', val: name_dirty } }],
|
[:name_dirty, :taken, { value: { obj: 'name', val: name_dirty } }],
|
||||||
[:name_dirty, :reserved, { value: { obj: 'name', val: name_dirty } }],
|
[:name_dirty, :reserved, { value: { obj: 'name', val: name_dirty } }],
|
||||||
[:name_dirty, :blocked, { value: { obj: 'name', val: name_dirty } }]
|
[:name_dirty, :blocked, { value: { obj: 'name', val: name_dirty } }]
|
||||||
],
|
],
|
||||||
'2304' => [ # Object status prohibits operation
|
'2304' => [ # Object status prohibits operation
|
||||||
[:base, :domain_status_prohibits_operation],
|
[:base, :domain_status_prohibits_operation]
|
||||||
[:base, :domain_is_reserved_and_requires_correct_auth_info]
|
|
||||||
],
|
],
|
||||||
'2306' => [ # Parameter policy error
|
'2306' => [ # Parameter policy error
|
||||||
[:period, :out_of_range, { value: { obj: 'period', val: period } }],
|
[:period, :out_of_range, { value: { obj: 'period', val: period } }],
|
||||||
|
@ -113,7 +116,7 @@ class Epp::Domain < Domain
|
||||||
|
|
||||||
at[:period_unit] = Epp::Domain.parse_period_unit_from_frame(frame) || 'y'
|
at[:period_unit] = Epp::Domain.parse_period_unit_from_frame(frame) || 'y'
|
||||||
|
|
||||||
at[:auth_info] = frame.css('pw').text if new_record?
|
at[:reserved_pw] = frame.css('reserved > pw').text
|
||||||
|
|
||||||
# at[:statuses] = domain_statuses_attrs(frame, action)
|
# at[:statuses] = domain_statuses_attrs(frame, action)
|
||||||
# binding.pry
|
# binding.pry
|
||||||
|
|
|
@ -60,7 +60,8 @@ en:
|
||||||
ds_data_not_allowed: 'dsData object is not allowed'
|
ds_data_not_allowed: 'dsData object is not allowed'
|
||||||
ds_data_with_key_not_allowed: 'dsData object with key data is not allowed'
|
ds_data_with_key_not_allowed: 'dsData object with key data is not allowed'
|
||||||
key_data_not_allowed: 'keyData object is not allowed'
|
key_data_not_allowed: 'keyData object is not allowed'
|
||||||
domain_is_reserved_and_requires_correct_auth_info: 'Domain is reserved and requires correct auth info'
|
required_parameter_missing_reserved: 'Required parameter missing; reserved>pw element required for reserved domains'
|
||||||
|
invalid_auth_information_reserved: 'Invalid authorization information; invalid reserved>pw value'
|
||||||
name_dirty:
|
name_dirty:
|
||||||
invalid: 'Domain name is invalid'
|
invalid: 'Domain name is invalid'
|
||||||
reserved: 'Domain name is reserved'
|
reserved: 'Domain name is reserved'
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
<sequence>
|
<sequence>
|
||||||
<element name="ident" type="eis:identType" minOccurs="0" maxOccurs="1"/>
|
<element name="ident" type="eis:identType" minOccurs="0" maxOccurs="1"/>
|
||||||
<element name="legalDocument" type="eis:legalDocType" minOccurs="0" maxOccurs="1"/>
|
<element name="legalDocument" type="eis:legalDocType" minOccurs="0" maxOccurs="1"/>
|
||||||
|
<element name="reserved" type="eis:reservedType" minOccurs="0" maxOccurs="1"/>
|
||||||
</sequence>
|
</sequence>
|
||||||
</complexType>
|
</complexType>
|
||||||
|
|
||||||
|
@ -31,6 +32,23 @@
|
||||||
Child elements of extdata
|
Child elements of extdata
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Reserved for providing passwords for reserved domains
|
||||||
|
-->
|
||||||
|
|
||||||
|
<complexType name="reservedType">
|
||||||
|
<sequence>
|
||||||
|
<element name="pw" type="eis:pwType" minOccurs="1" maxOccurs="1"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
|
||||||
|
<simpleType name="pwType">
|
||||||
|
<restriction base="normalizedString">
|
||||||
|
<minLength value="1"/>
|
||||||
|
<maxLength value="255"/>
|
||||||
|
</restriction>
|
||||||
|
</simpleType>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Legal document, encoded in base64
|
Legal document, encoded in base64
|
||||||
-->
|
-->
|
||||||
|
|
|
@ -225,18 +225,39 @@ describe 'EPP Domain', epp: true do
|
||||||
xml = domain_create_xml(name: { value: '1162.ee' })
|
xml = domain_create_xml(name: { value: '1162.ee' })
|
||||||
|
|
||||||
response = epp_plain_request(xml)
|
response = epp_plain_request(xml)
|
||||||
response[:result_code].should == '2304'
|
response[:msg].should == 'Required parameter missing; reserved>pw element required for reserved domains'
|
||||||
response[:msg].should == 'Domain is reserved and requires correct auth info'
|
response[:result_code].should == '2003'
|
||||||
response[:clTRID].should == 'ABC-12345'
|
response[:clTRID].should == 'ABC-12345'
|
||||||
|
|
||||||
xml = domain_create_xml(name: { value: '1162.ee' }, authInfo: { pw: { value: 'wrong_pw' } })
|
xml = domain_create_xml({name: { value: '1162.ee' }}, {}, {
|
||||||
|
_anonymus: [
|
||||||
|
legalDocument: {
|
||||||
|
value: 'dGVzdCBmYWlsCg==',
|
||||||
|
attrs: { type: 'pdf' }
|
||||||
|
},
|
||||||
|
reserved: {
|
||||||
|
pw: { value: 'wrong_pw' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
response = epp_plain_request(xml)
|
response = epp_plain_request(xml)
|
||||||
response[:result_code].should == '2304'
|
response[:msg].should == 'Invalid authorization information; invalid reserved>pw value'
|
||||||
response[:msg].should == 'Domain is reserved and requires correct auth info'
|
response[:result_code].should == '2202'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a reserved domain with correct auth info' do
|
it 'creates a reserved domain with correct auth info' do
|
||||||
xml = domain_create_xml(name: { value: '1162.ee' }, authInfo: { pw: { value: 'abc' } })
|
xml = domain_create_xml({name: { value: '1162.ee' }}, {}, {
|
||||||
|
_anonymus: [
|
||||||
|
legalDocument: {
|
||||||
|
value: 'dGVzdCBmYWlsCg==',
|
||||||
|
attrs: { type: 'pdf' }
|
||||||
|
},
|
||||||
|
reserved: {
|
||||||
|
pw: { value: 'abc' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
response = epp_plain_request(xml)
|
response = epp_plain_request(xml)
|
||||||
response[:msg].should == 'Command completed successfully'
|
response[:msg].should == 'Command completed successfully'
|
||||||
|
|
|
@ -24,12 +24,14 @@ feature 'ReservedDomain', type: :feature do
|
||||||
page.should have_content('110.ee: testpw')
|
page.should have_content('110.ee: testpw')
|
||||||
|
|
||||||
d.valid?.should == false
|
d.valid?.should == false
|
||||||
d.errors.full_messages.should match_array(["Domain is reserved and requires correct auth info"])
|
d.errors.full_messages.should match_array(
|
||||||
|
["Required parameter missing; reserved>pw element required for reserved domains"]
|
||||||
|
)
|
||||||
|
|
||||||
d.auth_info = 'wrongpw'
|
d.reserved_pw = 'wrongpw'
|
||||||
d.valid?.should == false
|
d.valid?.should == false
|
||||||
|
|
||||||
d.auth_info = 'testpw'
|
d.reserved_pw = 'testpw'
|
||||||
d.valid?.should == true
|
d.valid?.should == true
|
||||||
d.errors.full_messages.should match_array([])
|
d.errors.full_messages.should match_array([])
|
||||||
end
|
end
|
||||||
|
|
|
@ -144,7 +144,7 @@ module Epp
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop: disable Metrics/MethodLength
|
# rubocop: disable Metrics/MethodLength
|
||||||
def domain_create_xml(xml_params = {}, dnssec_params = {})
|
def domain_create_xml(xml_params = {}, dnssec_params = {}, custom_params = {})
|
||||||
defaults = {
|
defaults = {
|
||||||
name: { value: next_domain_name },
|
name: { value: next_domain_name },
|
||||||
period: { value: '1', attrs: { unit: 'y' } },
|
period: { value: '1', attrs: { unit: 'y' } },
|
||||||
|
@ -185,7 +185,7 @@ module Epp
|
||||||
|
|
||||||
dnssec_params = dnssec_defaults.deep_merge(dnssec_params) if dnssec_params != false
|
dnssec_params = dnssec_defaults.deep_merge(dnssec_params) if dnssec_params != false
|
||||||
|
|
||||||
custom_params = {
|
custom_defaults = {
|
||||||
_anonymus: [
|
_anonymus: [
|
||||||
legalDocument: {
|
legalDocument: {
|
||||||
value: 'dGVzdCBmYWlsCg==',
|
value: 'dGVzdCBmYWlsCg==',
|
||||||
|
@ -194,6 +194,8 @@ module Epp
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
custom_params = custom_defaults.deep_merge(custom_params) if custom_params != false
|
||||||
|
|
||||||
epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345')
|
epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345')
|
||||||
epp_xml.create(xml_params, dnssec_params, custom_params)
|
epp_xml.create(xml_params, dnssec_params, custom_params)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue