Merge pull request #1856 from internetee/1849-contact-with-status-delete-prohibited-can-be-deleted

1849 contact with status delete prohibited can be deleted
This commit is contained in:
Timo Võhmar 2021-02-22 13:20:08 +02:00 committed by GitHub
commit bd2cdc7153
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 66 additions and 2 deletions

View file

@ -19,6 +19,11 @@ module Actions
return return
end end
if contact.delete_prohibited?
contact.errors.add(:statuses, :delete_prohibited)
return
end
commit commit
end end

View file

@ -82,8 +82,11 @@ class Epp::Contact < Contact
'2302' => [ # Object exists '2302' => [ # Object exists
[:code, :epp_id_taken] [:code, :epp_id_taken]
], ],
'2304' => [ # Status prohibits operation
[:statuses, :delete_prohibited],
],
'2305' => [ # Association exists '2305' => [ # Association exists
[:domains, :exist] [:domains, :exist],
] ]
} }
end end

View file

@ -25,8 +25,10 @@ en:
email_regex_check_error: Invalid format email_regex_check_error: Invalid format
domains: domains:
exist: 'Object association prohibits operation' exist: 'Object association prohibits operation'
delete_prohibited: Contact delete prohibited by status
statuses: statuses:
not_uniq: 'not uniq' not_uniq: 'not uniq'
delete_prohibited: Contact delete prohibited by status
country_code: country_code:
invalid: Country code is not valid, should be in ISO_3166-1 alpha 2 format (%{value}) invalid: Country code is not valid, should be in ISO_3166-1 alpha 2 format (%{value})
disclosed_attributes: disclosed_attributes:

View file

@ -27,6 +27,60 @@ class EppContactDeleteBaseTest < EppTestCase
assert_epp_response :completed_successfully assert_epp_response :completed_successfully
end 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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<delete>
<contact:delete xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:id>#{contact.code.upcase}</contact:id>
</contact:delete>
</delete>
</command>
</epp>
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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<delete>
<contact:delete xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:id>#{contact.code.upcase}</contact:id>
</contact:delete>
</delete>
</command>
</epp>
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 def test_undeletable_cannot_be_deleted
contact = contacts(:john) contact = contacts(:john)
assert_not contact.deletable? assert_not contact.deletable?