fix: update admin contact validation error code

- Change error code from 2004 to 2306 for admin contact validation
- Add explicit validation check for required admin contacts
- Update tests to expect new error code

The error code 2306 better reflects the EPP standard for policy-based
validation failures. This change makes the error handling more consistent
with EPP specifications when validating admin contact requirements.
This commit is contained in:
oleghasjanov 2025-02-05 10:54:21 +02:00
parent dc37223bc2
commit a56237c84f
2 changed files with 10 additions and 4 deletions

View file

@ -29,6 +29,12 @@ class Epp::Domain < Domain
active_admins = admin_domain_contacts.select { |x| !x.marked_for_destruction? }
active_techs = tech_domain_contacts.select { |x| !x.marked_for_destruction? }
# Проверка количества админ контактов
if require_admin_contacts? && active_admins.empty?
add_epp_error('2306', 'contact', nil, 'Admin contacts are required')
ok = false
end
# validate registrant here as well
([Contact.find(registrant.id)] + active_admins + active_techs).each do |x|
unless x.valid?

View file

@ -142,7 +142,7 @@ class ReppV1DomainsContactsTest < ActionDispatch::IntegrationTest
@domain.reload
assert_response :bad_request
assert_equal 2004, json[:code]
assert_equal 2306, json[:code]
assert @domain.admin_contacts.any?
end
@ -159,7 +159,7 @@ class ReppV1DomainsContactsTest < ActionDispatch::IntegrationTest
json = JSON.parse(response.body, symbolize_names: true)
assert_response :bad_request
assert_equal 2004, json[:code]
assert_equal 2306, json[:code]
assert @domain.admin_contacts.any?
end
@ -178,7 +178,7 @@ class ReppV1DomainsContactsTest < ActionDispatch::IntegrationTest
json = JSON.parse(response.body, symbolize_names: true)
assert_response :bad_request
assert_equal 2004, json[:code]
assert_equal 2306, json[:code]
assert @domain.admin_contacts.any?
end
@ -217,7 +217,7 @@ class ReppV1DomainsContactsTest < ActionDispatch::IntegrationTest
json = JSON.parse(response.body, symbolize_names: true)
assert_response :bad_request
assert_equal 2004, json[:code]
assert_equal 2306, json[:code]
assert @domain.admin_contacts.any?
end