Add new element, error messages, fix tests #2565

This commit is contained in:
Martin Lensment 2015-07-09 17:57:33 +03:00
parent 94adc9496f
commit bfdabaacf3
7 changed files with 77 additions and 25 deletions

View file

@ -96,8 +96,17 @@ class Domain < ActiveRecord::Base
validate :validate_reservation
def validate_reservation
return if persisted?
return if !in_reserved_list? || reserved_pw == auth_info
errors.add(:base, :domain_is_reserved_and_requires_correct_auth_info)
return if !in_reserved_list?
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
validates :nameservers, object_count: {
@ -149,7 +158,7 @@ class Domain < ActiveRecord::Base
end
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
nameservers.select { |x| x.hostname.end_with?(name) }
@ -263,11 +272,7 @@ class Domain < ActiveRecord::Base
end
def in_reserved_list?
reserved_pw.present?
end
def reserved_pw
ReservedDomain.pw_for(name)
ReservedDomain.pw_for(name).present?
end
def pending_transfer

View file

@ -25,7 +25,8 @@ class Epp::Domain < Domain
],
'2003' => [ # Required parameter missing
[:registrant, :blank],
[:registrar, :blank]
[:registrar, :blank],
[:base, :required_parameter_missing_reserved]
],
'2004' => [ # Parameter value range error
[:nameservers, :out_of_range,
@ -60,14 +61,16 @@ class Epp::Domain < Domain
'2201' => [ # Authorisation error
[:auth_info, :wrong_pw]
],
'2202' => [
[:base, :invalid_auth_information_reserved]
],
'2302' => [ # Object exists
[:name_dirty, :taken, { value: { obj: 'name', val: name_dirty } }],
[:name_dirty, :reserved, { value: { obj: 'name', val: name_dirty } }],
[:name_dirty, :blocked, { value: { obj: 'name', val: name_dirty } }]
],
'2304' => [ # Object status prohibits operation
[:base, :domain_status_prohibits_operation],
[:base, :domain_is_reserved_and_requires_correct_auth_info]
[:base, :domain_status_prohibits_operation]
],
'2306' => [ # Parameter policy error
[: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[:auth_info] = frame.css('pw').text if new_record?
at[:reserved_pw] = frame.css('reserved > pw').text
# at[:statuses] = domain_statuses_attrs(frame, action)
# binding.pry