From a7e303bba2d596cdeea5109d68d4288ed48a3a0f Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Wed, 27 Jan 2021 13:42:10 +0200 Subject: [PATCH 1/2] added test for domain tech contacts bulk change if domain has server update prohibited --- test/integration/api/domain_contacts_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/integration/api/domain_contacts_test.rb b/test/integration/api/domain_contacts_test.rb index 6704739d1..efd7032b4 100644 --- a/test/integration/api/domain_contacts_test.rb +++ b/test/integration/api/domain_contacts_test.rb @@ -107,6 +107,24 @@ class APIDomainContactsTest < ApplicationIntegrationTest JSON.parse(response.body, symbolize_names: true) end + def test_tech_bulk_changed_when_domain_update_prohibited + domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED]) + + shop_tech_contact = Contact.find_by(code: 'william-001') + assert domains(:shop).tech_contacts.include?(shop_tech_contact) + + patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001', + new_contact_id: 'john-001' }, + headers: { 'HTTP_AUTHORIZATION' => http_auth_key } + + assert_response :ok + assert_equal ({ code: 1000, + message: 'Command completed successfully', + data: { affected_domains: ["airport.test"], + skipped_domains: ["shop.test"] }}), + JSON.parse(response.body, symbolize_names: true) + end + private def http_auth_key From 218bc436e6b7b744179b06c0fd380a45f5e44696 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Tue, 2 Feb 2021 15:07:31 +0200 Subject: [PATCH 2/2] Added test for bulk transfer and bulk nameservers --- test/integration/api/domain_transfers_test.rb | 14 ++++++++++++++ test/integration/api/nameservers/put_test.rb | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/test/integration/api/domain_transfers_test.rb b/test/integration/api/domain_transfers_test.rb index 3e9c10100..2cf12130b 100644 --- a/test/integration/api/domain_transfers_test.rb +++ b/test/integration/api/domain_transfers_test.rb @@ -63,6 +63,20 @@ class APIDomainTransfersTest < ApplicationIntegrationTest assert_equal 1, @new_registrar.contacts.where(name: 'William').size end + def test_bulk_transfer_if_domain_has_update_prohibited_status + domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED]) + + post '/repp/v1/domains/transfer', params: request_params, as: :json, + headers: { 'HTTP_AUTHORIZATION' => http_auth_key } + + assert_response :ok + assert_equal ({ code: 1000, + message: 'Command completed successfully', + data: { success: [], + failed: [{ type: "domain_transfer", domain_name: "shop.test" }] }}), + JSON.parse(response.body, symbolize_names: true) + end + private def request_params diff --git a/test/integration/api/nameservers/put_test.rb b/test/integration/api/nameservers/put_test.rb index 77b01a9b1..f1a478da6 100644 --- a/test/integration/api/nameservers/put_test.rb +++ b/test/integration/api/nameservers/put_test.rb @@ -104,6 +104,22 @@ class APINameserversPutTest < ApplicationIntegrationTest JSON.parse(response.body, symbolize_names: true) end + def test_bulk_namesaervers_if_domain_update_prohibited + domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED]) + + params = { data: { type: 'nameserver', id: domains(:shop).nameservers.hostnames[0], + attributes: { hostname: 'ns55.bestnames.test' } } } + put '/repp/v1/registrar/nameservers', params: params, as: :json, + headers: { 'HTTP_AUTHORIZATION' => http_auth_key } + + assert_response :ok + assert_equal ({ code: 1000, + message: 'Command completed successfully', + data: { affected_domains: ["airport.test"], + skipped_domains: ["shop.test"] }}), + JSON.parse(response.body, symbolize_names: true) + end + def test_unauthenticated put '/repp/v1/registrar/nameservers' assert_response 401