diff --git a/app/models/actions/contact_delete.rb b/app/models/actions/contact_delete.rb
index 59032d566..60d3252c4 100644
--- a/app/models/actions/contact_delete.rb
+++ b/app/models/actions/contact_delete.rb
@@ -19,6 +19,11 @@ module Actions
return
end
+ if contact.delete_prohibited?
+ contact.errors.add(:statuses, :delete_prohibited)
+ return
+ end
+
commit
end
diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb
index 0c0ed3d5f..4cd876d5f 100644
--- a/app/models/epp/contact.rb
+++ b/app/models/epp/contact.rb
@@ -82,8 +82,11 @@ class Epp::Contact < Contact
'2302' => [ # Object exists
[:code, :epp_id_taken]
],
+ '2304' => [ # Status prohibits operation
+ [:statuses, :delete_prohibited],
+ ],
'2305' => [ # Association exists
- [:domains, :exist]
+ [:domains, :exist],
]
}
end
diff --git a/config/locales/contacts.en.yml b/config/locales/contacts.en.yml
index 906bde193..4b4d099d7 100644
--- a/config/locales/contacts.en.yml
+++ b/config/locales/contacts.en.yml
@@ -25,8 +25,10 @@ en:
email_regex_check_error: Invalid format
domains:
exist: 'Object association prohibits operation'
+ delete_prohibited: Contact delete prohibited by status
statuses:
not_uniq: 'not uniq'
+ delete_prohibited: Contact delete prohibited by status
country_code:
invalid: Country code is not valid, should be in ISO_3166-1 alpha 2 format (%{value})
disclosed_attributes:
diff --git a/test/integration/epp/contact/delete/base_test.rb b/test/integration/epp/contact/delete/base_test.rb
index 26ba63897..e86bea9dd 100644
--- a/test/integration/epp/contact/delete/base_test.rb
+++ b/test/integration/epp/contact/delete/base_test.rb
@@ -27,6 +27,60 @@ class EppContactDeleteBaseTest < EppTestCase
assert_epp_response :completed_successfully
end
+ def test_delete_contact_with_server_delete_prohibited
+ contact = deletable_contact
+ contact.update(statuses: Contact::SERVER_DELETE_PROHIBITED)
+ assert contact.statuses.include? Contact::SERVER_DELETE_PROHIBITED
+
+ contact.update_columns(code: contact.code.upcase)
+
+ request_xml = <<-XML
+
+
+
+
+
+ #{contact.code.upcase}
+
+
+
+
+ XML
+
+ post epp_delete_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ assert Contact.exists?(id: contact.id)
+ assert_epp_response :object_status_prohibits_operation
+ end
+
+ def test_delete_contact_with_client_delete_prohibited
+ contact = deletable_contact
+ contact.update(statuses: Contact::CLIENT_DELETE_PROHIBITED)
+ assert contact.statuses.include? Contact::CLIENT_DELETE_PROHIBITED
+
+ contact.update_columns(code: contact.code.upcase)
+
+ request_xml = <<-XML
+
+
+
+
+
+ #{contact.code.upcase}
+
+
+
+
+ XML
+
+ post epp_delete_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ assert Contact.exists?(id: contact.id)
+ assert_epp_response :object_status_prohibits_operation
+ end
+
def test_undeletable_cannot_be_deleted
contact = contacts(:john)
assert_not contact.deletable?
@@ -61,4 +115,4 @@ class EppContactDeleteBaseTest < EppTestCase
DomainContact.delete_all
contacts(:john)
end
-end
\ No newline at end of file
+end