Change EPP response code according to its specification

Fixes #718
This commit is contained in:
Artur Beljajev 2019-09-13 21:29:49 +03:00
parent 03c81c4c5d
commit 79d9c631f5
6 changed files with 25 additions and 17 deletions

View file

@ -450,7 +450,12 @@ class Epp::Domain < Domain
def update(frame, current_user, verify = true) def update(frame, current_user, verify = true)
return super if frame.blank? return super if frame.blank?
check_discarded if discarded?
throw :epp_error, {
code: '2304',
msg: 'Object status prohibits operation',
}
end
at = {}.with_indifferent_access at = {}.with_indifferent_access
at.deep_merge!(attrs_from(frame.css('chg'), current_user, 'chg')) at.deep_merge!(attrs_from(frame.css('chg'), current_user, 'chg'))
@ -525,7 +530,12 @@ class Epp::Domain < Domain
end end
def epp_destroy(frame, user_id) def epp_destroy(frame, user_id)
check_discarded if discarded?
throw :epp_error, {
code: '2304',
msg: 'Object status prohibits operation',
}
end
if doc = attach_legal_document(Epp::Domain.parse_legal_document_from_frame(frame)) if doc = attach_legal_document(Epp::Domain.parse_legal_document_from_frame(frame))
frame.css("legalDocument").first.content = doc.path if doc&.persisted? frame.css("legalDocument").first.content = doc.path if doc&.persisted?
@ -590,7 +600,12 @@ class Epp::Domain < Domain
### TRANSFER ### ### TRANSFER ###
def transfer(frame, action, current_user) def transfer(frame, action, current_user)
check_discarded if discarded?
throw :epp_error, {
code: '2106',
msg: 'Object is not eligible for transfer',
}
end
@is_transfer = true @is_transfer = true
@ -814,15 +829,4 @@ class Epp::Domain < Domain
result result
end end
end end
private
def check_discarded
if discarded?
throw :epp_error, {
code: '2105',
msg: I18n.t(:object_is_not_eligible_for_renewal),
}
end
end
end end

View file

@ -18,6 +18,7 @@ module Epp
parameter_value_syntax_error: 2005, parameter_value_syntax_error: 2005,
billing_failure: 2104, billing_failure: 2104,
object_is_not_eligible_for_renewal: 2105, object_is_not_eligible_for_renewal: 2105,
object_is_not_eligible_for_transfer: 2106,
authorization_error: 2201, authorization_error: 2201,
invalid_authorization_information: 2202, invalid_authorization_information: 2202,
object_does_not_exist: 2303, object_does_not_exist: 2303,
@ -43,6 +44,7 @@ module Epp
2005 => 'Parameter value syntax error', 2005 => 'Parameter value syntax error',
2104 => 'Billing failure', 2104 => 'Billing failure',
2105 => 'Object is not eligible for renewal', 2105 => 'Object is not eligible for renewal',
2106 => 'Object is not eligible for transfer',
2201 => 'Authorization error', 2201 => 'Authorization error',
2202 => 'Invalid authorization information', 2202 => 'Invalid authorization information',
2303 => 'Object does not exist', 2303 => 'Object does not exist',

View file

@ -64,7 +64,7 @@ class EppDomainDeleteBaseTest < EppTestCase
assert_no_difference 'Domain.count' do assert_no_difference 'Domain.count' do
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end end
assert_epp_response :object_is_not_eligible_for_renewal assert_epp_response :object_status_prohibits_operation
end end
def test_requests_registrant_confirmation_when_required def test_requests_registrant_confirmation_when_required

View file

@ -47,6 +47,6 @@ class EppDomainUpdateTest < EppTestCase
XML XML
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
assert_epp_response :object_is_not_eligible_for_renewal assert_epp_response :object_status_prohibits_operation
end end
end end

View file

@ -86,7 +86,7 @@ class EppDomainTransferRequestTest < EppTestCase
@domain.reload @domain.reload
assert_equal registrars(:bestnames), @domain.registrar assert_equal registrars(:bestnames), @domain.registrar
assert_epp_response :object_is_not_eligible_for_renewal assert_epp_response :object_is_not_eligible_for_transfer
end end
def test_same_registrar def test_same_registrar

View file

@ -39,6 +39,7 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase
parameter_value_syntax_error: 2005, parameter_value_syntax_error: 2005,
billing_failure: 2104, billing_failure: 2104,
object_is_not_eligible_for_renewal: 2105, object_is_not_eligible_for_renewal: 2105,
object_is_not_eligible_for_transfer: 2106,
authorization_error: 2201, authorization_error: 2201,
invalid_authorization_information: 2202, invalid_authorization_information: 2202,
object_does_not_exist: 2303, object_does_not_exist: 2303,
@ -66,6 +67,7 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase
2005 => 'Parameter value syntax error', 2005 => 'Parameter value syntax error',
2104 => 'Billing failure', 2104 => 'Billing failure',
2105 => 'Object is not eligible for renewal', 2105 => 'Object is not eligible for renewal',
2106 => 'Object is not eligible for transfer',
2201 => 'Authorization error', 2201 => 'Authorization error',
2202 => 'Invalid authorization information', 2202 => 'Invalid authorization information',
2303 => 'Object does not exist', 2303 => 'Object does not exist',