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

This commit is contained in:
Martin Lensment 2015-04-29 13:31:21 +03:00
commit c5cc923619
4 changed files with 279 additions and 34 deletions

View file

@ -9,20 +9,34 @@ class Epp::Contact < Contact
# rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/CyclomaticComplexity
# rubocop: disable Metrics/MethodLength
def attrs_from(frame)
def attrs_from(frame, rem = nil)
f = frame
at = {}.with_indifferent_access
at[:name] = f.css('postalInfo name').text if f.css('postalInfo name').present?
at[:org_name] = f.css('postalInfo org').text if f.css('postalInfo org').present?
at[:email] = f.css('email').text if f.css('email').present?
at[:fax] = f.css('fax').text if f.css('fax').present?
at[:phone] = f.css('voice').text if f.css('voice').present?
at[:city] = f.css('postalInfo addr city').text if f.css('postalInfo addr city').present?
at[:zip] = f.css('postalInfo addr pc').text if f.css('postalInfo addr pc').present?
at[:street] = f.css('postalInfo addr street').text if f.css('postalInfo addr street').present?
at[:state] = f.css('postalInfo addr sp').text if f.css('postalInfo addr sp').present?
at[:country_code] = f.css('postalInfo addr cc').text if f.css('postalInfo addr cc').present?
at[:auth_info] = f.css('authInfo pw').text if f.css('authInfo pw').present?
if rem
at[:name] = nil if f.css('postalInfo name').present?
at[:org_name] = nil if f.css('postalInfo org').present?
at[:email] = nil if f.css('email').present?
at[:fax] = nil if f.css('fax').present?
at[:phone] = nil if f.css('voice').present?
at[:city] = nil if f.css('postalInfo addr city').present?
at[:zip] = nil if f.css('postalInfo addr pc').present?
at[:street] = nil if f.css('postalInfo addr street').present?
at[:state] = nil if f.css('postalInfo addr sp').present?
at[:country_code] = nil if f.css('postalInfo addr cc').present?
at[:auth_info] = nil if f.css('authInfo pw').present?
else
at[:name] = f.css('postalInfo name').text if f.css('postalInfo name').present?
at[:org_name] = f.css('postalInfo org').text if f.css('postalInfo org').present?
at[:email] = f.css('email').text if f.css('email').present?
at[:fax] = f.css('fax').text if f.css('fax').present?
at[:phone] = f.css('voice').text if f.css('voice').present?
at[:city] = f.css('postalInfo addr city').text if f.css('postalInfo addr city').present?
at[:zip] = f.css('postalInfo addr pc').text if f.css('postalInfo addr pc').present?
at[:street] = f.css('postalInfo addr street').text if f.css('postalInfo addr street').present?
at[:state] = f.css('postalInfo addr sp').text if f.css('postalInfo addr sp').present?
at[:country_code] = f.css('postalInfo addr cc').text if f.css('postalInfo addr cc').present?
at[:auth_info] = f.css('authInfo pw').text if f.css('authInfo pw').present?
end
legal_frame = f.css('legalDocument').first
if legal_frame.present?
@ -80,18 +94,30 @@ class Epp::Contact < Contact
def epp_code_map # rubocop:disable Metrics/MethodLength
{
'2003' => [ # Required parameter missing
[:name, :blank],
[:email, :blank],
[:phone, :blank],
[:city, :blank],
[:zip, :blank],
[:street, :blank],
[:country_code, :blank]
],
'2005' => [ # Value syntax error
[:name, :invalid],
[:phone, :invalid],
[:email, :invalid],
[:ident, :invalid],
[:ident, :invalid_EE_identity_format],
[:ident, :invalid_birthday_format]
],
'2302' => [ # Object exists
[:code, :epp_id_taken]
],
'2305' => [ # Association exists
[:domains, :exist]
],
'2005' => [ # Value syntax error
[:phone, :invalid],
[:email, :invalid],
[:ident, :invalid],
[:ident, :invalid_EE_identity_format],
[:ident, :invalid_birthday_format]
'2306' => [ # Parameter policy error
]
}
end
@ -99,6 +125,8 @@ class Epp::Contact < Contact
def update_attributes(frame)
return super if frame.blank?
at = {}.with_indifferent_access
at.deep_merge!(self.class.attrs_from(frame.css('rem'), 'rem'))
at.deep_merge!(self.class.attrs_from(frame.css('add')))
at.deep_merge!(self.class.attrs_from(frame.css('chg')))
at.merge!(self.class.ident_attrs(frame.css('ident').first))
legal_frame = frame.css('legalDocument').first

View file

@ -13,23 +13,12 @@ class Epp::Domain < Domain
def epp_code_map # rubocop:disable Metrics/MethodLength
{
'2002' => [
'2002' => [ # Command use error
[:base, :domain_already_belongs_to_the_querying_registrar]
],
'2302' => [ # Object exists
[:name_dirty, :taken, { value: { obj: 'name', val: name_dirty } }],
[:name_dirty, :reserved, { value: { obj: 'name', val: name_dirty } }]
],
'2304' => [
[:base, :domain_status_prohibits_operation]
],
'2306' => [ # Parameter policy error
'2003' => [ # Required parameter missing
[:registrant, :blank],
[:base, :ds_data_with_key_not_allowed],
[:base, :ds_data_not_allowed],
[:base, :key_data_not_allowed],
[:period, :not_a_number],
[:period, :not_an_integer]
[:registrar, :blank]
],
'2004' => [ # Parameter value range error
[:nameservers, :out_of_range,
@ -58,11 +47,25 @@ class Epp::Domain < Domain
}
]
],
'2005' => [
'2005' => [ # Parameter value syntax error
[:name_dirty, :invalid, { obj: 'name', val: name_dirty }]
],
'2201' => [
'2201' => [ # Authorisation error
[:auth_info, :wrong_pw]
],
'2302' => [ # Object exists
[:name_dirty, :taken, { value: { obj: 'name', val: name_dirty } }],
[:name_dirty, :reserved, { value: { obj: 'name', val: name_dirty } }]
],
'2304' => [ # Object status prohibits operation
[:base, :domain_status_prohibits_operation]
],
'2306' => [ # Parameter policy error
[:base, :ds_data_with_key_not_allowed],
[:base, :ds_data_not_allowed],
[:base, :key_data_not_allowed],
[:period, :not_a_number],
[:period, :not_an_integer]
]
}
end