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
if ident_frame
if identifier.valid?
report_update_disallowed_error
report_valid_ident_error
else
wrong_ident = ident_frame.text.present? && (ident_frame.text != ident)
report_wrong_ident_error if wrong_ident
ident_update_attempt = ident_frame.text.present? && (ident_frame.text != ident)
report_ident_update_error if ident_update_attempt
identifier = Ident.new(code: ident,
type: ident_frame.attr('type'),
@ -240,11 +240,11 @@ class Epp::Contact < Contact
private
def report_update_disallowed_error
throw :epp_error, { code: '2308', msg: I18n.t('epp.contacts.errors.update_disallowed') }
def report_valid_ident_error
throw :epp_error, { code: '2308', msg: I18n.t('epp.contacts.errors.valid_ident') }
end
def report_wrong_ident_error
throw :epp_error, { code: '2308', msg: I18n.t('epp.contacts.errors.wrong_ident') }
def report_ident_update_error
throw :epp_error, { code: '2308', msg: I18n.t('epp.contacts.errors.ident_update') }
end
end

View file

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

View file

@ -61,7 +61,7 @@ RSpec.describe 'EPP contact:update' do
request
expect(epp_response).to have_result(:data_management_policy_violation,
t('epp.contacts.errors.update_disallowed'))
t('epp.contacts.errors.valid_ident'))
end
end
@ -172,7 +172,7 @@ RSpec.describe 'EPP contact:update' do
request
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