Improve EPP contact:update ident errors

#569
This commit is contained in:
Artur Beljajev 2017-09-20 10:54:18 +03:00
parent ec4b3abae4
commit c05e6ead2a
3 changed files with 13 additions and 13 deletions

View file

@ -158,10 +158,10 @@ class Epp::Contact < Contact
# https://github.com/internetee/registry/issues/576 # https://github.com/internetee/registry/issues/576
if ident_frame if ident_frame
if identifier.valid? if identifier.valid?
report_update_disallowed_error report_valid_ident_error
else else
wrong_ident = ident_frame.text.present? && (ident_frame.text != ident) ident_update_attempt = ident_frame.text.present? && (ident_frame.text != ident)
report_wrong_ident_error if wrong_ident report_ident_update_error if ident_update_attempt
identifier = Ident.new(code: ident, identifier = Ident.new(code: ident,
type: ident_frame.attr('type'), type: ident_frame.attr('type'),
@ -240,11 +240,11 @@ class Epp::Contact < Contact
private private
def report_update_disallowed_error def report_valid_ident_error
throw :epp_error, { code: '2308', msg: I18n.t('epp.contacts.errors.update_disallowed') } throw :epp_error, { code: '2308', msg: I18n.t('epp.contacts.errors.valid_ident') }
end end
def report_wrong_ident_error def report_ident_update_error
throw :epp_error, { code: '2308', msg: I18n.t('epp.contacts.errors.wrong_ident') } throw :epp_error, { code: '2308', msg: I18n.t('epp.contacts.errors.ident_update') }
end end
end end

View file

@ -5,9 +5,9 @@ en:
completed_without_address: Command completed successfully; Postal address data discarded completed_without_address: Command completed successfully; Postal address data discarded
errors: errors:
update_disallowed: >- valid_ident: >-
Ident update is not allowed. Ident update is not allowed.
Consider creating new contact object Consider creating new contact object
wrong_ident: >- ident_update: >-
Ident is wrong. Only ident type and country can be updated in case of invalid ident.
A valid ident should be provided in order to be able to update missing ident country code or type Please create new contact object to update ident code

View file

@ -61,7 +61,7 @@ RSpec.describe 'EPP contact:update' do
request request
expect(epp_response).to have_result(:data_management_policy_violation, expect(epp_response).to have_result(:data_management_policy_violation,
t('epp.contacts.errors.update_disallowed')) t('epp.contacts.errors.valid_ident'))
end end
end end
@ -172,7 +172,7 @@ RSpec.describe 'EPP contact:update' do
request request
expect(epp_response).to have_result(:data_management_policy_violation, expect(epp_response).to have_result(:data_management_policy_violation,
t('epp.contacts.errors.wrong_ident')) t('epp.contacts.errors.ident_update'))
end end
end end
end end