Improve ident-related error messages on EPP contact:update

#569
This commit is contained in:
Artur Beljajev 2017-09-12 19:00:01 +03:00
parent d5197962ee
commit 4e6d576b67
4 changed files with 21 additions and 14 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?
deny_ident_update report_update_disallowed_error
else else
ident_change_disallowed = ident_frame.text.present? && (ident_frame.text != ident) wrong_ident = ident_frame.text.present? && (ident_frame.text != ident)
deny_ident_update if ident_change_disallowed report_wrong_ident_error if wrong_ident
identifier = Ident.new(code: ident, identifier = Ident.new(code: ident,
type: ident_frame.attr('type'), type: ident_frame.attr('type'),
@ -240,7 +240,11 @@ class Epp::Contact < Contact
private private
def deny_ident_update def report_update_disallowed_error
throw :epp_error, { code: '2308', msg: I18n.t(:ident_update_error) } throw :epp_error, { code: '2308', msg: I18n.t('epp.contacts.errors.update_disallowed') }
end
def report_wrong_ident_error
throw :epp_error, { code: '2308', msg: I18n.t('epp.contacts.errors.wrong_ident') }
end end
end end

View file

@ -473,9 +473,6 @@ en:
crt_revoked: 'CRT (revoked)' crt_revoked: 'CRT (revoked)'
contact_org_error: 'Parameter value policy error. Org must be blank' contact_org_error: 'Parameter value policy error. Org must be blank'
contact_fax_error: 'Parameter value policy error. Fax must be blank' contact_fax_error: 'Parameter value policy error. Fax must be blank'
ident_update_error: >-
Data management policy violation:
update of ident not allowed, please consider creating new contact object
invoices: 'Invoices' invoices: 'Invoices'
no_such_user: 'No such user' no_such_user: 'No such user'
phone_no: 'Phone number' phone_no: 'Phone number'

View file

@ -3,3 +3,11 @@ en:
contacts: contacts:
completed: Command completed successfully completed: Command completed successfully
completed_without_address: Command completed successfully; Postal address data discarded completed_without_address: Command completed successfully; Postal address data discarded
errors:
update_disallowed: >-
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

View file

@ -60,9 +60,8 @@ RSpec.describe 'EPP contact:update' do
specify do specify do
request request
message = 'Data management policy violation:' \ expect(epp_response).to have_result(:data_management_policy_violation,
' update of ident not allowed, please consider creating new contact object' t('epp.contacts.errors.update_disallowed'))
expect(epp_response).to have_result(:data_management_policy_violation, message)
end end
end end
@ -172,9 +171,8 @@ RSpec.describe 'EPP contact:update' do
specify do specify do
request request
message = 'Data management policy violation:' \ expect(epp_response).to have_result(:data_management_policy_violation,
' update of ident not allowed, please consider creating new contact object' t('epp.contacts.errors.wrong_ident'))
expect(epp_response).to have_result(:data_management_policy_violation, message)
end end
end end
end end