From d35042a1be225b51887bd2918b63c6f87dcb69d6 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 4 Jan 2021 18:30:20 +0500 Subject: [PATCH 001/132] Add test to check if Whois::Record saved --- test/models/domain/releasable/auctionable_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/models/domain/releasable/auctionable_test.rb b/test/models/domain/releasable/auctionable_test.rb index de3ac0ff6..bb0485f7d 100644 --- a/test/models/domain/releasable/auctionable_test.rb +++ b/test/models/domain/releasable/auctionable_test.rb @@ -58,6 +58,20 @@ class DomainReleasableAuctionableTest < ActiveSupport::TestCase end end + def test_updates_whois + @domain.update!(delete_date: '2010-07-04') + travel_to Time.zone.parse('2010-07-05') + + Domain.release_domains + + whois_record = Whois::Record.find_by(name: @domain.name) + + json = { "name"=>@domain.name, + "status"=>["AtAuction"], + "disclaimer"=> Setting.registry_whois_disclaimer } + assert_equal whois_record.json, json + end + def test_notifies_registrar @domain.update!(delete_date: '2010-07-04') travel_to Time.zone.parse('2010-07-05') From 0c5ef72c7da90a02d6d4ce370e5a78cf47046b12 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Tue, 5 Jan 2021 14:58:01 +0500 Subject: [PATCH 002/132] Add logging & domain lock on release --- app/models/concerns/domain/releasable.rb | 10 +++++++++- app/models/concerns/to_stdout.rb | 8 ++++++++ app/models/dns/domain_name.rb | 5 ++++- app/models/whois/record.rb | 6 ++++++ test/models/domain/releasable/auctionable_test.rb | 4 +++- 5 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 app/models/concerns/to_stdout.rb diff --git a/app/models/concerns/domain/releasable.rb b/app/models/concerns/domain/releasable.rb index 4aa5faa58..12a182b65 100644 --- a/app/models/concerns/domain/releasable.rb +++ b/app/models/concerns/domain/releasable.rb @@ -39,9 +39,12 @@ module Concerns def release if release_to_auction - transaction do + with_lock do + to_stdout "Checking if domain_name is auctionable: #{domain_name.auctionable?}" domain_name.sell_at_auction if domain_name.auctionable? + to_stdout 'Destroying domain' destroy! + to_stdout 'Sending registrar notification' registrar.notifications.create!(text: "#{I18n.t(:domain_deleted)}: #{name}", attached_obj_id: id, attached_obj_type: self.class) @@ -50,6 +53,11 @@ module Concerns discard end end + + def to_stdout(message) + time = Time.zone.now.utc + STDOUT << "#{time} - #{message}\n" unless Rails.env.test? + end end end end diff --git a/app/models/concerns/to_stdout.rb b/app/models/concerns/to_stdout.rb new file mode 100644 index 000000000..2a01ee668 --- /dev/null +++ b/app/models/concerns/to_stdout.rb @@ -0,0 +1,8 @@ +module ToStdout + extend ActiveSupport::Concern + + def to_stdout(message) + time = Time.zone.now.utc + STDOUT << "#{time} - #{message}\n" unless Rails.env.test? + end +end diff --git a/app/models/dns/domain_name.rb b/app/models/dns/domain_name.rb index c1af4d5e7..0daa7bbae 100644 --- a/app/models/dns/domain_name.rb +++ b/app/models/dns/domain_name.rb @@ -2,6 +2,7 @@ module DNS # Namespace is needed, because a class with the same name is defined by `domain_name` gem, # a dependency of `actionmailer`, class DomainName + include ToStdout def initialize(name) @name = name end @@ -36,6 +37,7 @@ module DNS auction = Auction.new auction.domain = name auction.start + to_stdout "Created the auction: #{auction.inspect}" update_whois_from_auction(auction) end @@ -100,7 +102,8 @@ module DNS whois_record = Whois::Record.find_or_create_by!(name: name) do |record| record.json = {} end - + to_stdout "Starting to update WHOIS record #{whois_record.inspect}\n\n"\ + "from auction #{auction.inspect}" whois_record.update_from_auction(auction) end end diff --git a/app/models/whois/record.rb b/app/models/whois/record.rb index 1d827e22a..b4f70c28f 100644 --- a/app/models/whois/record.rb +++ b/app/models/whois/record.rb @@ -1,24 +1,30 @@ module Whois class Record < Whois::Server + include ToStdout self.table_name = 'whois_records' def self.disclaimer Setting.registry_whois_disclaimer end + # rubocop:disable Metrics/AbcSize def update_from_auction(auction) if auction.started? update!(json: { name: auction.domain, status: ['AtAuction'], disclaimer: self.class.disclaimer }) + to_stdout "Updated from auction WHOIS record #{inspect}" elsif auction.no_bids? + to_stdout "Destroying WHOIS record #{inspect}" destroy! elsif auction.awaiting_payment? || auction.payment_received? update!(json: { name: auction.domain, status: ['PendingRegistration'], disclaimer: self.class.disclaimer, registration_deadline: auction.whois_deadline }) + to_stdout "Updated from auction WHOIS record #{inspect}" end end + # rubocop:enable Metrics/AbcSize end end diff --git a/test/models/domain/releasable/auctionable_test.rb b/test/models/domain/releasable/auctionable_test.rb index bb0485f7d..a74f41c90 100644 --- a/test/models/domain/releasable/auctionable_test.rb +++ b/test/models/domain/releasable/auctionable_test.rb @@ -25,6 +25,7 @@ class DomainReleasableAuctionableTest < ActiveSupport::TestCase def test_skips_auction_when_domains_is_blocked assert_equal 'shop.test', @domain.name blocked_domains(:one).update!(name: 'shop.test') + @domain.save!(validate: false) @domain.release @@ -34,6 +35,7 @@ class DomainReleasableAuctionableTest < ActiveSupport::TestCase def test_skips_auction_when_domains_is_reserved assert_equal 'shop.test', @domain.name reserved_domains(:one).update!(name: 'shop.test') + @domain.save!(validate: false) @domain.release @@ -58,7 +60,7 @@ class DomainReleasableAuctionableTest < ActiveSupport::TestCase end end - def test_updates_whois + def test_updates_whois_server @domain.update!(delete_date: '2010-07-04') travel_to Time.zone.parse('2010-07-05') From b60a7e571f01ee941780af8a90a8dc426b3aa04e Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Tue, 5 Jan 2021 17:21:13 +0500 Subject: [PATCH 003/132] Delete original WhoisRecord after domain deletion --- app/models/concerns/domain/releasable.rb | 20 +++++++++---------- app/models/domain.rb | 2 +- .../domain/releasable/auctionable_test.rb | 6 +++++- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/models/concerns/domain/releasable.rb b/app/models/concerns/domain/releasable.rb index 12a182b65..b800a4aa5 100644 --- a/app/models/concerns/domain/releasable.rb +++ b/app/models/concerns/domain/releasable.rb @@ -39,16 +39,16 @@ module Concerns def release if release_to_auction - with_lock do - to_stdout "Checking if domain_name is auctionable: #{domain_name.auctionable?}" - domain_name.sell_at_auction if domain_name.auctionable? - to_stdout 'Destroying domain' - destroy! - to_stdout 'Sending registrar notification' - registrar.notifications.create!(text: "#{I18n.t(:domain_deleted)}: #{name}", - attached_obj_id: id, - attached_obj_type: self.class) - end + lock! + to_stdout 'Destroying domain' + destroy! + to_stdout "Checking if domain_name is auctionable: #{domain_name.auctionable?}" + domain_name.sell_at_auction if domain_name.auctionable? + + to_stdout 'Sending registrar notification' + registrar.notifications.create!(text: "#{I18n.t(:domain_deleted)}: #{name}", + attached_obj_id: id, + attached_obj_type: self.class) else discard end diff --git a/app/models/domain.rb b/app/models/domain.rb index 49f18d9db..589a0b661 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -78,7 +78,7 @@ class Domain < ApplicationRecord true end - after_commit :update_whois_record, unless: -> { domain_name.at_auction? } + after_commit :update_whois_record after_create :update_reserved_domains def update_reserved_domains diff --git a/test/models/domain/releasable/auctionable_test.rb b/test/models/domain/releasable/auctionable_test.rb index a74f41c90..d24f46913 100644 --- a/test/models/domain/releasable/auctionable_test.rb +++ b/test/models/domain/releasable/auctionable_test.rb @@ -63,11 +63,15 @@ class DomainReleasableAuctionableTest < ActiveSupport::TestCase def test_updates_whois_server @domain.update!(delete_date: '2010-07-04') travel_to Time.zone.parse('2010-07-05') + old_whois = @domain.whois_record Domain.release_domains - whois_record = Whois::Record.find_by(name: @domain.name) + assert_raises ActiveRecord::RecordNotFound do + old_whois.reload + end + whois_record = Whois::Record.find_by(name: @domain.name) json = { "name"=>@domain.name, "status"=>["AtAuction"], "disclaimer"=> Setting.registry_whois_disclaimer } From 217f009fa3443cfe817ea6a9f72f479ba45677b8 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 6 Jan 2021 12:09:03 +0500 Subject: [PATCH 004/132] Small logic fixes --- app/models/concerns/domain/releasable.rb | 6 ------ app/models/domain.rb | 1 + 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/models/concerns/domain/releasable.rb b/app/models/concerns/domain/releasable.rb index b800a4aa5..51e1a6f1c 100644 --- a/app/models/concerns/domain/releasable.rb +++ b/app/models/concerns/domain/releasable.rb @@ -39,7 +39,6 @@ module Concerns def release if release_to_auction - lock! to_stdout 'Destroying domain' destroy! to_stdout "Checking if domain_name is auctionable: #{domain_name.auctionable?}" @@ -53,11 +52,6 @@ module Concerns discard end end - - def to_stdout(message) - time = Time.zone.now.utc - STDOUT << "#{time} - #{message}\n" unless Rails.env.test? - end end end end diff --git a/app/models/domain.rb b/app/models/domain.rb index 589a0b661..34a8c26ff 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -10,6 +10,7 @@ class Domain < ApplicationRecord include Concerns::Domain::RegistryLockable include Concerns::Domain::Releasable include Concerns::Domain::Disputable + include ToStdout attr_accessor :roles From 1d5c46e6a09f6ed96f9b28725de9629b01c08d99 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 6 Jan 2021 15:33:02 +0500 Subject: [PATCH 005/132] Move ToStdout to /app/lib folder and include it in app.rb --- app/{models/concerns => lib}/to_stdout.rb | 6 ++---- app/models/concerns/domain/releasable.rb | 6 +++--- app/models/dns/domain_name.rb | 7 +++---- app/models/domain.rb | 1 - app/models/whois/record.rb | 7 +++---- config/application.rb | 2 ++ 6 files changed, 13 insertions(+), 16 deletions(-) rename app/{models/concerns => lib}/to_stdout.rb (57%) diff --git a/app/models/concerns/to_stdout.rb b/app/lib/to_stdout.rb similarity index 57% rename from app/models/concerns/to_stdout.rb rename to app/lib/to_stdout.rb index 2a01ee668..eeab82c15 100644 --- a/app/models/concerns/to_stdout.rb +++ b/app/lib/to_stdout.rb @@ -1,7 +1,5 @@ -module ToStdout - extend ActiveSupport::Concern - - def to_stdout(message) +class ToStdout + def self.msg(message) time = Time.zone.now.utc STDOUT << "#{time} - #{message}\n" unless Rails.env.test? end diff --git a/app/models/concerns/domain/releasable.rb b/app/models/concerns/domain/releasable.rb index 51e1a6f1c..0a17b062a 100644 --- a/app/models/concerns/domain/releasable.rb +++ b/app/models/concerns/domain/releasable.rb @@ -39,12 +39,12 @@ module Concerns def release if release_to_auction - to_stdout 'Destroying domain' + ToStdout.msg 'Destroying domain' destroy! - to_stdout "Checking if domain_name is auctionable: #{domain_name.auctionable?}" + ToStdout.msg "Checking if domain_name is auctionable: #{domain_name.auctionable?}" domain_name.sell_at_auction if domain_name.auctionable? - to_stdout 'Sending registrar notification' + ToStdout.msg 'Sending registrar notification' registrar.notifications.create!(text: "#{I18n.t(:domain_deleted)}: #{name}", attached_obj_id: id, attached_obj_type: self.class) diff --git a/app/models/dns/domain_name.rb b/app/models/dns/domain_name.rb index 0daa7bbae..1e9cd6587 100644 --- a/app/models/dns/domain_name.rb +++ b/app/models/dns/domain_name.rb @@ -2,7 +2,6 @@ module DNS # Namespace is needed, because a class with the same name is defined by `domain_name` gem, # a dependency of `actionmailer`, class DomainName - include ToStdout def initialize(name) @name = name end @@ -37,7 +36,7 @@ module DNS auction = Auction.new auction.domain = name auction.start - to_stdout "Created the auction: #{auction.inspect}" + ToStdout.msg "Created the auction: #{auction.inspect}" update_whois_from_auction(auction) end @@ -102,8 +101,8 @@ module DNS whois_record = Whois::Record.find_or_create_by!(name: name) do |record| record.json = {} end - to_stdout "Starting to update WHOIS record #{whois_record.inspect}\n\n"\ - "from auction #{auction.inspect}" + ToStdout.msg "Starting to update WHOIS record #{whois_record.inspect}\n\n"\ + "from auction #{auction.inspect}" whois_record.update_from_auction(auction) end end diff --git a/app/models/domain.rb b/app/models/domain.rb index 34a8c26ff..589a0b661 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -10,7 +10,6 @@ class Domain < ApplicationRecord include Concerns::Domain::RegistryLockable include Concerns::Domain::Releasable include Concerns::Domain::Disputable - include ToStdout attr_accessor :roles diff --git a/app/models/whois/record.rb b/app/models/whois/record.rb index b4f70c28f..1501381a3 100644 --- a/app/models/whois/record.rb +++ b/app/models/whois/record.rb @@ -1,6 +1,5 @@ module Whois class Record < Whois::Server - include ToStdout self.table_name = 'whois_records' def self.disclaimer @@ -13,16 +12,16 @@ module Whois update!(json: { name: auction.domain, status: ['AtAuction'], disclaimer: self.class.disclaimer }) - to_stdout "Updated from auction WHOIS record #{inspect}" + ToStdout.msg "Updated from auction WHOIS record #{inspect}" elsif auction.no_bids? - to_stdout "Destroying WHOIS record #{inspect}" + ToStdout.msg "Destroying WHOIS record #{inspect}" destroy! elsif auction.awaiting_payment? || auction.payment_received? update!(json: { name: auction.domain, status: ['PendingRegistration'], disclaimer: self.class.disclaimer, registration_deadline: auction.whois_deadline }) - to_stdout "Updated from auction WHOIS record #{inspect}" + ToStdout.msg "Updated from auction WHOIS record #{inspect}" end end # rubocop:enable Metrics/AbcSize diff --git a/config/application.rb b/config/application.rb index a5fb17c9d..014c03269 100644 --- a/config/application.rb +++ b/config/application.rb @@ -36,8 +36,10 @@ module DomainNameRegistry # Autoload all model subdirs config.autoload_paths += Dir[Rails.root.join('app', 'models', '**/')] + config.autoload_paths += Dir[Rails.root.join('app', 'lib', '**/')] config.autoload_paths += Dir[Rails.root.join('app', 'interactions', '**/')] config.eager_load_paths << config.root.join('lib', 'validators') + config.eager_load_paths << config.root.join('app', 'lib') config.watchable_dirs['lib'] = %i[rb] config.active_record.schema_format = :sql From 59ddc5acce3ae10b4a7095e09334464ca79800e1 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Fri, 15 Jan 2021 15:32:40 +0500 Subject: [PATCH 006/132] Turn off removing auctioned Whois::Record --- app/models/whois/record.rb | 6 ++++++ app/models/whois_record.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/whois/record.rb b/app/models/whois/record.rb index 1501381a3..dc9cc2ba0 100644 --- a/app/models/whois/record.rb +++ b/app/models/whois/record.rb @@ -2,6 +2,12 @@ module Whois class Record < Whois::Server self.table_name = 'whois_records' + def self.without_auctions + ids = Whois::Record.all.select { |record| Auction.where(domain: record.name).blank? } + .pluck(:id) + Whois::Record.where(id: ids) + end + def self.disclaimer Setting.registry_whois_disclaimer end diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb index 3563b9630..19805d583 100644 --- a/app/models/whois_record.rb +++ b/app/models/whois_record.rb @@ -97,7 +97,7 @@ class WhoisRecord < ApplicationRecord end def destroy_whois_record - Whois::Record.where(name: name).delete_all + Whois::Record.without_auctions.where(name: name).delete_all end private From 0c1c015fc9e3eef1b6d912e2a5116a993168f3df Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 15 Jan 2021 16:15:31 +0200 Subject: [PATCH 007/132] Wrote test for admin users --- .../admin_area/admin_users_test.rb | 78 +++++++++++++++++++ .../api/v1/registrant/contacts/list_test.rb | 37 +++++++++ .../api/v1/registrant/contacts/update_test.rb | 44 ++++++++++- test/models/domain_test.rb | 6 ++ 4 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 test/integration/admin_area/admin_users_test.rb diff --git a/test/integration/admin_area/admin_users_test.rb b/test/integration/admin_area/admin_users_test.rb new file mode 100644 index 000000000..ffc4bfd14 --- /dev/null +++ b/test/integration/admin_area/admin_users_test.rb @@ -0,0 +1,78 @@ +require 'test_helper' +require 'application_system_test_case' + +class AdminAreaAdminUsersIntegrationTest < ApplicationSystemTestCase + include Devise::Test::IntegrationHelpers + include ActionView::Helpers::NumberHelper + + setup do + @original_default_language = Setting.default_language + sign_in users(:admin) + end + + # "/admin/admin_users" + def test_create_new_admin_user + visit admin_admin_users_path + click_on 'New admin user' + + fill_in 'Username', with: 'test_user_name' + fill_in 'Password', with: 'test_password' + fill_in 'Password confirmation', with: 'test_password' + fill_in 'Identity code', with: '38903110313' + fill_in 'Email', with: 'oleg@tester.ee' + + select 'Estonia', from: 'admin_user_country_code', match: :first + select 'User', from: 'admin_user_roles_', match: :first + + click_on 'Save' + assert_text 'Record created' + end + + # "/admin/admin_users" + def test_create_with_invalid_data_new_admin_user + visit admin_admin_users_path + click_on 'New admin user' + + fill_in 'Username', with: 'test_user_name' + fill_in 'Password', with: 'test_password' + fill_in 'Password confirmation', with: 'test_password2' + fill_in 'Identity code', with: '38903110313' + fill_in 'Email', with: 'oleg@tester.ee' + + select 'Estonia', from: 'admin_user_country_code', match: :first + select 'User', from: 'admin_user_roles_', match: :first + + click_on 'Save' + assert_text 'Failed to create record' + end + + def test_edit_successfully_exist_record + visit admin_admin_users_path + click_on 'New admin user' + + fill_in 'Username', with: 'test_user_name' + fill_in 'Password', with: 'test_password' + fill_in 'Password confirmation', with: 'test_password' + fill_in 'Identity code', with: '38903110313' + fill_in 'Email', with: 'oleg@tester.ee' + + select 'Estonia', from: 'admin_user_country_code', match: :first + select 'User', from: 'admin_user_roles_', match: :first + + click_on 'Save' + assert_text 'Record created' + + visit admin_admin_users_path + click_on 'test_user_name' + + assert_text 'General' + click_on 'Edit' + + fill_in 'Password', with: 'test_password' + fill_in 'Password confirmation', with: 'test_password' + + click_on 'Save' + assert_text 'Record updated' + + end +end \ No newline at end of file diff --git a/test/integration/api/v1/registrant/contacts/list_test.rb b/test/integration/api/v1/registrant/contacts/list_test.rb index 2389019f1..33e8b67eb 100644 --- a/test/integration/api/v1/registrant/contacts/list_test.rb +++ b/test/integration/api/v1/registrant/contacts/list_test.rb @@ -1,5 +1,6 @@ require 'test_helper' require 'auth_token/auth_token_creator' +require 'json' CompanyRegisterClientStub = Struct.new(:any_method) do def representation_rights(citizen_personal_code:, citizen_country_code:) @@ -55,6 +56,42 @@ class RegistrantApiV1ContactListTest < ActionDispatch::IntegrationTest assert_equal '1234', response_json.first[:ident][:code] end + def test_out_of_range_limit + get api_v1_registrant_contacts_path + "?limit=300", as: :json, headers: { 'HTTP_AUTHORIZATION' => auth_token } + response_json = JSON.parse(response.body, symbolize_names: true) + + text_response = JSON.pretty_generate(response_json[:errors][0][:limit][0]) + + assert_equal text_response, '"parameter is out of range"' + end + + def test_negative_offset + get api_v1_registrant_contacts_path + "?offset=-300", as: :json, headers: { 'HTTP_AUTHORIZATION' => auth_token } + response_json = JSON.parse(response.body, symbolize_names: true) + + text_response = JSON.pretty_generate(response_json[:errors][0][:offset][0]) + + assert_equal text_response, '"parameter is out of range"' + end + + def test_show_valid_contact + get api_v1_registrant_contacts_path + "/eb2f2766-b44c-4e14-9f16-32ab1a7cb957", as: :json, headers: { 'HTTP_AUTHORIZATION' => auth_token } + response_json = JSON.parse(response.body, symbolize_names: true) + + text_response = response_json[:name] + + assert_equal @contact[:name], text_response + end + + def test_show_invalid_contact + get api_v1_registrant_contacts_path + "/435", as: :json, headers: { 'HTTP_AUTHORIZATION' => auth_token } + response_json = JSON.parse(response.body, symbolize_names: true) + + text_response = response_json[:errors][0][:base][0] + + assert_equal text_response, 'Contact not found' + end + private def delete_direct_contact diff --git a/test/integration/api/v1/registrant/contacts/update_test.rb b/test/integration/api/v1/registrant/contacts/update_test.rb index 4ddf8b0ff..c1eaa005c 100644 --- a/test/integration/api/v1/registrant/contacts/update_test.rb +++ b/test/integration/api/v1/registrant/contacts/update_test.rb @@ -4,11 +4,12 @@ require 'auth_token/auth_token_creator' class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest setup do @contact = contacts(:john) + @contact_org = contacts(:acme_ltd) @original_address_processing = Setting.address_processing @original_fax_enabled_setting = ENV['fax_enabled'] - @user = users(:registrant) + end teardown do @@ -90,6 +91,32 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest @contact.address end + def test_update_address_when_enabled_without_address_params + Setting.address_processing = true + + patch api_v1_registrant_contact_path(@contact.uuid), params: { address: { } }, + as: :json, + headers: { 'HTTP_AUTHORIZATION' => auth_token } + + assert_response :bad_request + @contact.reload + assert_equal Contact::Address.new(nil, nil, nil, nil, nil), + @contact.address + end + + def test_update_address_when_enabled_without_address_params + Setting.address_processing = true + + patch api_v1_registrant_contact_path(@contact.uuid), params: { }, + as: :json, + headers: { 'HTTP_AUTHORIZATION' => auth_token } + + assert_response :bad_request + @contact.reload + assert_equal Contact::Address.new(nil, nil, nil, nil, nil), + @contact.address + end + def test_address_is_optional_when_enabled Setting.address_processing = true @contact.update!(street: 'any', zip: 'any', city: 'any', state: 'any', country_code: 'US') @@ -211,6 +238,21 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest symbolize_names: true) end + def test_org_disclosed_attributes + patch api_v1_registrant_contact_path(@contact_org.uuid), params: { disclosed_attributes: ["some_attr"] }, + as: :json, + headers: { 'HTTP_AUTHORIZATION' => auth_token } + + assert_response :bad_request + + err_msg = "Legal person's data is visible by default and cannot be concealed. Please remove this parameter." + + response_json = JSON.parse(response.body, symbolize_names: true) + response_msg = response_json[:errors][0][:disclosed_attributes][0] + + assert_equal err_msg, response_msg + end + def test_unmanaged_contact_cannot_be_updated assert_equal 'US-1234', @user.registrant_ident @contact.update!(ident: '12345') diff --git a/test/models/domain_test.rb b/test/models/domain_test.rb index ae12f4a1e..15ab8b0c2 100644 --- a/test/models/domain_test.rb +++ b/test/models/domain_test.rb @@ -69,6 +69,12 @@ class DomainTest < ActiveSupport::TestCase domain.name = 'xn--mnchen-3ya.test' assert domain.valid? + + domain.name = '####' + assert domain.invalid? + + domain.name = 'https://example.test' + assert domain.invalid? end def test_invalid_when_name_is_already_taken From 571755ffc39719c1d4ec1c60488a63e481181772 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 15 Jan 2021 17:12:04 +0200 Subject: [PATCH 008/132] add new tests for admin users --- test/application_system_test_case.rb | 7 ++- .../admin_area/admin_users_test.rb | 63 ++++++++++++++++++- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index b31489691..bf54aa11b 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -13,6 +13,7 @@ class ApplicationSystemTestCase < ActionDispatch::IntegrationTest WebMock.reset! Capybara.reset_sessions! Capybara.use_default_driver + end end @@ -28,17 +29,21 @@ class JavaScriptApplicationSystemTestCase < ApplicationSystemTestCase options.add_argument('--disable-dev-shm-usage') options.add_argument('--window-size=1400,1400') + + Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) + Capybara.exact = true end Capybara.server = :puma, { Silent: true } def setup DatabaseCleaner.start - + super Capybara.current_driver = :chrome + end def teardown diff --git a/test/integration/admin_area/admin_users_test.rb b/test/integration/admin_area/admin_users_test.rb index ffc4bfd14..aefff2f3a 100644 --- a/test/integration/admin_area/admin_users_test.rb +++ b/test/integration/admin_area/admin_users_test.rb @@ -6,10 +6,13 @@ class AdminAreaAdminUsersIntegrationTest < ApplicationSystemTestCase include ActionView::Helpers::NumberHelper setup do + @original_default_language = Setting.default_language sign_in users(:admin) end + # option_select = '//div[@class="selectize-input items has-options full has-items"]' + # "/admin/admin_users" def test_create_new_admin_user visit admin_admin_users_path @@ -73,6 +76,64 @@ class AdminAreaAdminUsersIntegrationTest < ApplicationSystemTestCase click_on 'Save' assert_text 'Record updated' - end + + def test_edit_exist_record_with_invalid_data + visit admin_admin_users_path + click_on 'New admin user' + + fill_in 'Username', with: 'test_user_name' + fill_in 'Password', with: 'test_password' + fill_in 'Password confirmation', with: 'test_password' + fill_in 'Identity code', with: '38903110313' + fill_in 'Email', with: 'oleg@tester.ee' + + select 'Estonia', from: 'admin_user_country_code', match: :first + select 'User', from: 'admin_user_roles_', match: :first + + click_on 'Save' + assert_text 'Record created' + + visit admin_admin_users_path + click_on 'test_user_name' + + assert_text 'General' + click_on 'Edit' + + fill_in 'Password', with: 'test_password' + fill_in 'Password confirmation', with: 'test_password2' + + click_on 'Save' + assert_text 'Failed to update record' + end + + # TODO + # def test_delete_exist_record + # visit admin_admin_users_path + # click_on 'New admin user' + + # fill_in 'Username', with: 'test_user_name' + # fill_in 'Password', with: 'test_password' + # fill_in 'Password confirmation', with: 'test_password' + # fill_in 'Identity code', with: '38903110313' + # fill_in 'Email', with: 'oleg@tester.ee' + + # select 'Estonia', from: 'admin_user_country_code', match: :first + # select 'User', from: 'admin_user_roles_', match: :first + + # click_on 'Save' + # assert_text 'Record created' + + # visit admin_admin_users_path + # click_on 'test_user_name' + + # assert_text 'General' + # click_on 'Delete' + + # accept_prompt(with: 'Are you sure?') do + # click_link('Ok') + # end + + # assert_text ' Record deleted' + # end end \ No newline at end of file From 8fe9e46fc9484612eae199c6471674c672a7786e Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Sat, 16 Jan 2021 22:12:23 +0200 Subject: [PATCH 009/132] covered ui test for admin users page --- test/application_system_test_case.rb | 2 +- .../admin_area/admin_users_test.rb | 122 +++++++----------- 2 files changed, 46 insertions(+), 78 deletions(-) diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index bf54aa11b..ec5fa02c7 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -32,7 +32,7 @@ class JavaScriptApplicationSystemTestCase < ApplicationSystemTestCase Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) - Capybara.exact = true + end Capybara.server = :puma, { Silent: true } diff --git a/test/integration/admin_area/admin_users_test.rb b/test/integration/admin_area/admin_users_test.rb index aefff2f3a..f18a58c96 100644 --- a/test/integration/admin_area/admin_users_test.rb +++ b/test/integration/admin_area/admin_users_test.rb @@ -1,69 +1,65 @@ require 'test_helper' require 'application_system_test_case' -class AdminAreaAdminUsersIntegrationTest < ApplicationSystemTestCase +class AdminAreaAdminUsersIntegrationTest < JavaScriptApplicationSystemTestCase include Devise::Test::IntegrationHelpers include ActionView::Helpers::NumberHelper setup do - + WebMock.allow_net_connect! @original_default_language = Setting.default_language sign_in users(:admin) end - # option_select = '//div[@class="selectize-input items has-options full has-items"]' - - # "/admin/admin_users" - def test_create_new_admin_user + # Helpers funcs + def createNewAdminUser(valid) visit admin_admin_users_path click_on 'New admin user' fill_in 'Username', with: 'test_user_name' - fill_in 'Password', with: 'test_password' - fill_in 'Password confirmation', with: 'test_password' + # If valid=true creating valid user, if else, then with invalid data + if valid + fill_in 'Password', with: 'test_password' + fill_in 'Password confirmation', with: 'test_password' + else + fill_in 'Password', with: 'test_password' + fill_in 'Password confirmation', with: 'test_password2' + end fill_in 'Identity code', with: '38903110313' fill_in 'Email', with: 'oleg@tester.ee' select 'Estonia', from: 'admin_user_country_code', match: :first - select 'User', from: 'admin_user_roles_', match: :first + + # option_select = '//div[@class="selectize-input items has-options full has-items"]' + # find(:xpath, ".//table/tr").click + # select 'User', from: 'admin_user_roles_', match: :first + select_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[1]") + select_element.click + + # /html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[2]/div/div[1] + option_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[2]/div/div[1]") + option_element.click click_on 'Save' - assert_text 'Record created' + if valid + assert_text 'Record created' + else + assert_text 'Failed to create record' + end end + # Tests # "/admin/admin_users" + def test_create_new_admin_user + createNewAdminUser(true) + end + def test_create_with_invalid_data_new_admin_user - visit admin_admin_users_path - click_on 'New admin user' - - fill_in 'Username', with: 'test_user_name' - fill_in 'Password', with: 'test_password' - fill_in 'Password confirmation', with: 'test_password2' - fill_in 'Identity code', with: '38903110313' - fill_in 'Email', with: 'oleg@tester.ee' - - select 'Estonia', from: 'admin_user_country_code', match: :first - select 'User', from: 'admin_user_roles_', match: :first - - click_on 'Save' - assert_text 'Failed to create record' + createNewAdminUser(false) end def test_edit_successfully_exist_record - visit admin_admin_users_path - click_on 'New admin user' - - fill_in 'Username', with: 'test_user_name' - fill_in 'Password', with: 'test_password' - fill_in 'Password confirmation', with: 'test_password' - fill_in 'Identity code', with: '38903110313' - fill_in 'Email', with: 'oleg@tester.ee' - - select 'Estonia', from: 'admin_user_country_code', match: :first - select 'User', from: 'admin_user_roles_', match: :first - - click_on 'Save' - assert_text 'Record created' + createNewAdminUser(true) visit admin_admin_users_path click_on 'test_user_name' @@ -79,20 +75,7 @@ class AdminAreaAdminUsersIntegrationTest < ApplicationSystemTestCase end def test_edit_exist_record_with_invalid_data - visit admin_admin_users_path - click_on 'New admin user' - - fill_in 'Username', with: 'test_user_name' - fill_in 'Password', with: 'test_password' - fill_in 'Password confirmation', with: 'test_password' - fill_in 'Identity code', with: '38903110313' - fill_in 'Email', with: 'oleg@tester.ee' - - select 'Estonia', from: 'admin_user_country_code', match: :first - select 'User', from: 'admin_user_roles_', match: :first - - click_on 'Save' - assert_text 'Record created' + createNewAdminUser(true) visit admin_admin_users_path click_on 'test_user_name' @@ -107,33 +90,18 @@ class AdminAreaAdminUsersIntegrationTest < ApplicationSystemTestCase assert_text 'Failed to update record' end - # TODO - # def test_delete_exist_record - # visit admin_admin_users_path - # click_on 'New admin user' + def test_delete_exist_record + createNewAdminUser(true) - # fill_in 'Username', with: 'test_user_name' - # fill_in 'Password', with: 'test_password' - # fill_in 'Password confirmation', with: 'test_password' - # fill_in 'Identity code', with: '38903110313' - # fill_in 'Email', with: 'oleg@tester.ee' + visit admin_admin_users_path + click_on 'test_user_name' - # select 'Estonia', from: 'admin_user_country_code', match: :first - # select 'User', from: 'admin_user_roles_', match: :first + assert_text 'General' + click_on 'Delete' - # click_on 'Save' - # assert_text 'Record created' + # Accept to delete in modal window + page.driver.browser.switch_to.alert.accept - # visit admin_admin_users_path - # click_on 'test_user_name' - - # assert_text 'General' - # click_on 'Delete' - - # accept_prompt(with: 'Are you sure?') do - # click_link('Ok') - # end - - # assert_text ' Record deleted' - # end + assert_text 'Record deleted' + end end \ No newline at end of file From db22f48990d3ec6341909b5f01b384c0ab788778 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Mon, 18 Jan 2021 13:35:35 +0200 Subject: [PATCH 010/132] covered blocked_domains with test, started account_activities --- .../admin_area/account_activities_test.rb | 18 +++++ .../admin_area/admin_users_test.rb | 7 +- .../admin_area/blocked_domains_test.rb | 74 +++++++++++++++++++ 3 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 test/integration/admin_area/account_activities_test.rb create mode 100644 test/integration/admin_area/blocked_domains_test.rb diff --git a/test/integration/admin_area/account_activities_test.rb b/test/integration/admin_area/account_activities_test.rb new file mode 100644 index 000000000..f0d1e5869 --- /dev/null +++ b/test/integration/admin_area/account_activities_test.rb @@ -0,0 +1,18 @@ +require 'test_helper' +require 'application_system_test_case' + +class AdminAreaAccountActivitiesIntegrationTest < ApplicationSystemTestCase + # /admin/account_activities + include Devise::Test::IntegrationHelpers + include ActionView::Helpers::NumberHelper + + setup do + sign_in users(:admin) + @original_default_language = Setting.default_language + end + + + # TESTS + # TODO + +end \ No newline at end of file diff --git a/test/integration/admin_area/admin_users_test.rb b/test/integration/admin_area/admin_users_test.rb index f18a58c96..74baee55e 100644 --- a/test/integration/admin_area/admin_users_test.rb +++ b/test/integration/admin_area/admin_users_test.rb @@ -30,17 +30,16 @@ class AdminAreaAdminUsersIntegrationTest < JavaScriptApplicationSystemTestCase select 'Estonia', from: 'admin_user_country_code', match: :first - # option_select = '//div[@class="selectize-input items has-options full has-items"]' - # find(:xpath, ".//table/tr").click - # select 'User', from: 'admin_user_roles_', match: :first + # '//div[@class="selectize-input items has-options full has-items"]' select_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[1]") select_element.click - # /html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[2]/div/div[1] option_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[2]/div/div[1]") option_element.click click_on 'Save' + + # if user created with valid data then record successfuly, else it failed if valid assert_text 'Record created' else diff --git a/test/integration/admin_area/blocked_domains_test.rb b/test/integration/admin_area/blocked_domains_test.rb new file mode 100644 index 000000000..8f8b99cc8 --- /dev/null +++ b/test/integration/admin_area/blocked_domains_test.rb @@ -0,0 +1,74 @@ +require 'test_helper' +require 'application_system_test_case' + + +# /admin/blocked_domains +class AdminAreaBlockedDomainsIntegrationTest < JavaScriptApplicationSystemTestCase + setup do + WebMock.allow_net_connect! + sign_in users(:admin) + @domain = domains(:shop) + @blocked_domain = blocked_domains(:one) + end + + # HELPERS + def visit_admin_blocked_domains_path + visit admin_blocked_domains_path + assert_text 'Blocked domains' + end + + def add_domain_into_blocked_list(value) + click_on 'New blocked domain' + assert_text 'Add domain to blocked list' + + fill_in 'Name', with: @domain.name + click_on 'Save' + + return assert_text 'Domain added!' if value + return assert_text 'Failed to add domain!' + end + + # ------------------------------------------------------------ + # TESTs + def test_page_successfully_loaded + visit_admin_blocked_domains_path + end + + def test_add_into_blocked_list + visit_admin_blocked_domains_path + add_domain_into_blocked_list(true) + end + + def test_add_into_blocked_list_same_domain + visit_admin_blocked_domains_path + add_domain_into_blocked_list(true) + add_domain_into_blocked_list(false) + end + + def test_delete_domain_from_blocked_list + visit_admin_blocked_domains_path + add_domain_into_blocked_list(true) + + click_link_or_button 'Delete', match: :first + + # Accept to delete in modal window + page.driver.browser.switch_to.alert.accept + + assert_text 'Domain deleted!' + end + + def test_find_blocked_domain_from_blocked_list + visit_admin_blocked_domains_path + add_domain_into_blocked_list(true) + + fill_in 'Name', with: @domain.name + find(:xpath, "//span[@class='glyphicon glyphicon-search']").click + + assert_text @domain.name + end + + def test_set_domain + assert_equal @blocked_domain.name, BlockedDomain.find(name: @blocked_domain.name) + end + +end \ No newline at end of file From a67c457520ff772d43c976009f407c09a996ae9a Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Mon, 18 Jan 2021 14:53:28 +0200 Subject: [PATCH 011/132] little fix --- test/integration/admin_area/blocked_domains_test.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/integration/admin_area/blocked_domains_test.rb b/test/integration/admin_area/blocked_domains_test.rb index 8f8b99cc8..a03848c35 100644 --- a/test/integration/admin_area/blocked_domains_test.rb +++ b/test/integration/admin_area/blocked_domains_test.rb @@ -67,8 +67,4 @@ class AdminAreaBlockedDomainsIntegrationTest < JavaScriptApplicationSystemTestCa assert_text @domain.name end - def test_set_domain - assert_equal @blocked_domain.name, BlockedDomain.find(name: @blocked_domain.name) - end - end \ No newline at end of file From 512d4137e8536bdec12d944016256431aa7eb279 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Mon, 18 Jan 2021 17:20:36 +0200 Subject: [PATCH 012/132] Started covering certificate --- .../admin_area/certificates_test.rb | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 test/integration/admin_area/certificates_test.rb diff --git a/test/integration/admin_area/certificates_test.rb b/test/integration/admin_area/certificates_test.rb new file mode 100644 index 000000000..bff9c346d --- /dev/null +++ b/test/integration/admin_area/certificates_test.rb @@ -0,0 +1,69 @@ +require 'test_helper' +require 'application_system_test_case' + +class AdminAreaCertificatesIntegrationTest < JavaScriptApplicationSystemTestCase + + # admin_api_user_certificates + # /admin/api_users/:api_user_id/ + # /admin/api_users/:api_user_id/certificates + + setup do + WebMock.allow_net_connect! + sign_in users(:admin) + + @apiuser = users(:api_bestnames) + @certificate = certificates(:api) + # @certificate.update!(csr: "-----BEGIN CERTIFICATE REQUEST----- + # MIICszCCAZsCAQAwbjELMAkGA1UEBhMCRUUxFDASBgNVBAMMC2ZyZXNoYm94LmVl + # MRAwDgYDVQQHDAdUYWxsaW5uMREwDwYDVQQKDAhGcmVzaGJveDERMA8GA1UECAwI + # SGFyanVtYWExETAPBgNVBAsMCEZyZXNoYm94MIIBIjANBgkqhkiG9w0BAQEFAAOC + # AQ8AMIIBCgKCAQEA1VVESynZoZhIbe8s9zHkELZ/ZDCGiM2Q8IIGb1IOieT5U2mx + # IsVXz85USYsSQY9+4YdEXnupq9fShArT8pstS/VN6BnxdfAiYXc3UWWAuaYAdNGJ + # Dr5Jf6uMt1wVnCgoDL7eJq9tWMwARC/viT81o92fgqHFHW0wEolfCmnpik9o0ACD + # FiWZ9IBIevmFqXtq25v9CY2cT9+eZW127WtJmOY/PKJhzh0QaEYHqXTHWOLZWpnp + # HH4elyJ2CrFulOZbHPkPNB9Nf4XQjzk1ffoH6e5IVys2VV5xwcTkF0jY5XTROVxX + # lR2FWqic8Q2pIhSks48+J6o1GtXGnTxv94lSDwIDAQABoAAwDQYJKoZIhvcNAQEL + # BQADggEBAEFcYmQvcAC8773eRTWBJJNoA4kRgoXDMYiiEHih5iJPVSxfidRwYDTF + # sP+ttNTUg3JocFHY75kuM9T2USh+gu/trRF0o4WWa+AbK3JbbdjdT1xOMn7XtfUU + # Z/f1XCS9YdHQFCA6nk4Z+TLWwYsgk7n490AQOiB213fa1UIe83qIfw/3GRqRUZ7U + # wIWEGsHED5WT69GyxjyKHcqGoV7uFnqFN0sQVKVTy/NFRVQvtBUspCbsOirdDRie + # AB2KbGHL+t1QrRF10szwCJDyk5aYlVhxvdI8zn010nrxHkiyQpDFFldDMLJl10BW + # 2w9PGO061z+tntdRcKQGuEpnIr9U5Vs= + # -----END CERTIFICATE REQUEST----\n") + end + + # Helpers + def show_certificate_info + visit admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id) + assert_text 'Certificates' + end + + # Tests + def test_show_certificate_info + show_certificate_info + end + + def test_destroy_certificate + show_certificate_info + find(:xpath, "//a[text()='Delete']").click + + page.driver.browser.switch_to.alert.accept + + assert_text 'Record deleted' + end + + # TODO + # Should be display "Revoke this certificate" button + + # def test_revoke_certificate + # show_certificate_info + + # element = find(:xpath, "//body/div[2]").native.attribute('outerHTML') + # puts element + + # # find(:xpath, "/html/body/div[2]/div[5]/div/div/div[1]/div[2]/a[2]").click + + # # assert_text 'Record deleted' + # end + +end \ No newline at end of file From a5f8e277ddfd01fac63e9c0bc2e04b07216d4001 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Tue, 19 Jan 2021 11:53:00 +0200 Subject: [PATCH 013/132] covered white_ips and covered a little certificates --- .../admin_area/certificates_test.rb | 60 ++++++----- test/integration/admin_area/white_ips_test.rb | 101 ++++++++++++++++++ 2 files changed, 133 insertions(+), 28 deletions(-) create mode 100644 test/integration/admin_area/white_ips_test.rb diff --git a/test/integration/admin_area/certificates_test.rb b/test/integration/admin_area/certificates_test.rb index bff9c346d..e056274b5 100644 --- a/test/integration/admin_area/certificates_test.rb +++ b/test/integration/admin_area/certificates_test.rb @@ -13,32 +13,16 @@ class AdminAreaCertificatesIntegrationTest < JavaScriptApplicationSystemTestCase @apiuser = users(:api_bestnames) @certificate = certificates(:api) - # @certificate.update!(csr: "-----BEGIN CERTIFICATE REQUEST----- - # MIICszCCAZsCAQAwbjELMAkGA1UEBhMCRUUxFDASBgNVBAMMC2ZyZXNoYm94LmVl - # MRAwDgYDVQQHDAdUYWxsaW5uMREwDwYDVQQKDAhGcmVzaGJveDERMA8GA1UECAwI - # SGFyanVtYWExETAPBgNVBAsMCEZyZXNoYm94MIIBIjANBgkqhkiG9w0BAQEFAAOC - # AQ8AMIIBCgKCAQEA1VVESynZoZhIbe8s9zHkELZ/ZDCGiM2Q8IIGb1IOieT5U2mx - # IsVXz85USYsSQY9+4YdEXnupq9fShArT8pstS/VN6BnxdfAiYXc3UWWAuaYAdNGJ - # Dr5Jf6uMt1wVnCgoDL7eJq9tWMwARC/viT81o92fgqHFHW0wEolfCmnpik9o0ACD - # FiWZ9IBIevmFqXtq25v9CY2cT9+eZW127WtJmOY/PKJhzh0QaEYHqXTHWOLZWpnp - # HH4elyJ2CrFulOZbHPkPNB9Nf4XQjzk1ffoH6e5IVys2VV5xwcTkF0jY5XTROVxX - # lR2FWqic8Q2pIhSks48+J6o1GtXGnTxv94lSDwIDAQABoAAwDQYJKoZIhvcNAQEL - # BQADggEBAEFcYmQvcAC8773eRTWBJJNoA4kRgoXDMYiiEHih5iJPVSxfidRwYDTF - # sP+ttNTUg3JocFHY75kuM9T2USh+gu/trRF0o4WWa+AbK3JbbdjdT1xOMn7XtfUU - # Z/f1XCS9YdHQFCA6nk4Z+TLWwYsgk7n490AQOiB213fa1UIe83qIfw/3GRqRUZ7U - # wIWEGsHED5WT69GyxjyKHcqGoV7uFnqFN0sQVKVTy/NFRVQvtBUspCbsOirdDRie - # AB2KbGHL+t1QrRF10szwCJDyk5aYlVhxvdI8zn010nrxHkiyQpDFFldDMLJl10BW - # 2w9PGO061z+tntdRcKQGuEpnIr9U5Vs= - # -----END CERTIFICATE REQUEST----\n") + @certificate.update!(csr: "-----BEGIN CERTIFICATE REQUEST-----\nMIICszCCAZsCAQAwbjELMAkGA1UEBhMCRUUxFDASBgNVBAMMC2ZyZXNoYm94LmVl\nMRAwDgYDVQQHDAdUYWxsaW5uMREwDwYDVQQKDAhGcmVzaGJveDERMA8GA1UECAwI\nSGFyanVtYWExETAPBgNVBAsMCEZyZXNoYm94MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEA1VVESynZoZhIbe8s9zHkELZ/ZDCGiM2Q8IIGb1IOieT5U2mx\nIsVXz85USYsSQY9+4YdEXnupq9fShArT8pstS/VN6BnxdfAiYXc3UWWAuaYAdNGJ\nDr5Jf6uMt1wVnCgoDL7eJq9tWMwARC/viT81o92fgqHFHW0wEolfCmnpik9o0ACD\nFiWZ9IBIevmFqXtq25v9CY2cT9+eZW127WtJmOY/PKJhzh0QaEYHqXTHWOLZWpnp\nHH4elyJ2CrFulOZbHPkPNB9Nf4XQjzk1ffoH6e5IVys2VV5xwcTkF0jY5XTROVxX\nlR2FWqic8Q2pIhSks48+J6o1GtXGnTxv94lSDwIDAQABoAAwDQYJKoZIhvcNAQEL\nBQADggEBAEFcYmQvcAC8773eRTWBJJNoA4kRgoXDMYiiEHih5iJPVSxfidRwYDTF\nsP+ttNTUg3JocFHY75kuM9T2USh+gu/trRF0o4WWa+AbK3JbbdjdT1xOMn7XtfUU\nZ/f1XCS9YdHQFCA6nk4Z+TLWwYsgk7n490AQOiB213fa1UIe83qIfw/3GRqRUZ7U\nwIWEGsHED5WT69GyxjyKHcqGoV7uFnqFN0sQVKVTy/NFRVQvtBUspCbsOirdDRie\nAB2KbGHL+t1QrRF10szwCJDyk5aYlVhxvdI8zn010nrxHkiyQpDFFldDMLJl10BW\n2w9PGO061z+tntdRcKQGuEpnIr9U5Vs=\n-----END CERTIFICATE REQUEST-----\n") end - # Helpers + # Helpers ======================= def show_certificate_info visit admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id) assert_text 'Certificates' end - # Tests + # TESTs =========================== def test_show_certificate_info show_certificate_info end @@ -52,18 +36,38 @@ class AdminAreaCertificatesIntegrationTest < JavaScriptApplicationSystemTestCase assert_text 'Record deleted' end - # TODO - # Should be display "Revoke this certificate" button + # download_csr_admin_api_user_certificate GET /admin/api_users/:api_user_id/certificates/:id/download_csr(.:format) + def test_download_csr + get download_csr_admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id) - # def test_revoke_certificate - # show_certificate_info + assert_response :ok + assert_equal 'application/octet-stream', response.headers['Content-Type'] + assert_equal "attachment; filename=\"test_bestnames.csr.pem\"; filename*=UTF-8''test_bestnames.csr.pem", response.headers['Content-Disposition'] + assert_not_empty response.body + end - # element = find(:xpath, "//body/div[2]").native.attribute('outerHTML') - # puts element + # download_crt_admin_api_user_certificate GET /admin/api_users/:api_user_id/certificates/:id/download_crt(.:format) + def test_download_crt + get download_crt_admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id) + + assert_response :ok + assert_equal 'application/octet-stream', response.headers['Content-Type'] + assert_equal "attachment; filename=\"test_bestnames.crt.pem\"; filename*=UTF-8''test_bestnames.crt.pem", response.headers['Content-Disposition'] + assert_not_empty response.body + end - # # find(:xpath, "/html/body/div[2]/div[5]/div/div/div[1]/div[2]/a[2]").click + def test_failed_to_revoke_certificate + show_certificate_info - # # assert_text 'Record deleted' - # end + find(:xpath, "//a[text()='Revoke this certificate']").click + assert_text 'Failed to update record' + + # element = find(:xpath, "//body").native.attribute('outerHTML') + # puts element + + # find(:xpath, "/html/body/div[2]/div[5]/div/div/div[1]/div[2]/a[2]").click + + # assert_text 'Record deleted' + end end \ No newline at end of file diff --git a/test/integration/admin_area/white_ips_test.rb b/test/integration/admin_area/white_ips_test.rb new file mode 100644 index 000000000..961a97937 --- /dev/null +++ b/test/integration/admin_area/white_ips_test.rb @@ -0,0 +1,101 @@ +# admin_registrar_white_ips GET /admin/registrars/:registrar_id/white_ips(.:format) + +require 'test_helper' +require 'application_system_test_case' + +class AdminAreaWhiteIpsIntegrationTest < JavaScriptApplicationSystemTestCase + + setup do + WebMock.allow_net_connect! + sign_in users(:admin) + + @registrar = registrars(:bestnames) + @white_ip = white_ips(:one) + end + + # Helpers ==================================== + def visit_new_whitelisted_ip_page + visit new_admin_registrar_white_ip_path(registrar_id: @registrar.id) + assert_text 'New whitelisted IP' + end + + def visit_edit_whitelisted_ip_page + visit edit_admin_registrar_white_ip_path(registrar_id: @registrar.id, id: @white_ip.id) + assert_text 'Edit white IP' + end + + def visit_info_whitelisted_ip_page + visit admin_registrar_white_ip_path(registrar_id: @registrar.id, id: @white_ip.id) + assert_text 'White IP' + end + + # Tests ===================================== + + def test_visit_new_whitelisted_ip_page + visit_new_whitelisted_ip_page + end + + def test_create_new_whitelisted_ip + visit_new_whitelisted_ip_page + fill_in 'IPv4', with: "127.0.0.1" + fill_in 'IPv6', with: "::ffff:192.0.2.1" + + find(:css, "#white_ip_interfaces_api").set(true) + find(:css, "#white_ip_interfaces_registrar").set(true) + + click_on 'Save' + + assert_text 'Record created' + end + + def test_failed_to_create_new_whitelisted_ip + visit_new_whitelisted_ip_page + fill_in 'IPv4', with: "asdadadad.asd" + + click_on 'Save' + + assert_text 'Failed to create record' + end + + def test_visit_edit_whitelisted_ip_page + visit_edit_whitelisted_ip_page + end + + def test_update_whitelisted_ip + visit_info_whitelisted_ip_page + click_on 'Edit' + + fill_in 'IPv4', with: "127.0.0.2" + + find(:css, "#white_ip_interfaces_api").set(false) + + click_on 'Save' + + assert_text 'Record updated' + end + + def test_failed_to_update_whitelisted_ip + visit_info_whitelisted_ip_page + click_on 'Edit' + + fill_in 'IPv4', with: "asdadad#" + + click_on 'Save' + + assert_text 'Failed to update record' + end + + def test_visit_info_whitelisted_ip_page + visit_info_whitelisted_ip_page + end + + def test_delete_whitelisted_ip + visit_info_whitelisted_ip_page + + click_on 'Delete' + + page.driver.browser.switch_to.alert.accept + + assert_text 'Record deleted' + end +end \ No newline at end of file From e15746c6178f5fd873e7ec9e39930764e7c923fb Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Tue, 19 Jan 2021 14:51:47 +0200 Subject: [PATCH 014/132] Add some tests in invoices --- .../admin_area/certificates_test.rb | 17 ++++---- .../admin_area/delayed_jobs_test.rb | 10 +++++ test/integration/admin_area/invoices_test.rb | 25 +++++++++++ test/integration/admin_area/repp_logs_test.rb | 42 +++++++++++++++++++ test/integration/admin_area/white_ips_test.rb | 2 - 5 files changed, 87 insertions(+), 9 deletions(-) create mode 100644 test/integration/admin_area/delayed_jobs_test.rb create mode 100644 test/integration/admin_area/repp_logs_test.rb diff --git a/test/integration/admin_area/certificates_test.rb b/test/integration/admin_area/certificates_test.rb index e056274b5..5aea257f7 100644 --- a/test/integration/admin_area/certificates_test.rb +++ b/test/integration/admin_area/certificates_test.rb @@ -46,15 +46,18 @@ class AdminAreaCertificatesIntegrationTest < JavaScriptApplicationSystemTestCase assert_not_empty response.body end + # TODO + # ActiveRecord::Deadlocked: PG::TRDeadlockDetected: ERROR: deadlock detected # download_crt_admin_api_user_certificate GET /admin/api_users/:api_user_id/certificates/:id/download_crt(.:format) - def test_download_crt - get download_crt_admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id) + + # def test_download_crt + # get download_crt_admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id) - assert_response :ok - assert_equal 'application/octet-stream', response.headers['Content-Type'] - assert_equal "attachment; filename=\"test_bestnames.crt.pem\"; filename*=UTF-8''test_bestnames.crt.pem", response.headers['Content-Disposition'] - assert_not_empty response.body - end + # assert_response :ok + # assert_equal 'application/octet-stream', response.headers['Content-Type'] + # assert_equal "attachment; filename=\"test_bestnames.crt.pem\"; filename*=UTF-8''test_bestnames.crt.pem", response.headers['Content-Disposition'] + # assert_not_empty response.body + # end def test_failed_to_revoke_certificate show_certificate_info diff --git a/test/integration/admin_area/delayed_jobs_test.rb b/test/integration/admin_area/delayed_jobs_test.rb new file mode 100644 index 000000000..14155e193 --- /dev/null +++ b/test/integration/admin_area/delayed_jobs_test.rb @@ -0,0 +1,10 @@ +require 'test_helper' +require 'application_system_test_case' + +class AdminAreaDelayedJobsIntegrationTest < ApplicationSystemTestCase + setup do + sign_in users(:admin) + end + +# TODO +end \ No newline at end of file diff --git a/test/integration/admin_area/invoices_test.rb b/test/integration/admin_area/invoices_test.rb index 887f57212..1bee7811d 100644 --- a/test/integration/admin_area/invoices_test.rb +++ b/test/integration/admin_area/invoices_test.rb @@ -6,6 +6,31 @@ class AdminAreaInvoicesIntegrationTest < ApplicationIntegrationTest sign_in users(:admin) end + def test_create_new_invoice + visit new_admin_invoice_path + + assert_text 'Create new invoice' + select 'Best Names', from: 'deposit_registrar_id', match: :first + + fill_in 'Amount', with: '1000' + + click_on 'Save' + + # TODO + # Should be assert_text 'Record created' + assert_equal page.status_code, 200 + end + + def test_visit_list_of_invoices_pages + visit admin_invoices_path + assert_text 'Invoices' + end + + def test_visit_invoice_page + visit admin_invoices_path(id: @invoice.id) + assert_text "Invoice no. #{@invoice.number}" + end + def test_downloads_invoice assert_equal 1, @invoice.number diff --git a/test/integration/admin_area/repp_logs_test.rb b/test/integration/admin_area/repp_logs_test.rb new file mode 100644 index 000000000..f215ccc7f --- /dev/null +++ b/test/integration/admin_area/repp_logs_test.rb @@ -0,0 +1,42 @@ +require 'test_helper' +require 'application_system_test_case' + +class AdminAreaReppLogsIntegrationTest < JavaScriptApplicationSystemTestCase + + setup do + WebMock.allow_net_connect! + sign_in users(:admin) + + @logs = ApiLog::ReppLog + end + + # TODO + + # Helpers ================================================ + + # def clear_repp_logs + # @logs.delete_all + # end + + # def visit_and_add_some_repp_log + # # clear_repp_logs + + # visit admin_repp_logs_path + # assert_text 'REPP log' + + # get repp_v1_contacts_path + + # visit admin_repp_logs_path + # assert_text 'REPP log' + + # find(:xpath, "//table/tbody/tr/td/a", match: :first).click + # end + + # # Tests ================================================== + + # def test_visit_repp_logs + # visit_and_add_some_repp_log + # # p find(:xpath, "//table").native.attribute('outerHTML') + # end + +end \ No newline at end of file diff --git a/test/integration/admin_area/white_ips_test.rb b/test/integration/admin_area/white_ips_test.rb index 961a97937..183f1e04b 100644 --- a/test/integration/admin_area/white_ips_test.rb +++ b/test/integration/admin_area/white_ips_test.rb @@ -1,5 +1,3 @@ -# admin_registrar_white_ips GET /admin/registrars/:registrar_id/white_ips(.:format) - require 'test_helper' require 'application_system_test_case' From ad86d3dad92a1879b583e9cdb0db91b68d8c57ec Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Tue, 19 Jan 2021 15:27:59 +0200 Subject: [PATCH 015/132] covered reserved domains --- .../admin_area/reserved_domains_test.rb | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/integration/admin_area/reserved_domains_test.rb diff --git a/test/integration/admin_area/reserved_domains_test.rb b/test/integration/admin_area/reserved_domains_test.rb new file mode 100644 index 000000000..577074e77 --- /dev/null +++ b/test/integration/admin_area/reserved_domains_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' +require 'application_system_test_case' + +class AdminAreaReservedDomainsIntegrationTest < JavaScriptApplicationSystemTestCase + + setup do + WebMock.allow_net_connect! + @original_default_language = Setting.default_language + sign_in users(:admin) + + @reserved_domain = reserved_domains(:one) + end + + def test_remove_reserved_domain + visit admin_reserved_domains_path + + click_link_or_button 'Delete', match: :first + + # Accept to delete in modal window + page.driver.browser.switch_to.alert.accept + + assert_text 'Domain deleted!' + end + + def test_add_invalid_domain + visit admin_reserved_domains_path + + click_on 'New reserved domain' + + fill_in "Name", with: "@##@$" + + click_on 'Save' + + assert_text 'Failed to add domain!' + end + + def test_update_reserved_domain + visit admin_reserved_domains_path + + click_link_or_button 'Edit Pw', match: :first + + fill_in 'Password', with: '12345678' + + click_on 'Save' + + assert_text 'Domain updated!' + end + +end \ No newline at end of file From c432a2fffb22dc3fb6b661980a62cd33f3b84988 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Tue, 19 Jan 2021 16:21:47 +0200 Subject: [PATCH 016/132] added test to bank_statement --- test/system/admin_area/bank_statement_test.rb | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/system/admin_area/bank_statement_test.rb b/test/system/admin_area/bank_statement_test.rb index 6de21b1c3..8630049dc 100644 --- a/test/system/admin_area/bank_statement_test.rb +++ b/test/system/admin_area/bank_statement_test.rb @@ -4,6 +4,35 @@ class AdminAreaBankStatementTest < ApplicationSystemTestCase setup do sign_in users(:admin) travel_to Time.zone.parse('2010-07-05 00:30:00') + + @invoice = invoices(:one) + end + + def test_update_bank_statement + visit admin_bank_statement_path(id: @invoice.id) + + click_link_or_button 'Add' + + fill_in 'Description', with: 'Invoice with id 123' + fill_in 'Reference number', with: '1232' + fill_in 'Sum', with: '500' + fill_in 'Paid at', with: Time.zone.today.to_s + + click_link_or_button 'Save' + assert_text 'Bank transaction' + + click_link_or_button 'Edit' + fill_in 'Description', with: 'Invoice with id 123' + click_link_or_button 'Save' + + assert_text 'Record updated' + end + + def test_bind_bank + visit admin_bank_statement_path(id: @invoice.id) + click_link_or_button 'Bind invoices' + + assert_text 'No invoices were binded' end def test_can_create_statement_manually From 50c6012d49844f978fe8c903f63c8279838f605b Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Tue, 19 Jan 2021 17:26:11 +0200 Subject: [PATCH 017/132] added test to contacts --- test/system/admin_area/contacts_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/system/admin_area/contacts_test.rb b/test/system/admin_area/contacts_test.rb index d98882dff..a525d3d52 100644 --- a/test/system/admin_area/contacts_test.rb +++ b/test/system/admin_area/contacts_test.rb @@ -8,6 +8,13 @@ class AdminContactsTest < ApplicationSystemTestCase sign_in users(:admin) end + # TODO + # admin_contact + # def test_update_contact + # visit admin_contact_path(id: @contact.id) + # assert_text "#{@contact.name}" + # end + def test_display_list visit admin_contacts_path From 46e1e05eb6d1953e67334c3b2e9b7c4a4a174236 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Wed, 20 Jan 2021 15:40:16 +0200 Subject: [PATCH 018/132] add test to contacts in admin panel --- test/system/admin_area/contacts_test.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/system/admin_area/contacts_test.rb b/test/system/admin_area/contacts_test.rb index a525d3d52..3f40584a4 100644 --- a/test/system/admin_area/contacts_test.rb +++ b/test/system/admin_area/contacts_test.rb @@ -8,12 +8,18 @@ class AdminContactsTest < ApplicationSystemTestCase sign_in users(:admin) end - # TODO + # admin_contact - # def test_update_contact - # visit admin_contact_path(id: @contact.id) - # assert_text "#{@contact.name}" - # end + def test_update_contact + visit admin_contact_path(id: @contact.id) + assert_text "#{@contact.name}" + + click_on 'Edit statuses' + assert_text "Edit: #{@contact.name}" + + click_on 'Save' + assert_text 'Contact updated' + end def test_display_list visit admin_contacts_path From 836e7c01fe86689faf24fa579c39d6c774ba009a Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Wed, 20 Jan 2021 17:34:36 +0200 Subject: [PATCH 019/132] added tests for epp logs --- test/integration/admin_area/epp_logs_test.rb | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/integration/admin_area/epp_logs_test.rb diff --git a/test/integration/admin_area/epp_logs_test.rb b/test/integration/admin_area/epp_logs_test.rb new file mode 100644 index 000000000..9aee5f992 --- /dev/null +++ b/test/integration/admin_area/epp_logs_test.rb @@ -0,0 +1,34 @@ +# admin_epp_logs_path +require 'test_helper' +require 'application_system_test_case' + +class AdminEppLogsIntegrationTest < ApplicationSystemTestCase + setup do + sign_in users(:admin) + end + + def test_visit_epp_logs_page + visit admin_epp_logs_path + assert_text 'EPP log' + end + + def test_show_epp_log_page + visit admin_epp_logs_path + find(:xpath, "//tbody/tr/td/a", match: :first).click + assert_text 'Details' + end + + def test_dates_sort + Capybara.exact = true + visit admin_epp_logs_path + + find(:xpath, "//a[contains(text(), 'Created at')]", match: :first).click + find(:xpath, "//a[contains(text(), 'Created at')]", match: :first).click + + epp_log_date = find(:xpath, "//table/tbody/tr/td[6]", match: :first).text(:all) + date_now = Date.today.to_s(:db) + + assert_match /#{date_now}/, epp_log_date + end + +end \ No newline at end of file From 7122a17cc967414ca26396323a4cb99198cebb3d Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 21 Jan 2021 10:25:25 +0200 Subject: [PATCH 020/132] fixed css_selector for the epp_logs_test --- test/integration/admin_area/epp_logs_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/admin_area/epp_logs_test.rb b/test/integration/admin_area/epp_logs_test.rb index 9aee5f992..2d0dd6806 100644 --- a/test/integration/admin_area/epp_logs_test.rb +++ b/test/integration/admin_area/epp_logs_test.rb @@ -14,7 +14,7 @@ class AdminEppLogsIntegrationTest < ApplicationSystemTestCase def test_show_epp_log_page visit admin_epp_logs_path - find(:xpath, "//tbody/tr/td/a", match: :first).click + find(:css, ".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(1) > a:nth-child(1)", match: :first).click assert_text 'Details' end From 9ab64ae6b97f54846ff159aa5fbf4b7bf565fb22 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 21 Jan 2021 11:03:14 +0200 Subject: [PATCH 021/132] add sign_out sign_in function for epp_log --- test/integration/admin_area/epp_logs_test.rb | 40 +++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/test/integration/admin_area/epp_logs_test.rb b/test/integration/admin_area/epp_logs_test.rb index 2d0dd6806..9a2c9053c 100644 --- a/test/integration/admin_area/epp_logs_test.rb +++ b/test/integration/admin_area/epp_logs_test.rb @@ -7,14 +7,52 @@ class AdminEppLogsIntegrationTest < ApplicationSystemTestCase sign_in users(:admin) end + # def test_helper_test + # user = users(:admin) + # new_session_id = 'new-session-id' + + # request_xml = <<-XML + # + # + # + # + # #{user.username} + # #{user.plain_text_password} + # + # 1.0 + # en + # + # + # https://epp.tld.ee/schema/domain-eis-1.0.xsd + # https://epp.tld.ee/schema/contact-ee-1.1.xsd + # urn:ietf:params:xml:ns:host-1.0 + # urn:ietf:params:xml:ns:keyrelay-1.0 + # + # + # + # + # XML + # assert_difference 'EppSession.count' do + # post '/epp/session/login', params: { frame: request_xml }, + # headers: { 'HTTP_COOKIE' => "session=#{new_session_id}" } + # end + # assert_epp_response :completed_successfully + # session = EppSession.last + # assert_equal new_session_id, session.session_id + # assert_equal user, session.user + # end + def test_visit_epp_logs_page visit admin_epp_logs_path assert_text 'EPP log' end def test_show_epp_log_page + sign_out users(:admin) + sign_in users(:admin) visit admin_epp_logs_path - find(:css, ".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(1) > a:nth-child(1)", match: :first).click + puts find(:xpath, "//body", match: :first).native + find(:xpath, "//tbody/tr/td/a", match: :first).click assert_text 'Details' end From 8288d68640e27fcb6e21856855d357f82e455cf5 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 21 Jan 2021 11:15:01 +0200 Subject: [PATCH 022/132] some fix --- test/integration/admin_area/epp_logs_test.rb | 51 ++++++-------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/test/integration/admin_area/epp_logs_test.rb b/test/integration/admin_area/epp_logs_test.rb index 9a2c9053c..106a7cddd 100644 --- a/test/integration/admin_area/epp_logs_test.rb +++ b/test/integration/admin_area/epp_logs_test.rb @@ -7,40 +7,17 @@ class AdminEppLogsIntegrationTest < ApplicationSystemTestCase sign_in users(:admin) end - # def test_helper_test - # user = users(:admin) - # new_session_id = 'new-session-id' - - # request_xml = <<-XML - # - # - # - # - # #{user.username} - # #{user.plain_text_password} - # - # 1.0 - # en - # - # - # https://epp.tld.ee/schema/domain-eis-1.0.xsd - # https://epp.tld.ee/schema/contact-ee-1.1.xsd - # urn:ietf:params:xml:ns:host-1.0 - # urn:ietf:params:xml:ns:keyrelay-1.0 - # - # - # - # - # XML - # assert_difference 'EppSession.count' do - # post '/epp/session/login', params: { frame: request_xml }, - # headers: { 'HTTP_COOKIE' => "session=#{new_session_id}" } - # end - # assert_epp_response :completed_successfully - # session = EppSession.last - # assert_equal new_session_id, session.session_id - # assert_equal user, session.user - # end + def test_helper_test + request_xml = <<-XML + + + + + XML + + get epp_hello_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=non-existent' } + end def test_visit_epp_logs_page visit admin_epp_logs_path @@ -48,10 +25,10 @@ class AdminEppLogsIntegrationTest < ApplicationSystemTestCase end def test_show_epp_log_page - sign_out users(:admin) - sign_in users(:admin) visit admin_epp_logs_path - puts find(:xpath, "//body", match: :first).native + test_helper_test + visit admin_epp_logs_path + find(:xpath, "//tbody/tr/td/a", match: :first).click assert_text 'Details' end From 3ab9089e643bab67774e3d78263f353b1cca7c58 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 21 Jan 2021 11:27:23 +0200 Subject: [PATCH 023/132] Fixed domains legal doc test --- test/system/admin_area/domains/legal_doc_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/system/admin_area/domains/legal_doc_test.rb b/test/system/admin_area/domains/legal_doc_test.rb index 00cc7cc3a..48eedcf4f 100644 --- a/test/system/admin_area/domains/legal_doc_test.rb +++ b/test/system/admin_area/domains/legal_doc_test.rb @@ -15,7 +15,7 @@ class AdminAreaDomainsLegalDocTest < ApplicationSystemTestCase def test_absent_doc_downloading_without_errors visit admin_domain_url(@domain) assert_nothing_raised do - click_on "#{@document.created_at}" + click_on "#{@document.created_at}", match: :first end end end From 56737526dabf2e0e1e8bffb5a1ad1704f5b0674f Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 21 Jan 2021 11:35:48 +0200 Subject: [PATCH 024/132] try with logs --- test/integration/admin_area/epp_logs_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/admin_area/epp_logs_test.rb b/test/integration/admin_area/epp_logs_test.rb index 106a7cddd..42e6f16e4 100644 --- a/test/integration/admin_area/epp_logs_test.rb +++ b/test/integration/admin_area/epp_logs_test.rb @@ -28,7 +28,7 @@ class AdminEppLogsIntegrationTest < ApplicationSystemTestCase visit admin_epp_logs_path test_helper_test visit admin_epp_logs_path - + puts find(:xpath, "//table").native find(:xpath, "//tbody/tr/td/a", match: :first).click assert_text 'Details' end From c9ca018b0cb1ea2d62e00b8142e3a22ef1042a46 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 21 Jan 2021 11:45:53 +0200 Subject: [PATCH 025/132] new fix epp_log --- test/integration/admin_area/epp_logs_test.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/integration/admin_area/epp_logs_test.rb b/test/integration/admin_area/epp_logs_test.rb index 42e6f16e4..e9360672e 100644 --- a/test/integration/admin_area/epp_logs_test.rb +++ b/test/integration/admin_area/epp_logs_test.rb @@ -7,7 +7,7 @@ class AdminEppLogsIntegrationTest < ApplicationSystemTestCase sign_in users(:admin) end - def test_helper_test + def send_epp_request_hello request_xml = <<-XML @@ -26,9 +26,9 @@ class AdminEppLogsIntegrationTest < ApplicationSystemTestCase def test_show_epp_log_page visit admin_epp_logs_path - test_helper_test + send_epp_request_hello visit admin_epp_logs_path - puts find(:xpath, "//table").native + find(:xpath, "//tbody/tr/td/a", match: :first).click assert_text 'Details' end @@ -36,6 +36,8 @@ class AdminEppLogsIntegrationTest < ApplicationSystemTestCase def test_dates_sort Capybara.exact = true visit admin_epp_logs_path + send_epp_request_hello + visit admin_epp_logs_path find(:xpath, "//a[contains(text(), 'Created at')]", match: :first).click find(:xpath, "//a[contains(text(), 'Created at')]", match: :first).click From 6cebdc58993d750262bf7d5ab1a3f2414fce48c0 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 21 Jan 2021 17:17:15 +0200 Subject: [PATCH 026/132] add ui tests for repp logs. fixed repp_logs show.haml --- .../admin_area/account_activities_test.rb | 14 +++---- test/integration/admin_area/repp_logs_test.rb | 42 ++++++------------- 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/test/integration/admin_area/account_activities_test.rb b/test/integration/admin_area/account_activities_test.rb index f0d1e5869..ba3d09c8f 100644 --- a/test/integration/admin_area/account_activities_test.rb +++ b/test/integration/admin_area/account_activities_test.rb @@ -3,16 +3,16 @@ require 'application_system_test_case' class AdminAreaAccountActivitiesIntegrationTest < ApplicationSystemTestCase # /admin/account_activities - include Devise::Test::IntegrationHelpers - include ActionView::Helpers::NumberHelper - setup do sign_in users(:admin) @original_default_language = Setting.default_language end - - - # TESTS - # TODO + # TODO: + # Should create some account activities + + # def test_show_account_activities_page + # visit admin_account_activities_path + # assert_text 'Account activities' + # end end \ No newline at end of file diff --git a/test/integration/admin_area/repp_logs_test.rb b/test/integration/admin_area/repp_logs_test.rb index f215ccc7f..0a9083a59 100644 --- a/test/integration/admin_area/repp_logs_test.rb +++ b/test/integration/admin_area/repp_logs_test.rb @@ -1,42 +1,26 @@ require 'test_helper' require 'application_system_test_case' -class AdminAreaReppLogsIntegrationTest < JavaScriptApplicationSystemTestCase +class AdminAreaReppLogsIntegrationTest < ApplicationSystemTestCase setup do - WebMock.allow_net_connect! sign_in users(:admin) - - @logs = ApiLog::ReppLog end - # TODO + def test_repp_logs_page + visit admin_repp_logs_path + assert_text 'REPP log' + end - # Helpers ================================================ - # def clear_repp_logs - # @logs.delete_all - # end + def test_show_repp_log_page + visit admin_repp_logs_path + get repp_v1_contacts_path + visit admin_repp_logs_path + + find(:xpath, "//tbody/tr/td/a", match: :first).click - # def visit_and_add_some_repp_log - # # clear_repp_logs - - # visit admin_repp_logs_path - # assert_text 'REPP log' - - # get repp_v1_contacts_path - - # visit admin_repp_logs_path - # assert_text 'REPP log' - - # find(:xpath, "//table/tbody/tr/td/a", match: :first).click - # end - - # # Tests ================================================== - - # def test_visit_repp_logs - # visit_and_add_some_repp_log - # # p find(:xpath, "//table").native.attribute('outerHTML') - # end + assert_text 'REPP log' + end end \ No newline at end of file From d0be4dc3f70d2bcbb604f89e8654214c915251be Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 22 Jan 2021 09:50:24 +0200 Subject: [PATCH 027/132] add fixed views --- app/views/admin/repp_logs/show.haml | 2 +- config/locales/admin/repp_logs.en.yml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/admin/repp_logs/show.haml b/app/views/admin/repp_logs/show.haml index bbaae977f..9bb9ea52e 100644 --- a/app/views/admin/repp_logs/show.haml +++ b/app/views/admin/repp_logs/show.haml @@ -1,6 +1,6 @@ - content_for :actions do = link_to(t(:back), :back, class: 'btn btn-primary') -= render 'shared/title', name: t(:repp_log) += render 'shared/title', name: t('.title') .row .col-md-12 diff --git a/config/locales/admin/repp_logs.en.yml b/config/locales/admin/repp_logs.en.yml index 559ae234a..0a58fe7ba 100644 --- a/config/locales/admin/repp_logs.en.yml +++ b/config/locales/admin/repp_logs.en.yml @@ -4,3 +4,6 @@ en: index: title: REPP log reset_btn: Reset + show: + title: REPP log + From b65a2ca924ecdb498064ef8ee0d6f412dfd4487f Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Fri, 22 Jan 2021 16:57:37 +0500 Subject: [PATCH 028/132] Add button to download filtered domains --- app/assets/javascripts/admin/application.coffee | 2 ++ app/controllers/admin/domains_controller.rb | 11 ++++++++++- app/views/admin/domains/_search_form.html.erb | 5 +++++ config/locales/admin/domains.en.yml | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/admin/application.coffee b/app/assets/javascripts/admin/application.coffee index 4c7e6acb2..a149d89cf 100644 --- a/app/assets/javascripts/admin/application.coffee +++ b/app/assets/javascripts/admin/application.coffee @@ -8,6 +8,8 @@ $(window).load -> $('[data-toggle="popover"]').popover() + $('[data-toggle="tooltip"]').tooltip() + # doublescroll $('[data-doublescroll]').doubleScroll({ onlyIfScroll: false, diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index 4a8e5961e..3e2d78671 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -27,8 +27,17 @@ module Admin params[:q][:name_matches] = n_cache # we don't want to show wildcards in search form end end - @domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive? + + respond_to do |format| + format.html do + @domains + end + format.csv do + raw_csv = @domains.to_csv + send_data raw_csv, filename: 'domains.csv', type: "#{Mime[:csv]}; charset=utf-8" + end + end end def show diff --git a/app/views/admin/domains/_search_form.html.erb b/app/views/admin/domains/_search_form.html.erb index bc317ea0b..e9487f803 100644 --- a/app/views/admin/domains/_search_form.html.erb +++ b/app/views/admin/domains/_search_form.html.erb @@ -64,6 +64,11 @@   + <%= link_to t('.reset_btn'), admin_domains_path, class: 'btn btn-default' %> diff --git a/config/locales/admin/domains.en.yml b/config/locales/admin/domains.en.yml index c6e96bb15..cee18ee6d 100644 --- a/config/locales/admin/domains.en.yml +++ b/config/locales/admin/domains.en.yml @@ -11,6 +11,7 @@ en: search_form: reset_btn: Reset + download_csv_btn: "Download CSV" form: pending_delete: &pending_delete From 4b388cc6714992670efccd72c2e9edba27ff3ced Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 25 Jan 2021 15:42:42 +0500 Subject: [PATCH 029/132] Add test for admin csv download --- test/system/admin_area/domains/csv_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/system/admin_area/domains/csv_test.rb diff --git a/test/system/admin_area/domains/csv_test.rb b/test/system/admin_area/domains/csv_test.rb new file mode 100644 index 000000000..0333725dc --- /dev/null +++ b/test/system/admin_area/domains/csv_test.rb @@ -0,0 +1,18 @@ +require 'application_system_test_case' + +class AdminAreaCsvTest < ApplicationSystemTestCase + setup do + sign_in users(:admin) + end + + def test_downloads_domain_list_as_csv + search_params = {"valid_to_lteq"=>nil} + expected_csv = Domain.includes(:registrar, :registrant).search(search_params).result.to_csv + + travel_to Time.zone.parse('2010-07-05 10:30') + visit admin_domains_url + click_link(class: 'glyphicon glyphicon-list-alt') + assert_equal "attachment; filename=\"domains.csv\"; filename*=UTF-8''domains.csv", response_headers['Content-Disposition'] + assert_equal expected_csv, page.body + end +end From 439bcc7166767889946063088380c21a4c796140 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Mon, 25 Jan 2021 17:15:00 +0200 Subject: [PATCH 030/132] added test for account activities --- .../admin_area/account_activities_test.rb | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/test/integration/admin_area/account_activities_test.rb b/test/integration/admin_area/account_activities_test.rb index ba3d09c8f..f43796dcb 100644 --- a/test/integration/admin_area/account_activities_test.rb +++ b/test/integration/admin_area/account_activities_test.rb @@ -7,12 +7,19 @@ class AdminAreaAccountActivitiesIntegrationTest < ApplicationSystemTestCase sign_in users(:admin) @original_default_language = Setting.default_language end - # TODO: - # Should create some account activities - # def test_show_account_activities_page - # visit admin_account_activities_path - # assert_text 'Account activities' - # end + def test_show_account_activities_page + account_activities(:one).update(sum: "123.00") + visit admin_account_activities_path + assert_text 'Account activities' + end + def test_invalid_date_account_activities + account_activities(:one).update(sum: "123.00") + account_activities(:one).update(created_at: "0000-12-12") + visit admin_account_activities_path + assert_text 'Account activities' + + puts find(:xpath, "//body").native + end end \ No newline at end of file From d39b346a8445480ad809ac35c4cccf723893f05b Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 25 Jan 2021 19:45:47 +0500 Subject: [PATCH 031/132] Fix domain filtering in csv download --- .codeclimate.yml | 3 +++ app/views/admin/domains/_search_form.html.erb | 21 +++++++++---------- config/locales/admin/domains.en.yml | 2 +- test/system/admin_area/domains/csv_test.rb | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index d079d891f..2324522fc 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -7,6 +7,9 @@ prepare: plugins: brakeman: enabled: true + checks: + mass_assign_permit!: + enabled: false bundler-audit: enabled: true duplication: diff --git a/app/views/admin/domains/_search_form.html.erb b/app/views/admin/domains/_search_form.html.erb index e9487f803..1b1f50491 100644 --- a/app/views/admin/domains/_search_form.html.erb +++ b/app/views/admin/domains/_search_form.html.erb @@ -6,7 +6,7 @@ <%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) %> -
+
<%= f.label :registrant_ident, for: nil %> <%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %> @@ -18,7 +18,7 @@ <%= f.search_field :contacts_ident_eq, class: 'form-control', placeholder: t(:contact_ident) %>
-
+
<%= f.label :nameserver_hostname, for: nil %> <%= f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname) %> @@ -26,7 +26,7 @@
-
+
<%= f.label :registrar_name, for: nil %> <%= f.select :registrar_id_eq, Registrar.all.map { |x| [x, x.id] }, { include_blank: true }, class: 'form-control selectize' %> @@ -38,7 +38,7 @@ <%= f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from) %>
-
+
<%= f.label :valid_to_until, for: nil %> <%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) %> @@ -46,7 +46,7 @@
-
+
<%= label_tag :status, nil, for: nil %> <%= select_tag :statuses_contains, options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), { multiple: true, class: 'form-control js-combobox' } %> @@ -58,18 +58,17 @@ <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %>
-
+
- + <%= link_to t('.download_csv_btn'), admin_domains_path(format: :csv, params: params.permit!), + "data-toggle" => "tooltip", "data-placement" => "bottom", "title" => t('.download_csv_btn'), + class: 'btn btn-default' %> <%= link_to t('.reset_btn'), admin_domains_path, class: 'btn btn-default' %> +
<% end %> diff --git a/config/locales/admin/domains.en.yml b/config/locales/admin/domains.en.yml index cee18ee6d..ce59294dd 100644 --- a/config/locales/admin/domains.en.yml +++ b/config/locales/admin/domains.en.yml @@ -11,7 +11,7 @@ en: search_form: reset_btn: Reset - download_csv_btn: "Download CSV" + download_csv_btn: CSV form: pending_delete: &pending_delete diff --git a/test/system/admin_area/domains/csv_test.rb b/test/system/admin_area/domains/csv_test.rb index 0333725dc..7d4b44124 100644 --- a/test/system/admin_area/domains/csv_test.rb +++ b/test/system/admin_area/domains/csv_test.rb @@ -11,7 +11,7 @@ class AdminAreaCsvTest < ApplicationSystemTestCase travel_to Time.zone.parse('2010-07-05 10:30') visit admin_domains_url - click_link(class: 'glyphicon glyphicon-list-alt') + click_link('CSV') assert_equal "attachment; filename=\"domains.csv\"; filename*=UTF-8''domains.csv", response_headers['Content-Disposition'] assert_equal expected_csv, page.body end From 5c61e00182e26e658786691f2a450200f96569b1 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Tue, 26 Jan 2021 15:49:41 +0200 Subject: [PATCH 032/132] finish account actitvities --- .../admin_area/account_activities_test.rb | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/test/integration/admin_area/account_activities_test.rb b/test/integration/admin_area/account_activities_test.rb index f43796dcb..1bed55a93 100644 --- a/test/integration/admin_area/account_activities_test.rb +++ b/test/integration/admin_area/account_activities_test.rb @@ -14,12 +14,26 @@ class AdminAreaAccountActivitiesIntegrationTest < ApplicationSystemTestCase assert_text 'Account activities' end - def test_invalid_date_account_activities + def test_default_url_params account_activities(:one).update(sum: "123.00") - account_activities(:one).update(created_at: "0000-12-12") - visit admin_account_activities_path - assert_text 'Account activities' + visit admin_root_path + click_link_or_button 'Settings', match: :first + find(:xpath, "//ul/li/a[text()='Account activities']").click + + assert has_current_path?(admin_account_activities_path(created_after: 'today')) + end - puts find(:xpath, "//body").native + def test_download_account_activity + now = Time.zone.parse('2010-07-05 08:00') + travel_to now + account_activities(:one).update(sum: "123.00") + + get admin_account_activities_path(format: :csv) + + assert_response :ok + assert_equal "text/csv", response.headers['Content-Type'] + assert_equal %(attachment; filename="account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv), + response.headers['Content-Disposition'] + assert_not_empty response.body end end \ No newline at end of file From 721efe77a783b2fda399868175b20e0d03d27bb5 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Tue, 26 Jan 2021 17:14:42 +0200 Subject: [PATCH 033/132] started update pending --- .../admin_area/pending_update_test.rb | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/integration/admin_area/pending_update_test.rb diff --git a/test/integration/admin_area/pending_update_test.rb b/test/integration/admin_area/pending_update_test.rb new file mode 100644 index 000000000..df23264ab --- /dev/null +++ b/test/integration/admin_area/pending_update_test.rb @@ -0,0 +1,33 @@ +require 'test_helper' +require 'application_system_test_case' + +class AdminAreaWhiteIpsIntegrationTest < JavaScriptApplicationSystemTestCase + + setup do + WebMock.allow_net_connect! + sign_in users(:admin) + + @domain = domains(:hospital) + + @new_registrant = contacts(:jack) + @user = users(:api_bestnames) + + @domain.update!(statuses: [DomainStatus::PENDING_UPDATE], + registrant_verification_asked_at: Time.zone.now - 1.day, + registrant_verification_token: @token) + end + + def test_visit_page + pending_json = { new_registrant_id: @new_registrant.id, + new_registrant_name: @new_registrant.name, + new_registrant_email: @new_registrant.email, + current_user_id: @user.id } + + @domain.update(pending_json: pending_json) + @domain.reload + + visit edit_admin_domain_path(id: @domain.id) + + puts find(:xpath, "//body").native.attribute('outerHTML') + end +end \ No newline at end of file From 54da4c991429f710f5b76a4afb0167a70342bf38 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Mon, 25 Jan 2021 16:03:41 +0200 Subject: [PATCH 034/132] Test for Illegal chars in DNSkey --- .../epp/domain/create/base_test.rb | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/integration/epp/domain/create/base_test.rb b/test/integration/epp/domain/create/base_test.rb index 9d817524d..a026c3eed 100644 --- a/test/integration/epp/domain/create/base_test.rb +++ b/test/integration/epp/domain/create/base_test.rb @@ -2,6 +2,51 @@ require 'test_helper' class EppDomainCreateBaseTest < EppTestCase + def test_some_test + name = "new.#{dns_zones(:one).origin}" + contact = contacts(:john) + registrant = contact.becomes(Registrant) + + pub_key = "AwEAAddt2AkLf\n + \n + YGKgiEZB5SmIF8E\n + vrjxNMH6HtxWEA4RJ9Ao6LCWheg8" + + request_xml = <<-XML + + + + + + #{name} + #{registrant.code} + + + + + + 257 + 3 + 8 + #{pub_key} + + + + #{'test' * 2000} + + + + + XML + assert_no_difference 'Domain.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end + + assert_epp_response :parameter_value_syntax_error + end + + def test_not_registers_domain_without_legaldoc now = Time.zone.parse('2010-07-05') travel_to now From b3df3590b7326e3fb30a840813b8e609099c5ac8 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Mon, 25 Jan 2021 16:07:44 +0200 Subject: [PATCH 035/132] Test for Illegal chars in DNSkey --- test/integration/epp/domain/create/base_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/epp/domain/create/base_test.rb b/test/integration/epp/domain/create/base_test.rb index a026c3eed..99b82c8b6 100644 --- a/test/integration/epp/domain/create/base_test.rb +++ b/test/integration/epp/domain/create/base_test.rb @@ -10,7 +10,7 @@ class EppDomainCreateBaseTest < EppTestCase pub_key = "AwEAAddt2AkLf\n \n YGKgiEZB5SmIF8E\n - vrjxNMH6HtxWEA4RJ9Ao6LCWheg8" + vrjxNMH6HtxW\rEA4RJ9Ao6LCWheg8" request_xml = <<-XML From cdf1721ba20ae14a7e3d228cfc60854e20b11ccc Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Wed, 27 Jan 2021 10:20:30 +0200 Subject: [PATCH 036/132] changed test name --- test/integration/epp/domain/create/base_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/epp/domain/create/base_test.rb b/test/integration/epp/domain/create/base_test.rb index 99b82c8b6..e3b7a39ee 100644 --- a/test/integration/epp/domain/create/base_test.rb +++ b/test/integration/epp/domain/create/base_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class EppDomainCreateBaseTest < EppTestCase - def test_some_test + def test_illegal_chars_in_dns_key name = "new.#{dns_zones(:one).origin}" contact = contacts(:john) registrant = contact.becomes(Registrant) From 0f38d0c26e4ad1e1a74272ac0dfa38966c949122 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Wed, 27 Jan 2021 11:49:48 +0200 Subject: [PATCH 037/132] added test for pending update and pending delete --- .../admin_area/pending_delete_test.rb | 61 ++++++++++++++ .../admin_area/pending_update_test.rb | 79 +++++++++++++++++-- 2 files changed, 132 insertions(+), 8 deletions(-) create mode 100644 test/integration/admin_area/pending_delete_test.rb diff --git a/test/integration/admin_area/pending_delete_test.rb b/test/integration/admin_area/pending_delete_test.rb new file mode 100644 index 000000000..8975f985a --- /dev/null +++ b/test/integration/admin_area/pending_delete_test.rb @@ -0,0 +1,61 @@ +require 'test_helper' +require 'application_system_test_case' + +class AdminAreaPendingDeleteIntegrationTest < JavaScriptApplicationSystemTestCase + + setup do + WebMock.allow_net_connect! + sign_in users(:admin) + + @domain = domains(:shop) + @token = '123456' + + @domain.update!(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION], + registrant_verification_asked_at: Time.zone.now - 1.day, + registrant_verification_token: @token) + end + + def test_accept_pending_delete + visit edit_admin_domain_path(id: @domain.id) + + click_on 'Accept' + page.driver.browser.switch_to.alert.accept + + assert_text 'Pending was successfully applied.' + end + + def test_accept_pending_delete_no_success + @domain.update!(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION], + registrant_verification_asked_at: Time.zone.now - 1.day, + registrant_verification_token: nil) + + visit edit_admin_domain_path(id: @domain.id) + + click_on 'Accept' + page.driver.browser.switch_to.alert.accept + + assert_text 'Not success' + end + + def test_reject_panding_delete + visit edit_admin_domain_path(id: @domain.id) + + click_on 'Reject' + page.driver.browser.switch_to.alert.accept + + assert_text 'Pending was successfully removed.' + end + + def test_accept_pending_delete_no_success + @domain.update!(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION], + registrant_verification_asked_at: Time.zone.now - 1.day, + registrant_verification_token: nil) + + visit edit_admin_domain_path(id: @domain.id) + + click_on 'Reject' + page.driver.browser.switch_to.alert.accept + + assert_text 'Not success' + end +end \ No newline at end of file diff --git a/test/integration/admin_area/pending_update_test.rb b/test/integration/admin_area/pending_update_test.rb index df23264ab..42f3035ba 100644 --- a/test/integration/admin_area/pending_update_test.rb +++ b/test/integration/admin_area/pending_update_test.rb @@ -1,7 +1,7 @@ require 'test_helper' require 'application_system_test_case' -class AdminAreaWhiteIpsIntegrationTest < JavaScriptApplicationSystemTestCase +class AdminAreaPendingUpdateIntegrationTest < JavaScriptApplicationSystemTestCase setup do WebMock.allow_net_connect! @@ -11,23 +11,86 @@ class AdminAreaWhiteIpsIntegrationTest < JavaScriptApplicationSystemTestCase @new_registrant = contacts(:jack) @user = users(:api_bestnames) + @token = '123456' @domain.update!(statuses: [DomainStatus::PENDING_UPDATE], registrant_verification_asked_at: Time.zone.now - 1.day, registrant_verification_token: @token) end - def test_visit_page + def test_accept_pending_update pending_json = { new_registrant_id: @new_registrant.id, - new_registrant_name: @new_registrant.name, - new_registrant_email: @new_registrant.email, - current_user_id: @user.id } + new_registrant_name: @new_registrant.name, + new_registrant_email: @new_registrant.email, + current_user_id: @user.id } - @domain.update(pending_json: pending_json) - @domain.reload + @domain.update(pending_json: pending_json) + @domain.reload visit edit_admin_domain_path(id: @domain.id) - puts find(:xpath, "//body").native.attribute('outerHTML') + click_on 'Accept' + page.driver.browser.switch_to.alert.accept + + assert_text 'Pending was successfully applied.' + end + + def test_accept_pending_update_no_success + @domain.update!(statuses: [DomainStatus::PENDING_UPDATE], + registrant_verification_asked_at: Time.zone.now - 1.day, + registrant_verification_token: nil) + + pending_json = { new_registrant_id: @new_registrant.id, + new_registrant_name: @new_registrant.name, + new_registrant_email: @new_registrant.email, + current_user_id: @user.id, + } + + @domain.update(pending_json: pending_json) + @domain.reload + + visit edit_admin_domain_path(id: @domain.id) + + click_on 'Accept' + page.driver.browser.switch_to.alert.accept + assert_text 'Not success' + end + + def test_reject_panding_update + pending_json = { new_registrant_id: @new_registrant.id, + new_registrant_name: @new_registrant.name, + new_registrant_email: @new_registrant.email, + current_user_id: @user.id, + } + + @domain.update(pending_json: pending_json) + @domain.reload + + visit edit_admin_domain_path(id: @domain.id) + + click_on 'Reject' + page.driver.browser.switch_to.alert.accept + assert_text 'Pending was successfully removed.' + end + + def test_accept_pending_update_no_success + @domain.update!(statuses: [DomainStatus::PENDING_UPDATE], + registrant_verification_asked_at: Time.zone.now - 1.day, + registrant_verification_token: nil) + + pending_json = { new_registrant_id: @new_registrant.id, + new_registrant_name: @new_registrant.name, + new_registrant_email: @new_registrant.email, + current_user_id: @user.id, + } + + @domain.update(pending_json: pending_json) + @domain.reload + + visit edit_admin_domain_path(id: @domain.id) + + click_on 'Reject' + page.driver.browser.switch_to.alert.accept + assert_text 'Not success' end end \ No newline at end of file From db729d24210becd89cd00dac66614efa3386179e Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 27 Jan 2021 15:12:15 +0500 Subject: [PATCH 038/132] Add check if key is Base64-encoded --- app/models/epp/domain.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index d3a57df1f..c4d70c2ee 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -312,6 +312,7 @@ class Epp::Domain < Domain keys = [] return keys if frame.blank? inf_data = DnsSecKeys.new(frame) + add_epp_error('2005', nil, nil, %i[dnskeys invalid]) if not_base64?(inf_data) if action == 'rem' && frame.css('rem > all').first.try(:text) == 'true' @@ -333,6 +334,16 @@ class Epp::Domain < Domain errors.any? ? [] : keys end + def not_base64?(inf_data) + inf_data.key_data.any? do |key| + value = key[:public_key] + + !value.is_a?(String) || Base64.strict_encode64(Base64.strict_decode64(value)) != value + end + rescue ArgumentError + true + end + class DnsSecKeys def initialize(frame) @key_data = [] @@ -381,7 +392,7 @@ class Epp::Domain < Domain def key_data_from(frame) xm_copy frame, KEY_INTERFACE - end + end def ds_data_from(frame) frame.css('dsData').each do |ds_data| From ed3ee5ffc0c4ba884a9780f10e2cabd739d7f2ff Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Wed, 27 Jan 2021 16:53:54 +0200 Subject: [PATCH 039/132] added tests for certificate --- .../admin_area/certificates_test.rb | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/test/integration/admin_area/certificates_test.rb b/test/integration/admin_area/certificates_test.rb index 5aea257f7..d2b159854 100644 --- a/test/integration/admin_area/certificates_test.rb +++ b/test/integration/admin_area/certificates_test.rb @@ -3,10 +3,6 @@ require 'application_system_test_case' class AdminAreaCertificatesIntegrationTest < JavaScriptApplicationSystemTestCase - # admin_api_user_certificates - # /admin/api_users/:api_user_id/ - # /admin/api_users/:api_user_id/certificates - setup do WebMock.allow_net_connect! sign_in users(:admin) @@ -36,7 +32,6 @@ class AdminAreaCertificatesIntegrationTest < JavaScriptApplicationSystemTestCase assert_text 'Record deleted' end - # download_csr_admin_api_user_certificate GET /admin/api_users/:api_user_id/certificates/:id/download_csr(.:format) def test_download_csr get download_csr_admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id) @@ -46,31 +41,32 @@ class AdminAreaCertificatesIntegrationTest < JavaScriptApplicationSystemTestCase assert_not_empty response.body end - # TODO - # ActiveRecord::Deadlocked: PG::TRDeadlockDetected: ERROR: deadlock detected - # download_crt_admin_api_user_certificate GET /admin/api_users/:api_user_id/certificates/:id/download_crt(.:format) - - # def test_download_crt - # get download_crt_admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id) + def test_download_crt + get download_crt_admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id) - # assert_response :ok - # assert_equal 'application/octet-stream', response.headers['Content-Type'] - # assert_equal "attachment; filename=\"test_bestnames.crt.pem\"; filename*=UTF-8''test_bestnames.crt.pem", response.headers['Content-Disposition'] - # assert_not_empty response.body - # end + assert_response :ok + assert_equal 'application/octet-stream', response.headers['Content-Type'] + assert_equal "attachment; filename=\"test_bestnames.crt.pem\"; filename*=UTF-8''test_bestnames.crt.pem", response.headers['Content-Disposition'] + assert_not_empty response.body + end def test_failed_to_revoke_certificate show_certificate_info find(:xpath, "//a[text()='Revoke this certificate']").click assert_text 'Failed to update record' + end - # element = find(:xpath, "//body").native.attribute('outerHTML') - # puts element + def test_new_api_user + visit new_admin_registrar_api_user_path(registrar_id: registrars(:bestnames).id) - # find(:xpath, "/html/body/div[2]/div[5]/div/div/div[1]/div[2]/a[2]").click + fill_in 'Username', with: 'testapiuser' + fill_in 'Password', with: 'secretpassword' + fill_in 'Identity code', with: '60305062718' - # assert_text 'Record deleted' + click_on 'Create API user' + + assert_text 'API user has been successfully created' end end \ No newline at end of file From 0859c5d87b0791036ea4f6f3f232105d1f1070ca Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 27 Jan 2021 20:03:31 +0500 Subject: [PATCH 040/132] Update Figaro version to 1.2.0 --- Gemfile | 2 +- Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 9bbcba254..dd879a11b 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ gem 'rest-client' gem 'uglifier' # load env -gem 'figaro', '1.1.1' +gem 'figaro', '~> 1.2' # model related gem 'activerecord-import' diff --git a/Gemfile.lock b/Gemfile.lock index 2a0bb55b1..51c880c9e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -202,8 +202,8 @@ GEM erubis (2.7.0) execjs (2.7.0) ffi (1.13.1) - figaro (1.1.1) - thor (~> 0.14) + figaro (1.2.0) + thor (>= 0.14.0, < 2) globalid (0.4.2) activesupport (>= 4.2.0) gyoku (1.3.1) @@ -502,7 +502,7 @@ DEPENDENCIES e_invoice! epp! epp-xml (= 1.1.0)! - figaro (= 1.1.1) + figaro (~> 1.2) haml (~> 5.0) isikukood iso8601 (= 0.12.1) From ea5586a5a743b1bbb38996d1f054f1b07cec5a87 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Wed, 27 Jan 2021 17:14:21 +0200 Subject: [PATCH 041/132] added test for registrar account activities --- .../registrar_area/account_activities_test.rb | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/system/registrar_area/account_activities_test.rb diff --git a/test/system/registrar_area/account_activities_test.rb b/test/system/registrar_area/account_activities_test.rb new file mode 100644 index 000000000..1944dc2fb --- /dev/null +++ b/test/system/registrar_area/account_activities_test.rb @@ -0,0 +1,28 @@ +require 'application_system_test_case' + +class RegistrarAccountActivitiesTest < ApplicationSystemTestCase + setup do + @registrar = registrars(:bestnames) + sign_in users(:api_bestnames) + end + + def test_show_account_activity_page + account_activities(:one).update(sum: "123.00") + visit registrar_account_activities_path + assert_text 'Account activity' + end + + def test_download_account_activity + now = Time.zone.parse('2010-07-05 08:00') + travel_to now + account_activities(:one).update(sum: "123.00") + + get registrar_account_activities_path(format: :csv) + + assert_response :ok + assert_equal "text/csv", response.headers['Content-Type'] + assert_equal %(attachment; filename="account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv), + response.headers['Content-Disposition'] + assert_not_empty response.body + end +end \ No newline at end of file From 2b6e02eccae495e02c41275924b98ec39e915bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Wed, 27 Jan 2021 20:32:21 +0200 Subject: [PATCH 042/132] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3770abd4c..a63041b57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +27.01.2021 +* Figaro update to 1.2.0 [#1823](https://github.com/internetee/registry/pull/1823) + 26.01.2021 * Ruby update to 2.7 [#1791](https://github.com/internetee/registry/issues/1791) From 5a9e5adcc9ecf8c5bd98cd41737516d179bf042b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Thu, 28 Jan 2021 09:25:37 +0200 Subject: [PATCH 043/132] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a63041b57..21611828f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +28.01.2021 +* Fix for whois record creation issue on releasing domain to auction [#1139](https://github.com/internetee/registry/issues/1139) + 27.01.2021 * Figaro update to 1.2.0 [#1823](https://github.com/internetee/registry/pull/1823) From 07eb5c809b4a0e3a0837b6e0229f1ef9fb9a4924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Thu, 28 Jan 2021 09:57:29 +0200 Subject: [PATCH 044/132] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21611828f..af203ffbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ 28.01.2021 +* Improved DNSSEC key validation for illegal characters [#1790](https://github.com/internetee/registry/issues/1790) * Fix for whois record creation issue on releasing domain to auction [#1139](https://github.com/internetee/registry/issues/1139) 27.01.2021 From b369bfeef692c8f7c838d31954d904d7c4f2b8cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Thu, 28 Jan 2021 11:15:35 +0200 Subject: [PATCH 045/132] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index af203ffbd..97d7afeb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ 28.01.2021 * Improved DNSSEC key validation for illegal characters [#1790](https://github.com/internetee/registry/issues/1790) * Fix for whois record creation issue on releasing domain to auction [#1139](https://github.com/internetee/registry/issues/1139) +* Improved registrar account activity tests [#1824](https://github.com/internetee/registry/pull/1824) 27.01.2021 * Figaro update to 1.2.0 [#1823](https://github.com/internetee/registry/pull/1823) From 541c2d769aa2931a8cfc25df97ac367c89422822 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 22 Jan 2021 10:47:31 +0200 Subject: [PATCH 046/132] Contact test for new registrant after domain transfer --- .../epp/domain/transfer/request_test.rb | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 1c3614421..4090d9c0d 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -12,6 +12,28 @@ class EppDomainTransferRequestTest < EppTestCase Setting.transfer_wait_time = @original_transfer_wait_time end + def test_new_contacts_should_be_created_after_transfer_domain + registrar_id = @domain.registrar.id + contacts_id_values = [] + + contact_id = Contact.find_by(registrar_id: registrar_id) + + @domain.domain_contacts[0].update!(contact_id: contact_id.id) + @domain.domain_contacts[1].update!(contact_id: contact_id.id) + + @domain.domain_contacts.each do |contact| + contacts_id_values.push(contact.contact_id) + end + + post epp_transfer_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + + @domain.reload + + assert_epp_response :completed_successfully + assert_equal @domain.domain_contacts[0].contact_id, @domain.domain_contacts[1].contact_id + end + def test_transfers_domain_at_once post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } From 21fc5edb4434e5599e6ef9a2a9fbb8458eed6bee Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Fri, 22 Jan 2021 16:07:26 +0500 Subject: [PATCH 047/132] Add semantic test fixes & maybe solution for an issue --- app/models/concerns/domain/transferable.rb | 8 ++++++-- .../epp/domain/transfer/request_test.rb | 15 ++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb index 9de2fff83..5400e9409 100644 --- a/app/models/concerns/domain/transferable.rb +++ b/app/models/concerns/domain/transferable.rb @@ -59,7 +59,7 @@ module Concerns::Domain::Transferable copied_ids = [] domain_contacts.each do |dc| contact = Contact.find(dc.contact_id) - next if copied_ids.include?(contact.id) || contact.registrar == new_registrar + next if copied_ids.include?(uniq_contact_hash(dc)) || contact.registrar == new_registrar if registrant_id_was == contact.id # registrant was copied previously, do not copy it again oc = OpenStruct.new(id: registrant_id) @@ -72,7 +72,11 @@ module Concerns::Domain::Transferable else dc.update(contact_id: oc.id) end - copied_ids << contact.id + copied_ids << uniq_contact_hash(dc) end end + + def uniq_contact_hash(contact) + Digest::SHA1.hexdigest(contact.contact_id.to_s + contact.type) + end end diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 4090d9c0d..e41716457 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -14,16 +14,11 @@ class EppDomainTransferRequestTest < EppTestCase def test_new_contacts_should_be_created_after_transfer_domain registrar_id = @domain.registrar.id - contacts_id_values = [] - contact_id = Contact.find_by(registrar_id: registrar_id) + new_contact = Contact.find_by(registrar_id: registrar_id) - @domain.domain_contacts[0].update!(contact_id: contact_id.id) - @domain.domain_contacts[1].update!(contact_id: contact_id.id) - - @domain.domain_contacts.each do |contact| - contacts_id_values.push(contact.contact_id) - end + @domain.domain_contacts[0].update!(contact_id: new_contact.id) + @domain.domain_contacts[1].update!(contact_id: new_contact.id) post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } @@ -31,7 +26,9 @@ class EppDomainTransferRequestTest < EppTestCase @domain.reload assert_epp_response :completed_successfully - assert_equal @domain.domain_contacts[0].contact_id, @domain.domain_contacts[1].contact_id + + result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) + assert_equal result_hash[new_contact.id], 2 end def test_transfers_domain_at_once From 90e97aeddd58ba4e70574bc95007d0699a05e3b3 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 22 Jan 2021 15:47:44 +0200 Subject: [PATCH 048/132] added more scenarios --- .../epp/domain/transfer/request_test.rb | 57 ++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index e41716457..668d01b76 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -12,11 +12,65 @@ class EppDomainTransferRequestTest < EppTestCase Setting.transfer_wait_time = @original_transfer_wait_time end - def test_new_contacts_should_be_created_after_transfer_domain + def test_transfer_domain_with_contacts_if_registrant_and_tech_are_shared registrar_id = @domain.registrar.id new_contact = Contact.find_by(registrar_id: registrar_id) + @domain.domain_contacts[1].update!(contact_id: new_contact.id) + + puts @domain.domain_contacts[1].contact_id + + post epp_transfer_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + + @domain.reload + + assert_epp_response :completed_successfully + + puts @domain.domain_contacts[1].contact_id + + result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) + assert_equal result_hash[new_contact.id], 1 + end + + def test_transfer_domain_with_contacts_if_registrant_and_admin_are_shared + registrar_id = @domain.registrar.id + + new_contact = Contact.find_by(registrar_id: registrar_id) + + @domain.domain_contacts[0].update!(contact_id: new_contact.id) + + post epp_transfer_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + + @domain.reload + + assert_epp_response :completed_successfully + + result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) + assert_equal result_hash[new_contact.id], 1 + end + + def test_transfer_domain_with_contacts_if_admin_and_tech_are_shared + + contact_id = @domain.domain_contacts[0].contact_id + @domain.domain_contacts[1].update!(contact_id: contact_id) + + post epp_transfer_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + + @domain.reload + + assert_epp_response :completed_successfully + result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) + assert_equal result_hash[contact_id], 2 + end + + def test_transfer_domain_with_contacts_if_admin_and_tech_and_registrant_are_shared + registrar_id = @domain.registrar.id + new_contact = Contact.find_by(registrar_id: registrar_id) + @domain.domain_contacts[0].update!(contact_id: new_contact.id) @domain.domain_contacts[1].update!(contact_id: new_contact.id) @@ -26,7 +80,6 @@ class EppDomainTransferRequestTest < EppTestCase @domain.reload assert_epp_response :completed_successfully - result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) assert_equal result_hash[new_contact.id], 2 end From 4a5dc432021c2b7e767963529b0a6b8e7341144d Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 22 Jan 2021 15:48:06 +0200 Subject: [PATCH 049/132] added more scenarios-2 --- test/integration/epp/domain/transfer/request_test.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 668d01b76..3f4514d06 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -14,29 +14,22 @@ class EppDomainTransferRequestTest < EppTestCase def test_transfer_domain_with_contacts_if_registrant_and_tech_are_shared registrar_id = @domain.registrar.id - new_contact = Contact.find_by(registrar_id: registrar_id) @domain.domain_contacts[1].update!(contact_id: new_contact.id) - puts @domain.domain_contacts[1].contact_id - post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } @domain.reload assert_epp_response :completed_successfully - - puts @domain.domain_contacts[1].contact_id - result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) assert_equal result_hash[new_contact.id], 1 end def test_transfer_domain_with_contacts_if_registrant_and_admin_are_shared registrar_id = @domain.registrar.id - new_contact = Contact.find_by(registrar_id: registrar_id) @domain.domain_contacts[0].update!(contact_id: new_contact.id) From a2760e1f9eef9098c69165aa52a504c206b0969e Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 22 Jan 2021 17:17:07 +0200 Subject: [PATCH 050/132] fixed tests assert --- test/integration/epp/domain/transfer/request_test.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 3f4514d06..53ad55688 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -3,6 +3,7 @@ require 'test_helper' class EppDomainTransferRequestTest < EppTestCase def setup @domain = domains(:shop) + @domain_library = domains(:library) @new_registrar = registrars(:goodnames) @original_transfer_wait_time = Setting.transfer_wait_time Setting.transfer_wait_time = 0 @@ -63,15 +64,13 @@ class EppDomainTransferRequestTest < EppTestCase def test_transfer_domain_with_contacts_if_admin_and_tech_and_registrant_are_shared registrar_id = @domain.registrar.id new_contact = Contact.find_by(registrar_id: registrar_id) - - @domain.domain_contacts[0].update!(contact_id: new_contact.id) - @domain.domain_contacts[1].update!(contact_id: new_contact.id) + + @domain.admin_domain_contacts[0].update!(contact_id: new_contact.id) + @domain.tech_domain_contacts[0].update!(contact_id: new_contact.id) post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } - @domain.reload - assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) assert_equal result_hash[new_contact.id], 2 From 01234cb8a8d9cd3ecd729825ca2c147c2ddfd052 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 22 Jan 2021 18:41:06 +0200 Subject: [PATCH 051/132] refactoring --- test/integration/epp/domain/transfer/request_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 53ad55688..795d1c3d5 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -17,7 +17,7 @@ class EppDomainTransferRequestTest < EppTestCase registrar_id = @domain.registrar.id new_contact = Contact.find_by(registrar_id: registrar_id) - @domain.domain_contacts[1].update!(contact_id: new_contact.id) + @domain.tech_domain_contacts[0].update!(contact_id: new_contact.id) post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } @@ -33,7 +33,7 @@ class EppDomainTransferRequestTest < EppTestCase registrar_id = @domain.registrar.id new_contact = Contact.find_by(registrar_id: registrar_id) - @domain.domain_contacts[0].update!(contact_id: new_contact.id) + @domain.admin_domain_contacts[0].update!(contact_id: new_contact.id) post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } From 3bfac1ba436dd12023f0cb98391ae7c8c5e6e3eb Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 22 Jan 2021 19:49:06 +0200 Subject: [PATCH 052/132] compare fix --- test/integration/epp/domain/transfer/request_test.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 795d1c3d5..f38947649 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -26,7 +26,8 @@ class EppDomainTransferRequestTest < EppTestCase assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - assert_equal result_hash[new_contact.id], 1 + puts "Shared registrar and tech: #{result_hash}" + assert result_hash[new_contact.id] < 2 end def test_transfer_domain_with_contacts_if_registrant_and_admin_are_shared @@ -41,9 +42,9 @@ class EppDomainTransferRequestTest < EppTestCase @domain.reload assert_epp_response :completed_successfully - result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - assert_equal result_hash[new_contact.id], 1 + puts "Shared registrar and tech: #{result_hash}" + assert result_hash[new_contact.id] < 2 end def test_transfer_domain_with_contacts_if_admin_and_tech_are_shared From a336ee95f85b86b578379fa428e140a4146bc5bb Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 22 Jan 2021 20:27:37 +0200 Subject: [PATCH 053/132] fixed compare --- .../epp/domain/transfer/request_test.rb | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index f38947649..160a6915a 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -18,15 +18,32 @@ class EppDomainTransferRequestTest < EppTestCase new_contact = Contact.find_by(registrar_id: registrar_id) @domain.tech_domain_contacts[0].update!(contact_id: new_contact.id) + @domain.reload + + puts + puts "test_transfer_domain_with_contacts_if_registrant_and_tech_are_shared" + puts "Registrar id #{new_contact.id}" + puts "Tech #{@domain.tech_domain_contacts[0].contact_id}" + puts "Tech #{@domain.tech_domain_contacts[1].contact_id}" + puts "Admin #{@domain.admin_domain_contacts[0].contact_id}" post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } @domain.reload + registrar_id = @domain.registrar.id + new_contact_2 = Contact.find_by(registrar_id: registrar_id) + + puts "Registrar id #{new_contact_2.id}" + puts "Tech #{@domain.tech_domain_contacts[0].contact_id}" + puts "Tech #{@domain.tech_domain_contacts[1].contact_id}" + puts "Admin #{@domain.admin_domain_contacts[0].contact_id}" + assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - puts "Shared registrar and tech: #{result_hash}" + + puts "Result hash #{result_hash}" assert result_hash[new_contact.id] < 2 end @@ -35,15 +52,31 @@ class EppDomainTransferRequestTest < EppTestCase new_contact = Contact.find_by(registrar_id: registrar_id) @domain.admin_domain_contacts[0].update!(contact_id: new_contact.id) + @domain.reload + + puts + puts "test_transfer_domain_with_contacts_if_registrant_and_admin_are_shared" + puts "Registrar id #{new_contact.id}" + puts "Tech 1 #{@domain.tech_domain_contacts[0].contact_id}" # ????? + puts "Tech 2 #{@domain.tech_domain_contacts[1].contact_id}" + puts "Admin #{@domain.admin_domain_contacts[0].contact_id}" post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } @domain.reload + registrar_id = @domain.registrar.id + new_contact_2 = Contact.find_by(registrar_id: registrar_id) + + puts "Registrar id #{new_contact_2.id}" + puts "Tech 1 #{@domain.tech_domain_contacts[0].contact_id}" + puts "Tech 2 #{@domain.tech_domain_contacts[1].contact_id}" + puts "Admin #{@domain.admin_domain_contacts[0].contact_id}" + assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - puts "Shared registrar and tech: #{result_hash}" + puts "Result hash #{result_hash}" assert result_hash[new_contact.id] < 2 end From 72c9e894fa77205cc9ba3e0f1edc5eabd2b7c8fd Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 22 Jan 2021 21:07:18 +0200 Subject: [PATCH 054/132] fixed --- .../epp/domain/transfer/request_test.rb | 36 ++++--------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 160a6915a..a0a49c289 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -20,13 +20,6 @@ class EppDomainTransferRequestTest < EppTestCase @domain.tech_domain_contacts[0].update!(contact_id: new_contact.id) @domain.reload - puts - puts "test_transfer_domain_with_contacts_if_registrant_and_tech_are_shared" - puts "Registrar id #{new_contact.id}" - puts "Tech #{@domain.tech_domain_contacts[0].contact_id}" - puts "Tech #{@domain.tech_domain_contacts[1].contact_id}" - puts "Admin #{@domain.admin_domain_contacts[0].contact_id}" - post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } @@ -35,48 +28,33 @@ class EppDomainTransferRequestTest < EppTestCase registrar_id = @domain.registrar.id new_contact_2 = Contact.find_by(registrar_id: registrar_id) - puts "Registrar id #{new_contact_2.id}" - puts "Tech #{@domain.tech_domain_contacts[0].contact_id}" - puts "Tech #{@domain.tech_domain_contacts[1].contact_id}" - puts "Admin #{@domain.admin_domain_contacts[0].contact_id}" assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - puts "Result hash #{result_hash}" assert result_hash[new_contact.id] < 2 end + # ??????????????????? def test_transfer_domain_with_contacts_if_registrant_and_admin_are_shared registrar_id = @domain.registrar.id new_contact = Contact.find_by(registrar_id: registrar_id) @domain.admin_domain_contacts[0].update!(contact_id: new_contact.id) + + # ????????? need to find out + @domain.tech_domain_contacts[1].delete @domain.reload - - puts - puts "test_transfer_domain_with_contacts_if_registrant_and_admin_are_shared" - puts "Registrar id #{new_contact.id}" - puts "Tech 1 #{@domain.tech_domain_contacts[0].contact_id}" # ????? - puts "Tech 2 #{@domain.tech_domain_contacts[1].contact_id}" - puts "Admin #{@domain.admin_domain_contacts[0].contact_id}" + # ?????????????????????????? post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } @domain.reload - registrar_id = @domain.registrar.id - new_contact_2 = Contact.find_by(registrar_id: registrar_id) - - puts "Registrar id #{new_contact_2.id}" - puts "Tech 1 #{@domain.tech_domain_contacts[0].contact_id}" - puts "Tech 2 #{@domain.tech_domain_contacts[1].contact_id}" - puts "Admin #{@domain.admin_domain_contacts[0].contact_id}" - assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - puts "Result hash #{result_hash}" + assert result_hash[new_contact.id] < 2 end @@ -88,8 +66,6 @@ class EppDomainTransferRequestTest < EppTestCase post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } - @domain.reload - assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) assert_equal result_hash[contact_id], 2 From 6b053d026058bebbb1d635a1f0e5bc934cddc003 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 22 Jan 2021 21:14:15 +0200 Subject: [PATCH 055/132] fixed --- test/integration/epp/domain/transfer/request_test.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index a0a49c289..7ab45b891 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -54,7 +54,9 @@ class EppDomainTransferRequestTest < EppTestCase assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - + puts @domain.admin_domain_contacts[0].contact_id + puts @domain.tech_domain_contacts[0].contact_id + puts result_hash assert result_hash[new_contact.id] < 2 end From fc0aeefcc1df7f85927e5c59d0d1b725c91491fb Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 22 Jan 2021 21:46:02 +0200 Subject: [PATCH 056/132] fixed --- test/integration/epp/domain/transfer/request_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 7ab45b891..91ca47a21 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -41,6 +41,7 @@ class EppDomainTransferRequestTest < EppTestCase new_contact = Contact.find_by(registrar_id: registrar_id) @domain.admin_domain_contacts[0].update!(contact_id: new_contact.id) + @domain.tech_domain_contacts[0].update!(contact_id: '999914115') # ????????? # ????????? need to find out @domain.tech_domain_contacts[1].delete From 0f789895557e1b55424fb2f9279fed61baba47bb Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 22 Jan 2021 22:13:28 +0200 Subject: [PATCH 057/132] fixed --- .../epp/domain/transfer/request_test.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 91ca47a21..185bd6b7c 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -55,9 +55,6 @@ class EppDomainTransferRequestTest < EppTestCase assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - puts @domain.admin_domain_contacts[0].contact_id - puts @domain.tech_domain_contacts[0].contact_id - puts result_hash assert result_hash[new_contact.id] < 2 end @@ -69,9 +66,16 @@ class EppDomainTransferRequestTest < EppTestCase post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + @domain.reload + + contact = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) assert_equal result_hash[contact_id], 2 + + result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) + assert result_hash_codes[contact.code] > 1 end def test_transfer_domain_with_contacts_if_admin_and_tech_and_registrant_are_shared @@ -84,9 +88,16 @@ class EppDomainTransferRequestTest < EppTestCase post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + @domain.reload + + contact = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) assert_equal result_hash[new_contact.id], 2 + + result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) + assert result_hash_codes[contact.code] > 1 end def test_transfers_domain_at_once From ccbde76473b9f00c43c3fef93c8a4216b360cc8b Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Sat, 23 Jan 2021 09:38:22 +0200 Subject: [PATCH 058/132] Update transfer domain with shared contacts --- .../epp/domain/transfer/request_test.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 185bd6b7c..dd306c80d 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -25,14 +25,14 @@ class EppDomainTransferRequestTest < EppTestCase @domain.reload - registrar_id = @domain.registrar.id - new_contact_2 = Contact.find_by(registrar_id: registrar_id) - + contact = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - assert result_hash[new_contact.id] < 2 + + result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) + assert result_hash_codes[contact.code] < 2 end # ??????????????????? @@ -53,13 +53,20 @@ class EppDomainTransferRequestTest < EppTestCase @domain.reload + contact_one = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + contact_two = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) + assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) assert result_hash[new_contact.id] < 2 + + result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) + assert result_hash_codes[contact_one.code] < 2 + assert result_hash_codes[contact_two.code] < 2 + end def test_transfer_domain_with_contacts_if_admin_and_tech_are_shared - contact_id = @domain.domain_contacts[0].contact_id @domain.domain_contacts[1].update!(contact_id: contact_id) From 9e88e74cc3b878eb309904c8b2fa80c4d74dc244 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Sat, 23 Jan 2021 11:38:58 +0200 Subject: [PATCH 059/132] Update transfer domain with shared contacts --- .../epp/domain/transfer/request_test.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index dd306c80d..8aed6fd48 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class EppDomainTransferRequestTest < EppTestCase def setup @domain = domains(:shop) - @domain_library = domains(:library) + @contact = contacts(:william) @new_registrar = registrars(:goodnames) @original_transfer_wait_time = Setting.transfer_wait_time Setting.transfer_wait_time = 0 @@ -67,22 +67,26 @@ class EppDomainTransferRequestTest < EppTestCase end def test_transfer_domain_with_contacts_if_admin_and_tech_are_shared - contact_id = @domain.domain_contacts[0].contact_id - @domain.domain_contacts[1].update!(contact_id: contact_id) + @domain.admin_domain_contacts[0].update!(contact_id: @contact.id) + @domain.tech_domain_contacts[0].update!(contact_id: @contact.id) post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } @domain.reload - contact = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + contact_fresh = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - assert_equal result_hash[contact_id], 2 + assert_equal result_hash[contact_fresh.original_id], 2 result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - assert result_hash_codes[contact.code] > 1 + assert result_hash_codes[contact_fresh.code] > 1 + + assert_equal @contact.phone, contact_fresh.phone + assert_equal @contact.name, contact_fresh.name + assert_equal @contact.ident, contact_fresh.ident end def test_transfer_domain_with_contacts_if_admin_and_tech_and_registrant_are_shared From a7c708bdf0066d9f409db9d37bb248b87303f796 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Sat, 23 Jan 2021 11:48:00 +0200 Subject: [PATCH 060/132] Update transfer domain with shared contacts --- test/integration/epp/domain/transfer/request_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 8aed6fd48..cd67639ee 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class EppDomainTransferRequestTest < EppTestCase def setup @domain = domains(:shop) - @contact = contacts(:william) + @contact = contacts(:jane) @new_registrar = registrars(:goodnames) @original_transfer_wait_time = Setting.transfer_wait_time Setting.transfer_wait_time = 0 From f0ca552cc1ba9f10920028702e71f4d7009aeab2 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Sat, 23 Jan 2021 11:55:40 +0200 Subject: [PATCH 061/132] Update transfer domain with shared contacts --- .../epp/domain/transfer/request_test.rb | 104 +++++++++--------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index cd67639ee..63c49d997 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -13,58 +13,58 @@ class EppDomainTransferRequestTest < EppTestCase Setting.transfer_wait_time = @original_transfer_wait_time end - def test_transfer_domain_with_contacts_if_registrant_and_tech_are_shared - registrar_id = @domain.registrar.id - new_contact = Contact.find_by(registrar_id: registrar_id) + # def test_transfer_domain_with_contacts_if_registrant_and_tech_are_shared + # registrar_id = @domain.registrar.id + # new_contact = Contact.find_by(registrar_id: registrar_id) - @domain.tech_domain_contacts[0].update!(contact_id: new_contact.id) - @domain.reload + # @domain.tech_domain_contacts[0].update!(contact_id: new_contact.id) + # @domain.reload - post epp_transfer_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + # post epp_transfer_path, params: { frame: request_xml }, + # headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } - @domain.reload + # @domain.reload - contact = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + # contact = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) - assert_epp_response :completed_successfully - result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - assert result_hash[new_contact.id] < 2 + # assert_epp_response :completed_successfully + # result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) + # assert result_hash[new_contact.id] < 2 - result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - assert result_hash_codes[contact.code] < 2 - end + # result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) + # assert result_hash_codes[contact.code] < 2 + # end - # ??????????????????? - def test_transfer_domain_with_contacts_if_registrant_and_admin_are_shared - registrar_id = @domain.registrar.id - new_contact = Contact.find_by(registrar_id: registrar_id) + # # ??????????????????? + # def test_transfer_domain_with_contacts_if_registrant_and_admin_are_shared + # registrar_id = @domain.registrar.id + # new_contact = Contact.find_by(registrar_id: registrar_id) - @domain.admin_domain_contacts[0].update!(contact_id: new_contact.id) - @domain.tech_domain_contacts[0].update!(contact_id: '999914115') # ????????? + # @domain.admin_domain_contacts[0].update!(contact_id: new_contact.id) + # @domain.tech_domain_contacts[0].update!(contact_id: '999914115') # ????????? - # ????????? need to find out - @domain.tech_domain_contacts[1].delete - @domain.reload - # ?????????????????????????? + # # ????????? need to find out + # @domain.tech_domain_contacts[1].delete + # @domain.reload + # # ?????????????????????????? - post epp_transfer_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + # post epp_transfer_path, params: { frame: request_xml }, + # headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } - @domain.reload + # @domain.reload - contact_one = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) - contact_two = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) + # contact_one = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + # contact_two = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) - assert_epp_response :completed_successfully - result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - assert result_hash[new_contact.id] < 2 + # assert_epp_response :completed_successfully + # result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) + # assert result_hash[new_contact.id] < 2 - result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - assert result_hash_codes[contact_one.code] < 2 - assert result_hash_codes[contact_two.code] < 2 + # result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) + # assert result_hash_codes[contact_one.code] < 2 + # assert result_hash_codes[contact_two.code] < 2 - end + # end def test_transfer_domain_with_contacts_if_admin_and_tech_are_shared @domain.admin_domain_contacts[0].update!(contact_id: @contact.id) @@ -89,27 +89,27 @@ class EppDomainTransferRequestTest < EppTestCase assert_equal @contact.ident, contact_fresh.ident end - def test_transfer_domain_with_contacts_if_admin_and_tech_and_registrant_are_shared - registrar_id = @domain.registrar.id - new_contact = Contact.find_by(registrar_id: registrar_id) + # def test_transfer_domain_with_contacts_if_admin_and_tech_and_registrant_are_shared + # registrar_id = @domain.registrar.id + # new_contact = Contact.find_by(registrar_id: registrar_id) - @domain.admin_domain_contacts[0].update!(contact_id: new_contact.id) - @domain.tech_domain_contacts[0].update!(contact_id: new_contact.id) + # @domain.admin_domain_contacts[0].update!(contact_id: new_contact.id) + # @domain.tech_domain_contacts[0].update!(contact_id: new_contact.id) - post epp_transfer_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + # post epp_transfer_path, params: { frame: request_xml }, + # headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } - @domain.reload + # @domain.reload - contact = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + # contact = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) - assert_epp_response :completed_successfully - result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - assert_equal result_hash[new_contact.id], 2 + # assert_epp_response :completed_successfully + # result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) + # assert_equal result_hash[new_contact.id], 2 - result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - assert result_hash_codes[contact.code] > 1 - end + # result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) + # assert result_hash_codes[contact.code] > 1 + # end def test_transfers_domain_at_once post epp_transfer_path, params: { frame: request_xml }, From a1815314ce73fffc623396cf018952093a06e0f6 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Sat, 23 Jan 2021 12:09:27 +0200 Subject: [PATCH 062/132] Update transfer domain with shared contacts --- .../epp/domain/transfer/request_test.rb | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 63c49d997..6fa31a907 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -89,27 +89,31 @@ class EppDomainTransferRequestTest < EppTestCase assert_equal @contact.ident, contact_fresh.ident end - # def test_transfer_domain_with_contacts_if_admin_and_tech_and_registrant_are_shared - # registrar_id = @domain.registrar.id - # new_contact = Contact.find_by(registrar_id: registrar_id) + def test_transfer_domain_with_contacts_if_admin_and_tech_and_registrant_are_shared + registrar_id = @domain.registrar.id + contact = Contact.find_by(registrar_id: registrar_id) - # @domain.admin_domain_contacts[0].update!(contact_id: new_contact.id) - # @domain.tech_domain_contacts[0].update!(contact_id: new_contact.id) + @domain.admin_domain_contacts[0].update!(contact_id: contact.id) + @domain.tech_domain_contacts[0].update!(contact_id: contact.id) - # post epp_transfer_path, params: { frame: request_xml }, - # headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + post epp_transfer_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } - # @domain.reload + @domain.reload - # contact = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + contact_fresh = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) - # assert_epp_response :completed_successfully - # result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - # assert_equal result_hash[new_contact.id], 2 + assert_epp_response :completed_successfully + result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) + assert_equal result_hash[contact.id], 2 - # result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - # assert result_hash_codes[contact.code] > 1 - # end + result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) + assert result_hash_codes[contact_fresh.code] > 1 + + assert_equal contact.phone, contact_fresh.phone + assert_equal contact.name, contact_fresh.name + assert_equal contact.ident, contact_fresh.ident + end def test_transfers_domain_at_once post epp_transfer_path, params: { frame: request_xml }, From e0c0b0942e4a1afe6ab8deadb2efff4d9f530e30 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Sat, 23 Jan 2021 12:29:58 +0200 Subject: [PATCH 063/132] Update transfer domain with shared contacts --- .../epp/domain/transfer/request_test.rb | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 6fa31a907..4a75de412 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -13,27 +13,35 @@ class EppDomainTransferRequestTest < EppTestCase Setting.transfer_wait_time = @original_transfer_wait_time end - # def test_transfer_domain_with_contacts_if_registrant_and_tech_are_shared - # registrar_id = @domain.registrar.id - # new_contact = Contact.find_by(registrar_id: registrar_id) + def test_transfer_domain_with_contacts_if_registrant_and_tech_are_shared + registrar_id = @domain.registrar.id + new_contact = Contact.find_by(registrar_id: registrar_id) - # @domain.tech_domain_contacts[0].update!(contact_id: new_contact.id) - # @domain.reload + @domain.tech_domain_contacts[0].update!(contact_id: new_contact.id) - # post epp_transfer_path, params: { frame: request_xml }, - # headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + # ???????? + @domain.tech_domain_contacts[1].delete + @domain.reload + # ??????? - # @domain.reload + post epp_transfer_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } - # contact = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + @domain.reload - # assert_epp_response :completed_successfully - # result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - # assert result_hash[new_contact.id] < 2 + contact_fresh = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) - # result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - # assert result_hash_codes[contact.code] < 2 - # end + assert_epp_response :completed_successfully + result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) + assert result_hash[new_contact.id] < 2 + + result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) + assert result_hash_codes[contact_fresh.code] < 2 + + assert_equal new_contact.phone, contact_fresh.phone + assert_equal new_contact.name, contact_fresh.name + assert_equal new_contact.ident, contact_fresh.ident + end # # ??????????????????? # def test_transfer_domain_with_contacts_if_registrant_and_admin_are_shared From 42b6f55ce3539fc81b6be0042b605f7a8f541613 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Sat, 23 Jan 2021 14:11:08 +0200 Subject: [PATCH 064/132] Update transfer domain with shared contacts --- .../epp/domain/transfer/request_test.rb | 78 +++++++++++-------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 4a75de412..6eebb947e 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -29,55 +29,60 @@ class EppDomainTransferRequestTest < EppTestCase @domain.reload - contact_fresh = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) + contact_one = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + contact_two = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) assert result_hash[new_contact.id] < 2 result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - assert result_hash_codes[contact_fresh.code] < 2 + assert result_hash_codes[contact_two.code] < 2 - assert_equal new_contact.phone, contact_fresh.phone - assert_equal new_contact.name, contact_fresh.name - assert_equal new_contact.ident, contact_fresh.ident + refute_equal contact_one, contact_two end - # # ??????????????????? - # def test_transfer_domain_with_contacts_if_registrant_and_admin_are_shared - # registrar_id = @domain.registrar.id - # new_contact = Contact.find_by(registrar_id: registrar_id) + # ??????????????????? + def test_transfer_domain_with_contacts_if_registrant_and_admin_are_shared + registrar_id = @domain.registrar.id + new_contact = Contact.find_by(registrar_id: registrar_id) - # @domain.admin_domain_contacts[0].update!(contact_id: new_contact.id) - # @domain.tech_domain_contacts[0].update!(contact_id: '999914115') # ????????? + @domain.admin_domain_contacts[0].update!(contact_id: new_contact.id) + @domain.tech_domain_contacts[0].update!(contact_id: @contact.id) # ????????? - # # ????????? need to find out - # @domain.tech_domain_contacts[1].delete - # @domain.reload - # # ?????????????????????????? + # ????????? need to find out + @domain.tech_domain_contacts[1].delete + @domain.reload + # ?????????????????????????? - # post epp_transfer_path, params: { frame: request_xml }, - # headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + post epp_transfer_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } - # @domain.reload + @domain.reload - # contact_one = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) - # contact_two = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) + contact_one = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + contact_two = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) - # assert_epp_response :completed_successfully - # result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - # assert result_hash[new_contact.id] < 2 + assert_epp_response :completed_successfully + result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) + assert result_hash[new_contact.id] < 2 - # result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - # assert result_hash_codes[contact_one.code] < 2 - # assert result_hash_codes[contact_two.code] < 2 + result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) + assert result_hash_codes[contact_one.code] < 2 + assert result_hash_codes[contact_two.code] < 2 - # end + refute_equal contact_one, contact_two + end def test_transfer_domain_with_contacts_if_admin_and_tech_are_shared @domain.admin_domain_contacts[0].update!(contact_id: @contact.id) @domain.tech_domain_contacts[0].update!(contact_id: @contact.id) + # ?????????????? + @domain.tech_domain_contacts[1].delete + @domain.reload + # ?????????????? + post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } @@ -92,9 +97,8 @@ class EppDomainTransferRequestTest < EppTestCase result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) assert result_hash_codes[contact_fresh.code] > 1 - assert_equal @contact.phone, contact_fresh.phone - assert_equal @contact.name, contact_fresh.name - assert_equal @contact.ident, contact_fresh.ident + assert_equal @domain.tech_domain_contacts[0].contact_id, + @domain.admin_domain_contacts[0].contact_id end def test_transfer_domain_with_contacts_if_admin_and_tech_and_registrant_are_shared @@ -104,13 +108,20 @@ class EppDomainTransferRequestTest < EppTestCase @domain.admin_domain_contacts[0].update!(contact_id: contact.id) @domain.tech_domain_contacts[0].update!(contact_id: contact.id) + # ?????????????? + @domain.tech_domain_contacts[1].delete + @domain.reload + # ?????????????? + post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } @domain.reload - contact_fresh = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + @domain.registrar.id + contact = Contact.find_by(registrar_id: registrar_id) + assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) assert_equal result_hash[contact.id], 2 @@ -118,9 +129,8 @@ class EppDomainTransferRequestTest < EppTestCase result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) assert result_hash_codes[contact_fresh.code] > 1 - assert_equal contact.phone, contact_fresh.phone - assert_equal contact.name, contact_fresh.name - assert_equal contact.ident, contact_fresh.ident + assert_equal @domain.tech_domain_contacts[0].contact_id, + @domain.admin_domain_contacts[0].contact_id end def test_transfers_domain_at_once From 8396fe3750044182af502989c5cf263f03c41fd6 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Sat, 23 Jan 2021 14:29:02 +0200 Subject: [PATCH 065/132] Update transfer domain with shared contacts --- test/integration/epp/domain/transfer/request_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 6eebb947e..f4b519577 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -122,6 +122,12 @@ class EppDomainTransferRequestTest < EppTestCase @domain.registrar.id contact = Contact.find_by(registrar_id: registrar_id) + registrar_id_2 = @domain.registrar.id + contact_2 = Contact.find_by(registrar_id: registrar_id_2) + + one = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) + two = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) assert_equal result_hash[contact.id], 2 @@ -129,8 +135,10 @@ class EppDomainTransferRequestTest < EppTestCase result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) assert result_hash_codes[contact_fresh.code] > 1 + # Contacts must belong to the same registrar assert_equal @domain.tech_domain_contacts[0].contact_id, @domain.admin_domain_contacts[0].contact_id + assert_equal one.registrar_id == two.registrar_id, one.registrar_id == contact_2.registrar_id end def test_transfers_domain_at_once From a1bacbd4e71dd4e20dc79c454bc4bd80ef33c131 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Sat, 23 Jan 2021 14:55:24 +0200 Subject: [PATCH 066/132] Update transfer domain with shared contacts: added more asserts --- .../epp/domain/transfer/request_test.rb | 55 +++++++++++-------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index f4b519577..f87a60535 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -29,26 +29,30 @@ class EppDomainTransferRequestTest < EppTestCase @domain.reload - contact_one = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) - contact_two = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) + admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) assert result_hash[new_contact.id] < 2 result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - assert result_hash_codes[contact_two.code] < 2 + assert result_hash_codes[tech.code] < 2 - refute_equal contact_one, contact_two + refute_equal admin, tech + + # Contacts must belong to the same registrar + new_registrar = Contact.find_by(registrar_id: @domain.registrar.id) + + assert_equal admin.registrar_id == tech.registrar_id, admin.registrar_id == new_registrar.registrar_id end - # ??????????????????? def test_transfer_domain_with_contacts_if_registrant_and_admin_are_shared registrar_id = @domain.registrar.id new_contact = Contact.find_by(registrar_id: registrar_id) @domain.admin_domain_contacts[0].update!(contact_id: new_contact.id) - @domain.tech_domain_contacts[0].update!(contact_id: @contact.id) # ????????? + @domain.tech_domain_contacts[0].update!(contact_id: @contact.id) # ????????? need to find out @domain.tech_domain_contacts[1].delete @@ -60,18 +64,23 @@ class EppDomainTransferRequestTest < EppTestCase @domain.reload - contact_one = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) - contact_two = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) + admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) assert result_hash[new_contact.id] < 2 result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - assert result_hash_codes[contact_one.code] < 2 - assert result_hash_codes[contact_two.code] < 2 + assert result_hash_codes[admin.code] < 2 + assert result_hash_codes[tech.code] < 2 - refute_equal contact_one, contact_two + refute_equal admin, tech + + # Contacts must belong to the same registrar + new_registrar = Contact.find_by(registrar_id: @domain.registrar.id) + + assert_equal admin.registrar_id == tech.registrar_id, admin.registrar_id == new_registrar.registrar_id end def test_transfer_domain_with_contacts_if_admin_and_tech_are_shared @@ -88,17 +97,21 @@ class EppDomainTransferRequestTest < EppTestCase @domain.reload - contact_fresh = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - assert_equal result_hash[contact_fresh.original_id], 2 + assert_equal result_hash[admin.original_id], 2 result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - assert result_hash_codes[contact_fresh.code] > 1 + assert result_hash_codes[admin.code] > 1 - assert_equal @domain.tech_domain_contacts[0].contact_id, - @domain.admin_domain_contacts[0].contact_id + # Contacts must belong to the same registrar + new_registrar = Contact.find_by(registrar_id: @domain.registrar.id) + + assert_equal admin.registrar_id == tech.registrar_id, admin.registrar_id == new_registrar.registrar_id + assert_equal admin.id, tech.id end def test_transfer_domain_with_contacts_if_admin_and_tech_and_registrant_are_shared @@ -122,9 +135,6 @@ class EppDomainTransferRequestTest < EppTestCase @domain.registrar.id contact = Contact.find_by(registrar_id: registrar_id) - registrar_id_2 = @domain.registrar.id - contact_2 = Contact.find_by(registrar_id: registrar_id_2) - one = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) two = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) @@ -136,9 +146,10 @@ class EppDomainTransferRequestTest < EppTestCase assert result_hash_codes[contact_fresh.code] > 1 # Contacts must belong to the same registrar - assert_equal @domain.tech_domain_contacts[0].contact_id, - @domain.admin_domain_contacts[0].contact_id - assert_equal one.registrar_id == two.registrar_id, one.registrar_id == contact_2.registrar_id + new_registrar = Contact.find_by(registrar_id: @domain.registrar.id) + + assert_equal one.id, two.id + assert_equal one.registrar_id == two.registrar_id, two.registrar_id == new_registrar.registrar_id end def test_transfers_domain_at_once From b9090d76032b1eb10be586620397037002a7c204 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Mon, 25 Jan 2021 13:48:40 +0200 Subject: [PATCH 067/132] Update transfer domain with shared contacts --- .../epp/domain/transfer/request_test.rb | 79 +++++++------------ 1 file changed, 29 insertions(+), 50 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index f87a60535..9aa219a4f 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -14,10 +14,7 @@ class EppDomainTransferRequestTest < EppTestCase end def test_transfer_domain_with_contacts_if_registrant_and_tech_are_shared - registrar_id = @domain.registrar.id - new_contact = Contact.find_by(registrar_id: registrar_id) - - @domain.tech_domain_contacts[0].update!(contact_id: new_contact.id) + @domain.tech_domain_contacts[0].update!(contact_id: @domain.registrant.id) # ???????? @domain.tech_domain_contacts[1].delete @@ -27,31 +24,23 @@ class EppDomainTransferRequestTest < EppTestCase post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + assert_epp_response :completed_successfully + @domain.reload - admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) - assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - assert result_hash[new_contact.id] < 2 + assert result_hash[@domain.registrant.original_id] < 2 result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) assert result_hash_codes[tech.code] < 2 - refute_equal admin, tech - - # Contacts must belong to the same registrar - new_registrar = Contact.find_by(registrar_id: @domain.registrar.id) - - assert_equal admin.registrar_id == tech.registrar_id, admin.registrar_id == new_registrar.registrar_id + assert_equal tech.registrar_id, @domain.registrar.id end def test_transfer_domain_with_contacts_if_registrant_and_admin_are_shared - registrar_id = @domain.registrar.id - new_contact = Contact.find_by(registrar_id: registrar_id) - - @domain.admin_domain_contacts[0].update!(contact_id: new_contact.id) + @domain.admin_domain_contacts[0].update!(contact_id: @domain.registrant.id) @domain.tech_domain_contacts[0].update!(contact_id: @contact.id) # ????????? need to find out @@ -62,25 +51,21 @@ class EppDomainTransferRequestTest < EppTestCase post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + assert_epp_response :completed_successfully + @domain.reload admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) - assert_epp_response :completed_successfully result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - assert result_hash[new_contact.id] < 2 + assert result_hash[@domain.registrant.original_id] < 2 result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) assert result_hash_codes[admin.code] < 2 assert result_hash_codes[tech.code] < 2 - refute_equal admin, tech - - # Contacts must belong to the same registrar - new_registrar = Contact.find_by(registrar_id: @domain.registrar.id) - - assert_equal admin.registrar_id == tech.registrar_id, admin.registrar_id == new_registrar.registrar_id + assert_equal admin.registrar_id, @domain.registrar.id end def test_transfer_domain_with_contacts_if_admin_and_tech_are_shared @@ -95,31 +80,29 @@ class EppDomainTransferRequestTest < EppTestCase post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } + assert_epp_response :completed_successfully + @domain.reload admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) - assert_epp_response :completed_successfully + result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) assert_equal result_hash[admin.original_id], 2 result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) assert result_hash_codes[admin.code] > 1 - # Contacts must belong to the same registrar - new_registrar = Contact.find_by(registrar_id: @domain.registrar.id) + # Contacts must belong to the same registrant - assert_equal admin.registrar_id == tech.registrar_id, admin.registrar_id == new_registrar.registrar_id - assert_equal admin.id, tech.id + assert_equal admin.registrar_id, @domain.registrar.id + assert_equal tech.registrar_id, @domain.registrar.id end def test_transfer_domain_with_contacts_if_admin_and_tech_and_registrant_are_shared - registrar_id = @domain.registrar.id - contact = Contact.find_by(registrar_id: registrar_id) - - @domain.admin_domain_contacts[0].update!(contact_id: contact.id) - @domain.tech_domain_contacts[0].update!(contact_id: contact.id) + @domain.tech_domain_contacts[0].update!(contact_id: @domain.registrant.id) + @domain.admin_domain_contacts[0].update!(contact_id: @domain.registrant.id) # ?????????????? @domain.tech_domain_contacts[1].delete @@ -129,27 +112,23 @@ class EppDomainTransferRequestTest < EppTestCase post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } - @domain.reload - contact_fresh = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) - - @domain.registrar.id - contact = Contact.find_by(registrar_id: registrar_id) - - one = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) - two = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) - assert_epp_response :completed_successfully + + @domain.reload + + admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) + tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) + result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - assert_equal result_hash[contact.id], 2 + assert_equal result_hash[@domain.registrant.original_id], 2 result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - assert result_hash_codes[contact_fresh.code] > 1 + assert result_hash_codes[@domain.registrant.code] > 1 - # Contacts must belong to the same registrar - new_registrar = Contact.find_by(registrar_id: @domain.registrar.id) + # Contacts must belong to the same registrant - assert_equal one.id, two.id - assert_equal one.registrar_id == two.registrar_id, two.registrar_id == new_registrar.registrar_id + assert_equal admin.registrar_id, @domain.registrar.id + assert_equal tech.registrar_id, @domain.registrar.id end def test_transfers_domain_at_once From aa1b69d431cc018e973545aa3189253d2e181337 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Mon, 25 Jan 2021 14:42:04 +0200 Subject: [PATCH 068/132] Update transfer domain with shared contacts --- .../epp/domain/transfer/request_test.rb | 31 ++++--------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 9aa219a4f..9b2894dd7 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -30,12 +30,7 @@ class EppDomainTransferRequestTest < EppTestCase tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) - result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - assert result_hash[@domain.registrant.original_id] < 2 - - result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - assert result_hash_codes[tech.code] < 2 - + assert_equal @domain.contacts.where(original_id: @domain.registrant.original_id).count, 1 assert_equal tech.registrar_id, @domain.registrar.id end @@ -56,15 +51,8 @@ class EppDomainTransferRequestTest < EppTestCase @domain.reload admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) - tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) - - result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - assert result_hash[@domain.registrant.original_id] < 2 - - result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - assert result_hash_codes[admin.code] < 2 - assert result_hash_codes[tech.code] < 2 + assert_equal @domain.contacts.where(original_id: @domain.registrant.original_id).count, 1 assert_equal admin.registrar_id, @domain.registrar.id end @@ -87,13 +75,8 @@ class EppDomainTransferRequestTest < EppTestCase admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) - result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - assert_equal result_hash[admin.original_id], 2 - - result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - assert result_hash_codes[admin.code] > 1 - + assert result_hash[admin.original_id], 2 # Contacts must belong to the same registrant assert_equal admin.registrar_id, @domain.registrar.id @@ -119,12 +102,10 @@ class EppDomainTransferRequestTest < EppTestCase admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id) tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id) - result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) - assert_equal result_hash[@domain.registrant.original_id], 2 - - result_hash_codes = @domain.contacts.pluck(:code).group_by(&:itself).transform_values(&:count) - assert result_hash_codes[@domain.registrant.code] > 1 + assert_equal @domain.contacts.where(original_id: @domain.registrant.original_id).count, 2 + result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) + assert result_hash[@domain.registrant.original_id], 2 # Contacts must belong to the same registrant assert_equal admin.registrar_id, @domain.registrar.id From c6cc18fd71e5d05a759db13ae15f97ec5dcdfe07 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 28 Jan 2021 10:45:22 +0200 Subject: [PATCH 069/132] refactoring: remoce useless comments --- test/integration/epp/domain/transfer/request_test.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 9b2894dd7..273a9f490 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -16,10 +16,8 @@ class EppDomainTransferRequestTest < EppTestCase def test_transfer_domain_with_contacts_if_registrant_and_tech_are_shared @domain.tech_domain_contacts[0].update!(contact_id: @domain.registrant.id) - # ???????? @domain.tech_domain_contacts[1].delete @domain.reload - # ??????? post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } @@ -38,10 +36,8 @@ class EppDomainTransferRequestTest < EppTestCase @domain.admin_domain_contacts[0].update!(contact_id: @domain.registrant.id) @domain.tech_domain_contacts[0].update!(contact_id: @contact.id) - # ????????? need to find out @domain.tech_domain_contacts[1].delete @domain.reload - # ?????????????????????????? post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } @@ -60,10 +56,8 @@ class EppDomainTransferRequestTest < EppTestCase @domain.admin_domain_contacts[0].update!(contact_id: @contact.id) @domain.tech_domain_contacts[0].update!(contact_id: @contact.id) - # ?????????????? @domain.tech_domain_contacts[1].delete @domain.reload - # ?????????????? post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } @@ -77,7 +71,6 @@ class EppDomainTransferRequestTest < EppTestCase result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) assert result_hash[admin.original_id], 2 - # Contacts must belong to the same registrant assert_equal admin.registrar_id, @domain.registrar.id assert_equal tech.registrar_id, @domain.registrar.id @@ -87,10 +80,8 @@ class EppDomainTransferRequestTest < EppTestCase @domain.tech_domain_contacts[0].update!(contact_id: @domain.registrant.id) @domain.admin_domain_contacts[0].update!(contact_id: @domain.registrant.id) - # ?????????????? @domain.tech_domain_contacts[1].delete @domain.reload - # ?????????????? post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } @@ -106,7 +97,6 @@ class EppDomainTransferRequestTest < EppTestCase result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count) assert result_hash[@domain.registrant.original_id], 2 - # Contacts must belong to the same registrant assert_equal admin.registrar_id, @domain.registrar.id assert_equal tech.registrar_id, @domain.registrar.id From 7e76d65293e8271cfa017f2cd659d87e35c059ae Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Thu, 28 Jan 2021 14:31:50 +0500 Subject: [PATCH 070/132] Resolve issue with possible freezes on nil raw_frame --- config/initializers/filter_parameter_logging.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index f2acc88e6..4f4e68288 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,9 +1,9 @@ Rails.application.configure do config.filter_parameters += [:password, /^frame$/, /^nokogiri_frame$/, /^parsed_frame$/] config.filter_parameters << lambda do |key, value| - if key == 'raw_frame' - value.to_s.gsub!(/pw>.+<\//, 'pw>[FILTERED]]+)>([^<])+<\/eis:legalDocument>/, + if key == 'raw_frame' && value.respond_to?(:gsub!) + value.gsub!(/pw>.+<\//, 'pw>[FILTERED]]+)>([^<])+<\/eis:legalDocument>/, "[FILTERED]") end end From 560d9111ce6fa917342cf479aff27f366ac121bb Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Tue, 26 Jan 2021 13:04:02 +0200 Subject: [PATCH 071/132] added tests for not unique contacts --- .../epp/domain/create/base_test.rb | 227 ++++++++++++++++++ 1 file changed, 227 insertions(+) diff --git a/test/integration/epp/domain/create/base_test.rb b/test/integration/epp/domain/create/base_test.rb index e3b7a39ee..c0cef74b8 100644 --- a/test/integration/epp/domain/create/base_test.rb +++ b/test/integration/epp/domain/create/base_test.rb @@ -76,6 +76,233 @@ class EppDomainCreateBaseTest < EppTestCase assert_epp_response :required_parameter_missing end + def test_create_domain_with_unique_contact + now = Time.zone.parse('2010-07-05') + travel_to now + name = "new.#{dns_zones(:one).origin}" + contact = contacts(:john) + registrant = contact.becomes(Registrant) + + request_xml = <<-XML + + + + + + #{name} + #{registrant.code} + #{contacts(:jane).code} + #{contacts(:william).code} + + + + + #{'test' * 2000} + + + + + XML + + assert_difference 'Domain.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end + assert_epp_response :completed_successfully + end + + + def test_create_domain_with_array_of_not_unique_admins_and_techs + now = Time.zone.parse('2010-07-05') + travel_to now + name = "new.#{dns_zones(:one).origin}" + contact = contacts(:john) + registrant = contact.becomes(Registrant) + + request_xml = <<-XML + + + + + + #{name} + #{registrant.code} + #{contact.code} + #{contact.code} + #{contact.code} + #{contact.code} + + + + + #{'test' * 2000} + + + + + XML + + + + assert_no_difference 'Domain.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end + assert_epp_response :parameter_value_policy_error + end + + def test_create_domain_with_array_of_not_unique_admins + now = Time.zone.parse('2010-07-05') + travel_to now + name = "new.#{dns_zones(:one).origin}" + contact = contacts(:john) + registrant = contact.becomes(Registrant) + + request_xml = <<-XML + + + + + + #{name} + #{registrant.code} + #{contact.code} + #{contact.code} + #{contact.code} + + + + + #{'test' * 2000} + + + + + XML + + + + assert_no_difference 'Domain.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end + + assert_epp_response :parameter_value_policy_error + end + + def test_create_domain_with_array_of_not_unique_techs + now = Time.zone.parse('2010-07-05') + travel_to now + name = "new.#{dns_zones(:one).origin}" + contact = contacts(:john) + registrant = contact.becomes(Registrant) + + request_xml = <<-XML + + + + + + #{name} + #{registrant.code} + #{contact.code} + #{contact.code} + #{contact.code} + + + + + #{'test' * 2000} + + + + + XML + + assert_no_difference 'Domain.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end + + assert_epp_response :parameter_value_policy_error + end + + def test_create_domain_with_array_of_not_unique_admin_but_tech_another_one + now = Time.zone.parse('2010-07-05') + travel_to now + name = "new.#{dns_zones(:one).origin}" + contact = contacts(:john) + registrant = contact.becomes(Registrant) + contact_two = contacts(:william) + + request_xml = <<-XML + + + + + + #{name} + #{registrant.code} + #{contact.code} + #{contact.code} + #{contact_two.code} + + + + + #{'test' * 2000} + + + + + XML + + assert_no_difference 'Domain.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end + + assert_epp_response :parameter_value_policy_error + end + + def test_create_domain_with_array_of_not_unique_techs_but_admin_another_one + now = Time.zone.parse('2010-07-05') + travel_to now + name = "new.#{dns_zones(:one).origin}" + contact = contacts(:john) + registrant = contact.becomes(Registrant) + contact_two = contacts(:william) + + request_xml = <<-XML + + + + + + #{name} + #{registrant.code} + #{contact_two.code} + #{contact.code} + #{contact.code} + + + + + #{'test' * 2000} + + + + + XML + + assert_no_difference 'Domain.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end + + assert_epp_response :parameter_value_policy_error + end + def test_registers_new_domain_with_required_attributes now = Time.zone.parse('2010-07-05') travel_to now From 3dfb22d79dd9023f9ab55ca623f62a732a9f7a07 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Thu, 28 Jan 2021 16:31:35 +0500 Subject: [PATCH 072/132] Return epp error 2306 is tech are admin contacts are duplicated --- app/models/epp/domain.rb | 8 +++ .../epp/domain/create/base_test.rb | 53 +++++++++---------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index c4d70c2ee..ad96adc64 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -162,6 +162,9 @@ class Epp::Domain < Domain at[:admin_domain_contacts_attributes] = admin_domain_contacts_attrs(frame, action) at[:tech_domain_contacts_attributes] = tech_domain_contacts_attrs(frame, action) + check_for_same_contacts(at[:admin_domain_contacts_attributes], 'admin') + check_for_same_contacts(at[:tech_domain_contacts_attributes], 'tech') + pw = frame.css('authInfo > pw').text at[:transfer_code] = pw if pw.present? @@ -176,6 +179,11 @@ class Epp::Domain < Domain at end + def check_for_same_contacts(contacts, contact_type) + return unless contacts.uniq.count != contacts.count + + add_epp_error('2306', contact_type, nil, %i[domain_contacts invalid]) + end # Adding legal doc to domain and # if something goes wrong - raise Rollback error diff --git a/test/integration/epp/domain/create/base_test.rb b/test/integration/epp/domain/create/base_test.rb index c0cef74b8..cbbd8a57d 100644 --- a/test/integration/epp/domain/create/base_test.rb +++ b/test/integration/epp/domain/create/base_test.rb @@ -120,34 +120,33 @@ class EppDomainCreateBaseTest < EppTestCase registrant = contact.becomes(Registrant) request_xml = <<-XML - - - - - - #{name} - #{registrant.code} - #{contact.code} - #{contact.code} - #{contact.code} - #{contact.code} - - - - - #{'test' * 2000} - - - - - XML + + + + + + #{name} + #{registrant.code} + #{contact.code} + #{contact.code} + #{contact.code} + #{contact.code} + + + + + #{'test' * 2000} + + + + + XML - - - assert_no_difference 'Domain.count' do - post epp_create_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + assert_no_difference 'Domain.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } end + assert_epp_response :parameter_value_policy_error end @@ -180,7 +179,7 @@ class EppDomainCreateBaseTest < EppTestCase XML - + assert_no_difference 'Domain.count' do post epp_create_path, params: { frame: request_xml }, From 2648f66e78c1eefc012e2266a9228b74c4d36cc0 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 28 Jan 2021 14:09:07 +0200 Subject: [PATCH 073/132] made refactoring: remove paddings and line breaks --- .../epp/domain/create/base_test.rb | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/test/integration/epp/domain/create/base_test.rb b/test/integration/epp/domain/create/base_test.rb index cbbd8a57d..9f974ebf8 100644 --- a/test/integration/epp/domain/create/base_test.rb +++ b/test/integration/epp/domain/create/base_test.rb @@ -104,9 +104,9 @@ class EppDomainCreateBaseTest < EppTestCase XML - assert_difference 'Domain.count' do - post epp_create_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + assert_difference 'Domain.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } end assert_epp_response :completed_successfully end @@ -181,9 +181,9 @@ class EppDomainCreateBaseTest < EppTestCase - assert_no_difference 'Domain.count' do - post epp_create_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + assert_no_difference 'Domain.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } end assert_epp_response :parameter_value_policy_error @@ -218,12 +218,12 @@ class EppDomainCreateBaseTest < EppTestCase XML - assert_no_difference 'Domain.count' do - post epp_create_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + assert_no_difference 'Domain.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } end - assert_epp_response :parameter_value_policy_error + assert_epp_response :parameter_value_policy_error end def test_create_domain_with_array_of_not_unique_admin_but_tech_another_one @@ -254,14 +254,14 @@ class EppDomainCreateBaseTest < EppTestCase - XML + XML - assert_no_difference 'Domain.count' do - post epp_create_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } - end + assert_no_difference 'Domain.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end - assert_epp_response :parameter_value_policy_error + assert_epp_response :parameter_value_policy_error end def test_create_domain_with_array_of_not_unique_techs_but_admin_another_one @@ -292,14 +292,14 @@ class EppDomainCreateBaseTest < EppTestCase - XML + XML - assert_no_difference 'Domain.count' do - post epp_create_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } - end + assert_no_difference 'Domain.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end - assert_epp_response :parameter_value_policy_error + assert_epp_response :parameter_value_policy_error end def test_registers_new_domain_with_required_attributes From 18c994256f8d75a2f36845451beedea4f24892d1 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 28 Jan 2021 14:16:39 +0200 Subject: [PATCH 074/132] xml padding changed --- .../epp/domain/create/base_test.rb | 244 +++++++++--------- 1 file changed, 121 insertions(+), 123 deletions(-) diff --git a/test/integration/epp/domain/create/base_test.rb b/test/integration/epp/domain/create/base_test.rb index 9f974ebf8..35ef38179 100644 --- a/test/integration/epp/domain/create/base_test.rb +++ b/test/integration/epp/domain/create/base_test.rb @@ -13,30 +13,30 @@ class EppDomainCreateBaseTest < EppTestCase vrjxNMH6HtxW\rEA4RJ9Ao6LCWheg8" request_xml = <<-XML - - - - - - #{name} - #{registrant.code} - - - - - - 257 - 3 - 8 - #{pub_key} - - - - #{'test' * 2000} - - - - + + + + + + #{name} + #{registrant.code} + + + + + + 257 + 3 + 8 + #{pub_key} + + + + #{'test' * 2000} + + + + XML assert_no_difference 'Domain.count' do post epp_create_path, params: { frame: request_xml }, @@ -84,25 +84,25 @@ class EppDomainCreateBaseTest < EppTestCase registrant = contact.becomes(Registrant) request_xml = <<-XML - - - - - - #{name} - #{registrant.code} - #{contacts(:jane).code} - #{contacts(:william).code} - - - - - #{'test' * 2000} - - - - - XML + + + + + + #{name} + #{registrant.code} + #{contacts(:jane).code} + #{contacts(:william).code} + + + + + #{'test' * 2000} + + + + + XML assert_difference 'Domain.count' do post epp_create_path, params: { frame: request_xml }, @@ -158,28 +158,26 @@ class EppDomainCreateBaseTest < EppTestCase registrant = contact.becomes(Registrant) request_xml = <<-XML - - - - - - #{name} - #{registrant.code} - #{contact.code} - #{contact.code} - #{contact.code} - - - - - #{'test' * 2000} - - - - - XML - - + + + + + + #{name} + #{registrant.code} + #{contact.code} + #{contact.code} + #{contact.code} + + + + + #{'test' * 2000} + + + + + XML assert_no_difference 'Domain.count' do post epp_create_path, params: { frame: request_xml }, @@ -197,26 +195,26 @@ class EppDomainCreateBaseTest < EppTestCase registrant = contact.becomes(Registrant) request_xml = <<-XML - - - - - - #{name} - #{registrant.code} - #{contact.code} - #{contact.code} - #{contact.code} - - - - - #{'test' * 2000} - - - - - XML + + + + + + #{name} + #{registrant.code} + #{contact.code} + #{contact.code} + #{contact.code} + + + + + #{'test' * 2000} + + + + + XML assert_no_difference 'Domain.count' do post epp_create_path, params: { frame: request_xml }, @@ -235,25 +233,25 @@ class EppDomainCreateBaseTest < EppTestCase contact_two = contacts(:william) request_xml = <<-XML - - - - - - #{name} - #{registrant.code} - #{contact.code} - #{contact.code} - #{contact_two.code} - - - - - #{'test' * 2000} - - - - + + + + + + #{name} + #{registrant.code} + #{contact.code} + #{contact.code} + #{contact_two.code} + + + + + #{'test' * 2000} + + + + XML assert_no_difference 'Domain.count' do @@ -273,25 +271,25 @@ class EppDomainCreateBaseTest < EppTestCase contact_two = contacts(:william) request_xml = <<-XML - - - - - - #{name} - #{registrant.code} - #{contact_two.code} - #{contact.code} - #{contact.code} - - - - - #{'test' * 2000} - - - - + + + + + + #{name} + #{registrant.code} + #{contact_two.code} + #{contact.code} + #{contact.code} + + + + + #{'test' * 2000} + + + + XML assert_no_difference 'Domain.count' do From e22e282c31eae599e643d5b246ac695ff0c0cc45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Thu, 28 Jan 2021 15:19:07 +0200 Subject: [PATCH 075/132] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97d7afeb7..90abb0d34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ 28.01.2021 +* Fixed transfer with shared admin and tech contacts [#1808](https://github.com/internetee/registry/issues/1808) * Improved DNSSEC key validation for illegal characters [#1790](https://github.com/internetee/registry/issues/1790) * Fix for whois record creation issue on releasing domain to auction [#1139](https://github.com/internetee/registry/issues/1139) * Improved registrar account activity tests [#1824](https://github.com/internetee/registry/pull/1824) From 2ddfa45f98656acf57b41c307f6916a8cdfd1b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Thu, 28 Jan 2021 16:39:52 +0200 Subject: [PATCH 076/132] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90abb0d34..e2681c615 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ 28.01.2021 * Fixed transfer with shared admin and tech contacts [#1808](https://github.com/internetee/registry/issues/1808) +* Added CSV export option to admin [#1775](https://github.com/internetee/registry/issues/1775) * Improved DNSSEC key validation for illegal characters [#1790](https://github.com/internetee/registry/issues/1790) * Fix for whois record creation issue on releasing domain to auction [#1139](https://github.com/internetee/registry/issues/1139) * Improved registrar account activity tests [#1824](https://github.com/internetee/registry/pull/1824) From 5b8e6bb576fb1ffd6cf2b9db332b364cc16a271d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Thu, 28 Jan 2021 17:02:43 +0200 Subject: [PATCH 077/132] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2681c615..d23d879c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * Added CSV export option to admin [#1775](https://github.com/internetee/registry/issues/1775) * Improved DNSSEC key validation for illegal characters [#1790](https://github.com/internetee/registry/issues/1790) * Fix for whois record creation issue on releasing domain to auction [#1139](https://github.com/internetee/registry/issues/1139) +* Fix for handling malformed request frames [#1825](https://github.com/internetee/registry/issues/1825) * Improved registrar account activity tests [#1824](https://github.com/internetee/registry/pull/1824) 27.01.2021 From cb330d4f797f41e2702a5a0dc10c7147b0e687a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Thu, 28 Jan 2021 17:32:57 +0200 Subject: [PATCH 078/132] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d23d879c9..5585ca6f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ 28.01.2021 * Fixed transfer with shared admin and tech contacts [#1808](https://github.com/internetee/registry/issues/1808) +* Improved error handling with double admin/tech contacts [#1758](https://github.com/internetee/registry/issues/1758) * Added CSV export option to admin [#1775](https://github.com/internetee/registry/issues/1775) * Improved DNSSEC key validation for illegal characters [#1790](https://github.com/internetee/registry/issues/1790) * Fix for whois record creation issue on releasing domain to auction [#1139](https://github.com/internetee/registry/issues/1139) From 02b5c8c4b668739e4742e2684f3c9289a6b801cb Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 29 Jan 2021 11:59:07 +0200 Subject: [PATCH 079/132] refactored: extra line breaks, extra indentation, extra comments --- test/application_system_test_case.rb | 6 - .../admin_area/account_activities_test.rb | 2 +- .../admin_area/admin_users_test.rb | 4 +- .../admin_area/blocked_domains_test.rb | 38 +++-- .../admin_area/certificates_test.rb | 103 +++++++------ .../admin_area/delayed_jobs_test.rb | 10 -- test/integration/admin_area/epp_logs_test.rb | 87 +++++------ test/integration/admin_area/invoices_test.rb | 4 - .../admin_area/pending_delete_test.rb | 83 ++++++----- .../admin_area/pending_update_test.rb | 138 +++++++++--------- .../integration/admin_area/registrars_test.rb | 2 +- test/integration/admin_area/repp_logs_test.rb | 35 ++--- .../admin_area/reserved_domains_test.rb | 3 +- test/integration/admin_area/white_ips_test.rb | 135 +++++++++-------- test/system/admin_area/contacts_test.rb | 2 - test/system/admin_area/invoices_test.rb | 2 +- test/system/admin_area/protected_area_test.rb | 2 +- 17 files changed, 310 insertions(+), 346 deletions(-) delete mode 100644 test/integration/admin_area/delayed_jobs_test.rb diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index ec5fa02c7..726767390 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -13,7 +13,6 @@ class ApplicationSystemTestCase < ActionDispatch::IntegrationTest WebMock.reset! Capybara.reset_sessions! Capybara.use_default_driver - end end @@ -29,21 +28,16 @@ class JavaScriptApplicationSystemTestCase < ApplicationSystemTestCase options.add_argument('--disable-dev-shm-usage') options.add_argument('--window-size=1400,1400') - - Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) - end Capybara.server = :puma, { Silent: true } def setup DatabaseCleaner.start - super Capybara.current_driver = :chrome - end def teardown diff --git a/test/integration/admin_area/account_activities_test.rb b/test/integration/admin_area/account_activities_test.rb index 1bed55a93..085c51771 100644 --- a/test/integration/admin_area/account_activities_test.rb +++ b/test/integration/admin_area/account_activities_test.rb @@ -36,4 +36,4 @@ class AdminAreaAccountActivitiesIntegrationTest < ApplicationSystemTestCase response.headers['Content-Disposition'] assert_not_empty response.body end -end \ No newline at end of file +end diff --git a/test/integration/admin_area/admin_users_test.rb b/test/integration/admin_area/admin_users_test.rb index 74baee55e..bc9753565 100644 --- a/test/integration/admin_area/admin_users_test.rb +++ b/test/integration/admin_area/admin_users_test.rb @@ -30,7 +30,6 @@ class AdminAreaAdminUsersIntegrationTest < JavaScriptApplicationSystemTestCase select 'Estonia', from: 'admin_user_country_code', match: :first - # '//div[@class="selectize-input items has-options full has-items"]' select_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[1]") select_element.click @@ -39,7 +38,6 @@ class AdminAreaAdminUsersIntegrationTest < JavaScriptApplicationSystemTestCase click_on 'Save' - # if user created with valid data then record successfuly, else it failed if valid assert_text 'Record created' else @@ -103,4 +101,4 @@ class AdminAreaAdminUsersIntegrationTest < JavaScriptApplicationSystemTestCase assert_text 'Record deleted' end -end \ No newline at end of file +end diff --git a/test/integration/admin_area/blocked_domains_test.rb b/test/integration/admin_area/blocked_domains_test.rb index a03848c35..7df9d30e7 100644 --- a/test/integration/admin_area/blocked_domains_test.rb +++ b/test/integration/admin_area/blocked_domains_test.rb @@ -11,25 +11,6 @@ class AdminAreaBlockedDomainsIntegrationTest < JavaScriptApplicationSystemTestCa @blocked_domain = blocked_domains(:one) end - # HELPERS - def visit_admin_blocked_domains_path - visit admin_blocked_domains_path - assert_text 'Blocked domains' - end - - def add_domain_into_blocked_list(value) - click_on 'New blocked domain' - assert_text 'Add domain to blocked list' - - fill_in 'Name', with: @domain.name - click_on 'Save' - - return assert_text 'Domain added!' if value - return assert_text 'Failed to add domain!' - end - - # ------------------------------------------------------------ - # TESTs def test_page_successfully_loaded visit_admin_blocked_domains_path end @@ -67,4 +48,21 @@ class AdminAreaBlockedDomainsIntegrationTest < JavaScriptApplicationSystemTestCa assert_text @domain.name end -end \ No newline at end of file + private + + def visit_admin_blocked_domains_path + visit admin_blocked_domains_path + assert_text 'Blocked domains' + end + + def add_domain_into_blocked_list(value) + click_on 'New blocked domain' + assert_text 'Add domain to blocked list' + + fill_in 'Name', with: @domain.name + click_on 'Save' + + return assert_text 'Domain added!' if value + return assert_text 'Failed to add domain!' + end +end diff --git a/test/integration/admin_area/certificates_test.rb b/test/integration/admin_area/certificates_test.rb index d2b159854..d2eec0bc4 100644 --- a/test/integration/admin_area/certificates_test.rb +++ b/test/integration/admin_area/certificates_test.rb @@ -3,70 +3,69 @@ require 'application_system_test_case' class AdminAreaCertificatesIntegrationTest < JavaScriptApplicationSystemTestCase - setup do - WebMock.allow_net_connect! - sign_in users(:admin) + setup do + WebMock.allow_net_connect! + sign_in users(:admin) - @apiuser = users(:api_bestnames) - @certificate = certificates(:api) - @certificate.update!(csr: "-----BEGIN CERTIFICATE REQUEST-----\nMIICszCCAZsCAQAwbjELMAkGA1UEBhMCRUUxFDASBgNVBAMMC2ZyZXNoYm94LmVl\nMRAwDgYDVQQHDAdUYWxsaW5uMREwDwYDVQQKDAhGcmVzaGJveDERMA8GA1UECAwI\nSGFyanVtYWExETAPBgNVBAsMCEZyZXNoYm94MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEA1VVESynZoZhIbe8s9zHkELZ/ZDCGiM2Q8IIGb1IOieT5U2mx\nIsVXz85USYsSQY9+4YdEXnupq9fShArT8pstS/VN6BnxdfAiYXc3UWWAuaYAdNGJ\nDr5Jf6uMt1wVnCgoDL7eJq9tWMwARC/viT81o92fgqHFHW0wEolfCmnpik9o0ACD\nFiWZ9IBIevmFqXtq25v9CY2cT9+eZW127WtJmOY/PKJhzh0QaEYHqXTHWOLZWpnp\nHH4elyJ2CrFulOZbHPkPNB9Nf4XQjzk1ffoH6e5IVys2VV5xwcTkF0jY5XTROVxX\nlR2FWqic8Q2pIhSks48+J6o1GtXGnTxv94lSDwIDAQABoAAwDQYJKoZIhvcNAQEL\nBQADggEBAEFcYmQvcAC8773eRTWBJJNoA4kRgoXDMYiiEHih5iJPVSxfidRwYDTF\nsP+ttNTUg3JocFHY75kuM9T2USh+gu/trRF0o4WWa+AbK3JbbdjdT1xOMn7XtfUU\nZ/f1XCS9YdHQFCA6nk4Z+TLWwYsgk7n490AQOiB213fa1UIe83qIfw/3GRqRUZ7U\nwIWEGsHED5WT69GyxjyKHcqGoV7uFnqFN0sQVKVTy/NFRVQvtBUspCbsOirdDRie\nAB2KbGHL+t1QrRF10szwCJDyk5aYlVhxvdI8zn010nrxHkiyQpDFFldDMLJl10BW\n2w9PGO061z+tntdRcKQGuEpnIr9U5Vs=\n-----END CERTIFICATE REQUEST-----\n") - end + @apiuser = users(:api_bestnames) + @certificate = certificates(:api) + @certificate.update!(csr: "-----BEGIN CERTIFICATE REQUEST-----\nMIICszCCAZsCAQAwbjELMAkGA1UEBhMCRUUxFDASBgNVBAMMC2ZyZXNoYm94LmVl\nMRAwDgYDVQQHDAdUYWxsaW5uMREwDwYDVQQKDAhGcmVzaGJveDERMA8GA1UECAwI\nSGFyanVtYWExETAPBgNVBAsMCEZyZXNoYm94MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEA1VVESynZoZhIbe8s9zHkELZ/ZDCGiM2Q8IIGb1IOieT5U2mx\nIsVXz85USYsSQY9+4YdEXnupq9fShArT8pstS/VN6BnxdfAiYXc3UWWAuaYAdNGJ\nDr5Jf6uMt1wVnCgoDL7eJq9tWMwARC/viT81o92fgqHFHW0wEolfCmnpik9o0ACD\nFiWZ9IBIevmFqXtq25v9CY2cT9+eZW127WtJmOY/PKJhzh0QaEYHqXTHWOLZWpnp\nHH4elyJ2CrFulOZbHPkPNB9Nf4XQjzk1ffoH6e5IVys2VV5xwcTkF0jY5XTROVxX\nlR2FWqic8Q2pIhSks48+J6o1GtXGnTxv94lSDwIDAQABoAAwDQYJKoZIhvcNAQEL\nBQADggEBAEFcYmQvcAC8773eRTWBJJNoA4kRgoXDMYiiEHih5iJPVSxfidRwYDTF\nsP+ttNTUg3JocFHY75kuM9T2USh+gu/trRF0o4WWa+AbK3JbbdjdT1xOMn7XtfUU\nZ/f1XCS9YdHQFCA6nk4Z+TLWwYsgk7n490AQOiB213fa1UIe83qIfw/3GRqRUZ7U\nwIWEGsHED5WT69GyxjyKHcqGoV7uFnqFN0sQVKVTy/NFRVQvtBUspCbsOirdDRie\nAB2KbGHL+t1QrRF10szwCJDyk5aYlVhxvdI8zn010nrxHkiyQpDFFldDMLJl10BW\n2w9PGO061z+tntdRcKQGuEpnIr9U5Vs=\n-----END CERTIFICATE REQUEST-----\n") + end - # Helpers ======================= - def show_certificate_info - visit admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id) - assert_text 'Certificates' - end + def test_show_certificate_info + show_certificate_info + end - # TESTs =========================== - def test_show_certificate_info - show_certificate_info - end + def test_destroy_certificate + show_certificate_info + find(:xpath, "//a[text()='Delete']").click - def test_destroy_certificate - show_certificate_info - find(:xpath, "//a[text()='Delete']").click + page.driver.browser.switch_to.alert.accept - page.driver.browser.switch_to.alert.accept + assert_text 'Record deleted' + end - assert_text 'Record deleted' - end + def test_download_csr + get download_csr_admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id) - def test_download_csr - get download_csr_admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id) - - assert_response :ok - assert_equal 'application/octet-stream', response.headers['Content-Type'] - assert_equal "attachment; filename=\"test_bestnames.csr.pem\"; filename*=UTF-8''test_bestnames.csr.pem", response.headers['Content-Disposition'] - assert_not_empty response.body - end + assert_response :ok + assert_equal 'application/octet-stream', response.headers['Content-Type'] + assert_equal "attachment; filename=\"test_bestnames.csr.pem\"; filename*=UTF-8''test_bestnames.csr.pem", response.headers['Content-Disposition'] + assert_not_empty response.body + end - def test_download_crt - get download_crt_admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id) - - assert_response :ok - assert_equal 'application/octet-stream', response.headers['Content-Type'] - assert_equal "attachment; filename=\"test_bestnames.crt.pem\"; filename*=UTF-8''test_bestnames.crt.pem", response.headers['Content-Disposition'] - assert_not_empty response.body - end + def test_download_crt + get download_crt_admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id) - def test_failed_to_revoke_certificate - show_certificate_info + assert_response :ok + assert_equal 'application/octet-stream', response.headers['Content-Type'] + assert_equal "attachment; filename=\"test_bestnames.crt.pem\"; filename*=UTF-8''test_bestnames.crt.pem", response.headers['Content-Disposition'] + assert_not_empty response.body + end - find(:xpath, "//a[text()='Revoke this certificate']").click - assert_text 'Failed to update record' - end + def test_failed_to_revoke_certificate + show_certificate_info - def test_new_api_user - visit new_admin_registrar_api_user_path(registrar_id: registrars(:bestnames).id) + find(:xpath, "//a[text()='Revoke this certificate']").click + assert_text 'Failed to update record' + end - fill_in 'Username', with: 'testapiuser' - fill_in 'Password', with: 'secretpassword' - fill_in 'Identity code', with: '60305062718' + def test_new_api_user + visit new_admin_registrar_api_user_path(registrar_id: registrars(:bestnames).id) - click_on 'Create API user' + fill_in 'Username', with: 'testapiuser' + fill_in 'Password', with: 'secretpassword' + fill_in 'Identity code', with: '60305062718' - assert_text 'API user has been successfully created' - end + click_on 'Create API user' -end \ No newline at end of file + assert_text 'API user has been successfully created' + end + + private + + def show_certificate_info + visit admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id) + assert_text 'Certificates' + end +end diff --git a/test/integration/admin_area/delayed_jobs_test.rb b/test/integration/admin_area/delayed_jobs_test.rb deleted file mode 100644 index 14155e193..000000000 --- a/test/integration/admin_area/delayed_jobs_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'test_helper' -require 'application_system_test_case' - -class AdminAreaDelayedJobsIntegrationTest < ApplicationSystemTestCase - setup do - sign_in users(:admin) - end - -# TODO -end \ No newline at end of file diff --git a/test/integration/admin_area/epp_logs_test.rb b/test/integration/admin_area/epp_logs_test.rb index e9360672e..5ad514cb8 100644 --- a/test/integration/admin_area/epp_logs_test.rb +++ b/test/integration/admin_area/epp_logs_test.rb @@ -3,49 +3,50 @@ require 'test_helper' require 'application_system_test_case' class AdminEppLogsIntegrationTest < ApplicationSystemTestCase - setup do - sign_in users(:admin) - end + setup do + sign_in users(:admin) + end - def send_epp_request_hello - request_xml = <<-XML - - - - + def test_visit_epp_logs_page + visit admin_epp_logs_path + assert_text 'EPP log' + end + + def test_show_epp_log_page + visit admin_epp_logs_path + send_epp_request_hello + visit admin_epp_logs_path + + find(:xpath, "//tbody/tr/td/a", match: :first).click + assert_text 'Details' + end + + def test_dates_sort + Capybara.exact = true + visit admin_epp_logs_path + send_epp_request_hello + visit admin_epp_logs_path + + find(:xpath, "//a[contains(text(), 'Created at')]", match: :first).click + find(:xpath, "//a[contains(text(), 'Created at')]", match: :first).click + + epp_log_date = find(:xpath, "//table/tbody/tr/td[6]", match: :first).text(:all) + date_now = Date.today.to_s(:db) + + assert_match /#{date_now}/, epp_log_date + end + + private + + def send_epp_request_hello + request_xml = <<-XML + + + + XML - - get epp_hello_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=non-existent' } - end - def test_visit_epp_logs_page - visit admin_epp_logs_path - assert_text 'EPP log' - end - - def test_show_epp_log_page - visit admin_epp_logs_path - send_epp_request_hello - visit admin_epp_logs_path - - find(:xpath, "//tbody/tr/td/a", match: :first).click - assert_text 'Details' - end - - def test_dates_sort - Capybara.exact = true - visit admin_epp_logs_path - send_epp_request_hello - visit admin_epp_logs_path - - find(:xpath, "//a[contains(text(), 'Created at')]", match: :first).click - find(:xpath, "//a[contains(text(), 'Created at')]", match: :first).click - - epp_log_date = find(:xpath, "//table/tbody/tr/td[6]", match: :first).text(:all) - date_now = Date.today.to_s(:db) - - assert_match /#{date_now}/, epp_log_date - end - -end \ No newline at end of file + get epp_hello_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=non-existent' } + end +end diff --git a/test/integration/admin_area/invoices_test.rb b/test/integration/admin_area/invoices_test.rb index 1bee7811d..2aa17201d 100644 --- a/test/integration/admin_area/invoices_test.rb +++ b/test/integration/admin_area/invoices_test.rb @@ -11,13 +11,9 @@ class AdminAreaInvoicesIntegrationTest < ApplicationIntegrationTest assert_text 'Create new invoice' select 'Best Names', from: 'deposit_registrar_id', match: :first - fill_in 'Amount', with: '1000' - click_on 'Save' - # TODO - # Should be assert_text 'Record created' assert_equal page.status_code, 200 end diff --git a/test/integration/admin_area/pending_delete_test.rb b/test/integration/admin_area/pending_delete_test.rb index 8975f985a..737d12480 100644 --- a/test/integration/admin_area/pending_delete_test.rb +++ b/test/integration/admin_area/pending_delete_test.rb @@ -2,60 +2,59 @@ require 'test_helper' require 'application_system_test_case' class AdminAreaPendingDeleteIntegrationTest < JavaScriptApplicationSystemTestCase + setup do + WebMock.allow_net_connect! + sign_in users(:admin) - setup do - WebMock.allow_net_connect! - sign_in users(:admin) + @domain = domains(:shop) + @token = '123456' - @domain = domains(:shop) - @token = '123456' + @domain.update!(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION], + registrant_verification_asked_at: Time.zone.now - 1.day, + registrant_verification_token: @token) + end - @domain.update!(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION], - registrant_verification_asked_at: Time.zone.now - 1.day, - registrant_verification_token: @token) - end + def test_accept_pending_delete + visit edit_admin_domain_path(id: @domain.id) - def test_accept_pending_delete - visit edit_admin_domain_path(id: @domain.id) + click_on 'Accept' + page.driver.browser.switch_to.alert.accept - click_on 'Accept' - page.driver.browser.switch_to.alert.accept + assert_text 'Pending was successfully applied.' + end - assert_text 'Pending was successfully applied.' - end + def test_accept_pending_delete_no_success + @domain.update!(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION], + registrant_verification_asked_at: Time.zone.now - 1.day, + registrant_verification_token: nil) - def test_accept_pending_delete_no_success - @domain.update!(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION], - registrant_verification_asked_at: Time.zone.now - 1.day, - registrant_verification_token: nil) + visit edit_admin_domain_path(id: @domain.id) - visit edit_admin_domain_path(id: @domain.id) + click_on 'Accept' + page.driver.browser.switch_to.alert.accept - click_on 'Accept' - page.driver.browser.switch_to.alert.accept + assert_text 'Not success' + end - assert_text 'Not success' - end + def test_reject_panding_delete + visit edit_admin_domain_path(id: @domain.id) - def test_reject_panding_delete - visit edit_admin_domain_path(id: @domain.id) + click_on 'Reject' + page.driver.browser.switch_to.alert.accept - click_on 'Reject' - page.driver.browser.switch_to.alert.accept + assert_text 'Pending was successfully removed.' + end - assert_text 'Pending was successfully removed.' - end + def test_accept_pending_delete_no_success + @domain.update!(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION], + registrant_verification_asked_at: Time.zone.now - 1.day, + registrant_verification_token: nil) - def test_accept_pending_delete_no_success - @domain.update!(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION], - registrant_verification_asked_at: Time.zone.now - 1.day, - registrant_verification_token: nil) + visit edit_admin_domain_path(id: @domain.id) - visit edit_admin_domain_path(id: @domain.id) - - click_on 'Reject' - page.driver.browser.switch_to.alert.accept - - assert_text 'Not success' - end -end \ No newline at end of file + click_on 'Reject' + page.driver.browser.switch_to.alert.accept + + assert_text 'Not success' + end +end diff --git a/test/integration/admin_area/pending_update_test.rb b/test/integration/admin_area/pending_update_test.rb index 42f3035ba..5d08e104b 100644 --- a/test/integration/admin_area/pending_update_test.rb +++ b/test/integration/admin_area/pending_update_test.rb @@ -3,94 +3,94 @@ require 'application_system_test_case' class AdminAreaPendingUpdateIntegrationTest < JavaScriptApplicationSystemTestCase - setup do - WebMock.allow_net_connect! - sign_in users(:admin) + setup do + WebMock.allow_net_connect! + sign_in users(:admin) - @domain = domains(:hospital) + @domain = domains(:hospital) - @new_registrant = contacts(:jack) - @user = users(:api_bestnames) - @token = '123456' + @new_registrant = contacts(:jack) + @user = users(:api_bestnames) + @token = '123456' - @domain.update!(statuses: [DomainStatus::PENDING_UPDATE], - registrant_verification_asked_at: Time.zone.now - 1.day, - registrant_verification_token: @token) - end + @domain.update!(statuses: [DomainStatus::PENDING_UPDATE], + registrant_verification_asked_at: Time.zone.now - 1.day, + registrant_verification_token: @token) + end - def test_accept_pending_update - pending_json = { new_registrant_id: @new_registrant.id, - new_registrant_name: @new_registrant.name, - new_registrant_email: @new_registrant.email, - current_user_id: @user.id } + def test_accept_pending_update + pending_json = { new_registrant_id: @new_registrant.id, + new_registrant_name: @new_registrant.name, + new_registrant_email: @new_registrant.email, + current_user_id: @user.id } - @domain.update(pending_json: pending_json) - @domain.reload + @domain.update(pending_json: pending_json) + @domain.reload - visit edit_admin_domain_path(id: @domain.id) + visit edit_admin_domain_path(id: @domain.id) - click_on 'Accept' - page.driver.browser.switch_to.alert.accept + click_on 'Accept' + page.driver.browser.switch_to.alert.accept - assert_text 'Pending was successfully applied.' - end + assert_text 'Pending was successfully applied.' + end - def test_accept_pending_update_no_success - @domain.update!(statuses: [DomainStatus::PENDING_UPDATE], - registrant_verification_asked_at: Time.zone.now - 1.day, - registrant_verification_token: nil) + def test_accept_pending_update_no_success + @domain.update!(statuses: [DomainStatus::PENDING_UPDATE], + registrant_verification_asked_at: Time.zone.now - 1.day, + registrant_verification_token: nil) - pending_json = { new_registrant_id: @new_registrant.id, - new_registrant_name: @new_registrant.name, - new_registrant_email: @new_registrant.email, - current_user_id: @user.id, - } + pending_json = { new_registrant_id: @new_registrant.id, + new_registrant_name: @new_registrant.name, + new_registrant_email: @new_registrant.email, + current_user_id: @user.id, + } - @domain.update(pending_json: pending_json) - @domain.reload + @domain.update(pending_json: pending_json) + @domain.reload - visit edit_admin_domain_path(id: @domain.id) + visit edit_admin_domain_path(id: @domain.id) - click_on 'Accept' - page.driver.browser.switch_to.alert.accept - assert_text 'Not success' - end + click_on 'Accept' + page.driver.browser.switch_to.alert.accept + assert_text 'Not success' + end - def test_reject_panding_update - pending_json = { new_registrant_id: @new_registrant.id, - new_registrant_name: @new_registrant.name, - new_registrant_email: @new_registrant.email, - current_user_id: @user.id, - } + def test_reject_panding_update + pending_json = { new_registrant_id: @new_registrant.id, + new_registrant_name: @new_registrant.name, + new_registrant_email: @new_registrant.email, + current_user_id: @user.id, + } - @domain.update(pending_json: pending_json) - @domain.reload + @domain.update(pending_json: pending_json) + @domain.reload - visit edit_admin_domain_path(id: @domain.id) + visit edit_admin_domain_path(id: @domain.id) - click_on 'Reject' - page.driver.browser.switch_to.alert.accept - assert_text 'Pending was successfully removed.' - end + click_on 'Reject' + page.driver.browser.switch_to.alert.accept + assert_text 'Pending was successfully removed.' + end - def test_accept_pending_update_no_success - @domain.update!(statuses: [DomainStatus::PENDING_UPDATE], - registrant_verification_asked_at: Time.zone.now - 1.day, - registrant_verification_token: nil) + def test_accept_pending_update_no_success + @domain.update!(statuses: [DomainStatus::PENDING_UPDATE], + registrant_verification_asked_at: Time.zone.now - 1.day, + registrant_verification_token: nil) - pending_json = { new_registrant_id: @new_registrant.id, - new_registrant_name: @new_registrant.name, - new_registrant_email: @new_registrant.email, - current_user_id: @user.id, - } + pending_json = { new_registrant_id: @new_registrant.id, + new_registrant_name: @new_registrant.name, + new_registrant_email: @new_registrant.email, + current_user_id: @user.id, + } - @domain.update(pending_json: pending_json) - @domain.reload + @domain.update(pending_json: pending_json) + @domain.reload - visit edit_admin_domain_path(id: @domain.id) + visit edit_admin_domain_path(id: @domain.id) - click_on 'Reject' - page.driver.browser.switch_to.alert.accept - assert_text 'Not success' - end -end \ No newline at end of file + click_on 'Reject' + page.driver.browser.switch_to.alert.accept + assert_text 'Not success' + end +end diff --git a/test/integration/admin_area/registrars_test.rb b/test/integration/admin_area/registrars_test.rb index d73496899..552650791 100644 --- a/test/integration/admin_area/registrars_test.rb +++ b/test/integration/admin_area/registrars_test.rb @@ -17,4 +17,4 @@ class AdminAreaRegistrarsIntegrationTest < ActionDispatch::IntegrationTest assert_equal new_iban, @registrar.iban end -end \ No newline at end of file +end diff --git a/test/integration/admin_area/repp_logs_test.rb b/test/integration/admin_area/repp_logs_test.rb index 0a9083a59..6630a6d57 100644 --- a/test/integration/admin_area/repp_logs_test.rb +++ b/test/integration/admin_area/repp_logs_test.rb @@ -2,25 +2,22 @@ require 'test_helper' require 'application_system_test_case' class AdminAreaReppLogsIntegrationTest < ApplicationSystemTestCase + setup do + sign_in users(:admin) + end - setup do - sign_in users(:admin) - end + def test_repp_logs_page + visit admin_repp_logs_path + assert_text 'REPP log' + end - def test_repp_logs_page - visit admin_repp_logs_path - assert_text 'REPP log' - end + def test_show_repp_log_page + visit admin_repp_logs_path + get repp_v1_contacts_path + visit admin_repp_logs_path + + find(:xpath, "//tbody/tr/td/a", match: :first).click - - def test_show_repp_log_page - visit admin_repp_logs_path - get repp_v1_contacts_path - visit admin_repp_logs_path - - find(:xpath, "//tbody/tr/td/a", match: :first).click - - assert_text 'REPP log' - end - -end \ No newline at end of file + assert_text 'REPP log' + end +end diff --git a/test/integration/admin_area/reserved_domains_test.rb b/test/integration/admin_area/reserved_domains_test.rb index 577074e77..1020255b0 100644 --- a/test/integration/admin_area/reserved_domains_test.rb +++ b/test/integration/admin_area/reserved_domains_test.rb @@ -45,5 +45,4 @@ class AdminAreaReservedDomainsIntegrationTest < JavaScriptApplicationSystemTestC assert_text 'Domain updated!' end - -end \ No newline at end of file +end diff --git a/test/integration/admin_area/white_ips_test.rb b/test/integration/admin_area/white_ips_test.rb index 183f1e04b..b4ffda90a 100644 --- a/test/integration/admin_area/white_ips_test.rb +++ b/test/integration/admin_area/white_ips_test.rb @@ -3,97 +3,92 @@ require 'application_system_test_case' class AdminAreaWhiteIpsIntegrationTest < JavaScriptApplicationSystemTestCase - setup do - WebMock.allow_net_connect! - sign_in users(:admin) + setup do + WebMock.allow_net_connect! + sign_in users(:admin) - @registrar = registrars(:bestnames) - @white_ip = white_ips(:one) - end + @registrar = registrars(:bestnames) + @white_ip = white_ips(:one) + end - # Helpers ==================================== - def visit_new_whitelisted_ip_page - visit new_admin_registrar_white_ip_path(registrar_id: @registrar.id) - assert_text 'New whitelisted IP' - end + def test_visit_new_whitelisted_ip_page + visit_new_whitelisted_ip_page + end - def visit_edit_whitelisted_ip_page - visit edit_admin_registrar_white_ip_path(registrar_id: @registrar.id, id: @white_ip.id) - assert_text 'Edit white IP' - end + def test_create_new_whitelisted_ip + visit_new_whitelisted_ip_page + fill_in 'IPv4', with: "127.0.0.1" + fill_in 'IPv6', with: "::ffff:192.0.2.1" - def visit_info_whitelisted_ip_page - visit admin_registrar_white_ip_path(registrar_id: @registrar.id, id: @white_ip.id) - assert_text 'White IP' - end + find(:css, "#white_ip_interfaces_api").set(true) + find(:css, "#white_ip_interfaces_registrar").set(true) - # Tests ===================================== + click_on 'Save' - def test_visit_new_whitelisted_ip_page - visit_new_whitelisted_ip_page - end + assert_text 'Record created' + end - def test_create_new_whitelisted_ip - visit_new_whitelisted_ip_page - fill_in 'IPv4', with: "127.0.0.1" - fill_in 'IPv6', with: "::ffff:192.0.2.1" + def test_failed_to_create_new_whitelisted_ip + visit_new_whitelisted_ip_page + fill_in 'IPv4', with: "asdadadad.asd" - find(:css, "#white_ip_interfaces_api").set(true) - find(:css, "#white_ip_interfaces_registrar").set(true) + click_on 'Save' - click_on 'Save' + assert_text 'Failed to create record' + end - assert_text 'Record created' - end + def test_visit_edit_whitelisted_ip_page + visit_edit_whitelisted_ip_page + end - def test_failed_to_create_new_whitelisted_ip - visit_new_whitelisted_ip_page - fill_in 'IPv4', with: "asdadadad.asd" + def test_update_whitelisted_ip + visit_info_whitelisted_ip_page + click_on 'Edit' - click_on 'Save' + fill_in 'IPv4', with: "127.0.0.2" + find(:css, "#white_ip_interfaces_api").set(false) + click_on 'Save' - assert_text 'Failed to create record' - end + assert_text 'Record updated' + end - def test_visit_edit_whitelisted_ip_page - visit_edit_whitelisted_ip_page - end + def test_failed_to_update_whitelisted_ip + visit_info_whitelisted_ip_page + click_on 'Edit' + fill_in 'IPv4', with: "asdadad#" - def test_update_whitelisted_ip - visit_info_whitelisted_ip_page - click_on 'Edit' + click_on 'Save' - fill_in 'IPv4', with: "127.0.0.2" + assert_text 'Failed to update record' + end - find(:css, "#white_ip_interfaces_api").set(false) + def test_visit_info_whitelisted_ip_page + visit_info_whitelisted_ip_page + end - click_on 'Save' + def test_delete_whitelisted_ip + visit_info_whitelisted_ip_page + click_on 'Delete' - assert_text 'Record updated' - end + page.driver.browser.switch_to.alert.accept - def test_failed_to_update_whitelisted_ip - visit_info_whitelisted_ip_page - click_on 'Edit' + assert_text 'Record deleted' + end - fill_in 'IPv4', with: "asdadad#" + private - click_on 'Save' + def visit_new_whitelisted_ip_page + visit new_admin_registrar_white_ip_path(registrar_id: @registrar.id) + assert_text 'New whitelisted IP' + end - assert_text 'Failed to update record' - end + def visit_edit_whitelisted_ip_page + visit edit_admin_registrar_white_ip_path(registrar_id: @registrar.id, id: @white_ip.id) + assert_text 'Edit white IP' + end - def test_visit_info_whitelisted_ip_page - visit_info_whitelisted_ip_page - end - - def test_delete_whitelisted_ip - visit_info_whitelisted_ip_page - - click_on 'Delete' - - page.driver.browser.switch_to.alert.accept - - assert_text 'Record deleted' - end -end \ No newline at end of file + def visit_info_whitelisted_ip_page + visit admin_registrar_white_ip_path(registrar_id: @registrar.id, id: @white_ip.id) + assert_text 'White IP' + end +end diff --git a/test/system/admin_area/contacts_test.rb b/test/system/admin_area/contacts_test.rb index 3f40584a4..19b15c8a5 100644 --- a/test/system/admin_area/contacts_test.rb +++ b/test/system/admin_area/contacts_test.rb @@ -8,8 +8,6 @@ class AdminContactsTest < ApplicationSystemTestCase sign_in users(:admin) end - - # admin_contact def test_update_contact visit admin_contact_path(id: @contact.id) assert_text "#{@contact.name}" diff --git a/test/system/admin_area/invoices_test.rb b/test/system/admin_area/invoices_test.rb index 814f95d4a..40a50e1c7 100644 --- a/test/system/admin_area/invoices_test.rb +++ b/test/system/admin_area/invoices_test.rb @@ -40,4 +40,4 @@ class AdminAreaInvoicesTest < ApplicationSystemTestCase assert_current_path admin_invoice_path(@invoice) assert_text 'Invoice has been sent' end -end \ No newline at end of file +end diff --git a/test/system/admin_area/protected_area_test.rb b/test/system/admin_area/protected_area_test.rb index f3375776a..fa413291b 100644 --- a/test/system/admin_area/protected_area_test.rb +++ b/test/system/admin_area/protected_area_test.rb @@ -19,4 +19,4 @@ class AdminAreaProtectedAreaTest < ApplicationSystemTestCase assert_text 'You are already signed in' assert_current_path admin_domains_path end -end \ No newline at end of file +end From 8a399569fef26ec1f491de8b667c634f8aa348d2 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Wed, 27 Jan 2021 13:42:10 +0200 Subject: [PATCH 080/132] 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 486fceca9c99ae04c5475199e4288781da5d396a Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 29 Jan 2021 12:19:14 +0200 Subject: [PATCH 081/132] changed tabs --- .../admin_area/account_activities_test.rb | 64 ++++---- .../admin_area/admin_users_test.rb | 145 +++++++++--------- .../admin_area/reserved_domains_test.rb | 61 ++++---- 3 files changed, 129 insertions(+), 141 deletions(-) diff --git a/test/integration/admin_area/account_activities_test.rb b/test/integration/admin_area/account_activities_test.rb index 085c51771..306935269 100644 --- a/test/integration/admin_area/account_activities_test.rb +++ b/test/integration/admin_area/account_activities_test.rb @@ -2,38 +2,38 @@ require 'test_helper' require 'application_system_test_case' class AdminAreaAccountActivitiesIntegrationTest < ApplicationSystemTestCase - # /admin/account_activities - setup do - sign_in users(:admin) - @original_default_language = Setting.default_language - end - - def test_show_account_activities_page - account_activities(:one).update(sum: "123.00") - visit admin_account_activities_path - assert_text 'Account activities' - end + # /admin/account_activities + setup do + sign_in users(:admin) + @original_default_language = Setting.default_language + end + + def test_show_account_activities_page + account_activities(:one).update(sum: "123.00") + visit admin_account_activities_path + assert_text 'Account activities' + end - def test_default_url_params - account_activities(:one).update(sum: "123.00") - visit admin_root_path - click_link_or_button 'Settings', match: :first - find(:xpath, "//ul/li/a[text()='Account activities']").click - - assert has_current_path?(admin_account_activities_path(created_after: 'today')) - end + def test_default_url_params + account_activities(:one).update(sum: "123.00") + visit admin_root_path + click_link_or_button 'Settings', match: :first + find(:xpath, "//ul/li/a[text()='Account activities']").click + + assert has_current_path?(admin_account_activities_path(created_after: 'today')) + end - def test_download_account_activity - now = Time.zone.parse('2010-07-05 08:00') - travel_to now - account_activities(:one).update(sum: "123.00") - - get admin_account_activities_path(format: :csv) - - assert_response :ok - assert_equal "text/csv", response.headers['Content-Type'] - assert_equal %(attachment; filename="account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv), - response.headers['Content-Disposition'] - assert_not_empty response.body - end + def test_download_account_activity + now = Time.zone.parse('2010-07-05 08:00') + travel_to now + account_activities(:one).update(sum: "123.00") + + get admin_account_activities_path(format: :csv) + + assert_response :ok + assert_equal "text/csv", response.headers['Content-Type'] + assert_equal %(attachment; filename="account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv), + response.headers['Content-Disposition'] + assert_not_empty response.body + end end diff --git a/test/integration/admin_area/admin_users_test.rb b/test/integration/admin_area/admin_users_test.rb index bc9753565..5d45d3146 100644 --- a/test/integration/admin_area/admin_users_test.rb +++ b/test/integration/admin_area/admin_users_test.rb @@ -2,103 +2,100 @@ require 'test_helper' require 'application_system_test_case' class AdminAreaAdminUsersIntegrationTest < JavaScriptApplicationSystemTestCase - include Devise::Test::IntegrationHelpers - include ActionView::Helpers::NumberHelper + include Devise::Test::IntegrationHelpers + include ActionView::Helpers::NumberHelper - setup do - WebMock.allow_net_connect! - @original_default_language = Setting.default_language - sign_in users(:admin) - end + setup do + WebMock.allow_net_connect! + @original_default_language = Setting.default_language + sign_in users(:admin) + end - # Helpers funcs - def createNewAdminUser(valid) - visit admin_admin_users_path - click_on 'New admin user' + def test_create_new_admin_user + createNewAdminUser(true) + end - fill_in 'Username', with: 'test_user_name' - # If valid=true creating valid user, if else, then with invalid data - if valid - fill_in 'Password', with: 'test_password' - fill_in 'Password confirmation', with: 'test_password' - else - fill_in 'Password', with: 'test_password' - fill_in 'Password confirmation', with: 'test_password2' - end - fill_in 'Identity code', with: '38903110313' - fill_in 'Email', with: 'oleg@tester.ee' + def test_create_with_invalid_data_new_admin_user + createNewAdminUser(false) + end - select 'Estonia', from: 'admin_user_country_code', match: :first + def test_edit_successfully_exist_record + createNewAdminUser(true) - select_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[1]") - select_element.click + visit admin_admin_users_path + click_on 'test_user_name' - option_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[2]/div/div[1]") - option_element.click + assert_text 'General' + click_on 'Edit' - click_on 'Save' + fill_in 'Password', with: 'test_password' + fill_in 'Password confirmation', with: 'test_password' - if valid - assert_text 'Record created' - else - assert_text 'Failed to create record' - end - end + click_on 'Save' + assert_text 'Record updated' + end - # Tests - # "/admin/admin_users" - def test_create_new_admin_user - createNewAdminUser(true) - end + def test_edit_exist_record_with_invalid_data + createNewAdminUser(true) - def test_create_with_invalid_data_new_admin_user - createNewAdminUser(false) - end + visit admin_admin_users_path + click_on 'test_user_name' - def test_edit_successfully_exist_record - createNewAdminUser(true) + assert_text 'General' + click_on 'Edit' - visit admin_admin_users_path - click_on 'test_user_name' + fill_in 'Password', with: 'test_password' + fill_in 'Password confirmation', with: 'test_password2' - assert_text 'General' - click_on 'Edit' + click_on 'Save' + assert_text 'Failed to update record' + end + def test_delete_exist_record + createNewAdminUser(true) + + visit admin_admin_users_path + click_on 'test_user_name' + assert_text 'General' + click_on 'Delete' + + page.driver.browser.switch_to.alert.accept + + assert_text 'Record deleted' + end + + private + + def createNewAdminUser(valid) + visit admin_admin_users_path + click_on 'New admin user' + + fill_in 'Username', with: 'test_user_name' + # If valid=true creating valid user, if else, then with invalid data + if valid fill_in 'Password', with: 'test_password' fill_in 'Password confirmation', with: 'test_password' - - click_on 'Save' - assert_text 'Record updated' - end - - def test_edit_exist_record_with_invalid_data - createNewAdminUser(true) - - visit admin_admin_users_path - click_on 'test_user_name' - - assert_text 'General' - click_on 'Edit' - + else fill_in 'Password', with: 'test_password' fill_in 'Password confirmation', with: 'test_password2' - - click_on 'Save' - assert_text 'Failed to update record' end + fill_in 'Identity code', with: '38903110313' + fill_in 'Email', with: 'oleg@tester.ee' - def test_delete_exist_record - createNewAdminUser(true) + select 'Estonia', from: 'admin_user_country_code', match: :first - visit admin_admin_users_path - click_on 'test_user_name' + select_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[1]") + select_element.click - assert_text 'General' - click_on 'Delete' + option_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[2]/div/div[1]") + option_element.click - # Accept to delete in modal window - page.driver.browser.switch_to.alert.accept + click_on 'Save' - assert_text 'Record deleted' + if valid + assert_text 'Record created' + else + assert_text 'Failed to create record' end + end end diff --git a/test/integration/admin_area/reserved_domains_test.rb b/test/integration/admin_area/reserved_domains_test.rb index 1020255b0..c09c3723b 100644 --- a/test/integration/admin_area/reserved_domains_test.rb +++ b/test/integration/admin_area/reserved_domains_test.rb @@ -3,46 +3,37 @@ require 'application_system_test_case' class AdminAreaReservedDomainsIntegrationTest < JavaScriptApplicationSystemTestCase - setup do - WebMock.allow_net_connect! - @original_default_language = Setting.default_language - sign_in users(:admin) + setup do + WebMock.allow_net_connect! + @original_default_language = Setting.default_language + sign_in users(:admin) - @reserved_domain = reserved_domains(:one) - end + @reserved_domain = reserved_domains(:one) + end - def test_remove_reserved_domain - visit admin_reserved_domains_path - - click_link_or_button 'Delete', match: :first + def test_remove_reserved_domain + visit admin_reserved_domains_path + click_link_or_button 'Delete', match: :first + page.driver.browser.switch_to.alert.accept - # Accept to delete in modal window - page.driver.browser.switch_to.alert.accept + assert_text 'Domain deleted!' + end - assert_text 'Domain deleted!' - end + def test_add_invalid_domain + visit admin_reserved_domains_path + click_on 'New reserved domain' + fill_in "Name", with: "@##@$" + click_on 'Save' - def test_add_invalid_domain - visit admin_reserved_domains_path + assert_text 'Failed to add domain!' + end - click_on 'New reserved domain' + def test_update_reserved_domain + visit admin_reserved_domains_path + click_link_or_button 'Edit Pw', match: :first + fill_in 'Password', with: '12345678' + click_on 'Save' - fill_in "Name", with: "@##@$" - - click_on 'Save' - - assert_text 'Failed to add domain!' - end - - def test_update_reserved_domain - visit admin_reserved_domains_path - - click_link_or_button 'Edit Pw', match: :first - - fill_in 'Password', with: '12345678' - - click_on 'Save' - - assert_text 'Domain updated!' - end + assert_text 'Domain updated!' + end end From 569939e84260aaab7c534267c8c2c9501d071f1b Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 29 Jan 2021 12:28:04 +0200 Subject: [PATCH 082/132] fixed tabs --- .../admin_area/admin_users_test.rb | 12 +- test/integration/admin_area/white_ips_test.rb | 128 +++++++++--------- 2 files changed, 70 insertions(+), 70 deletions(-) diff --git a/test/integration/admin_area/admin_users_test.rb b/test/integration/admin_area/admin_users_test.rb index 5d45d3146..89b9edef9 100644 --- a/test/integration/admin_area/admin_users_test.rb +++ b/test/integration/admin_area/admin_users_test.rb @@ -73,11 +73,11 @@ class AdminAreaAdminUsersIntegrationTest < JavaScriptApplicationSystemTestCase fill_in 'Username', with: 'test_user_name' # If valid=true creating valid user, if else, then with invalid data if valid - fill_in 'Password', with: 'test_password' - fill_in 'Password confirmation', with: 'test_password' + fill_in 'Password', with: 'test_password' + fill_in 'Password confirmation', with: 'test_password' else - fill_in 'Password', with: 'test_password' - fill_in 'Password confirmation', with: 'test_password2' + fill_in 'Password', with: 'test_password' + fill_in 'Password confirmation', with: 'test_password2' end fill_in 'Identity code', with: '38903110313' fill_in 'Email', with: 'oleg@tester.ee' @@ -93,9 +93,9 @@ class AdminAreaAdminUsersIntegrationTest < JavaScriptApplicationSystemTestCase click_on 'Save' if valid - assert_text 'Record created' + assert_text 'Record created' else - assert_text 'Failed to create record' + assert_text 'Failed to create record' end end end diff --git a/test/integration/admin_area/white_ips_test.rb b/test/integration/admin_area/white_ips_test.rb index b4ffda90a..499c86f57 100644 --- a/test/integration/admin_area/white_ips_test.rb +++ b/test/integration/admin_area/white_ips_test.rb @@ -3,92 +3,92 @@ require 'application_system_test_case' class AdminAreaWhiteIpsIntegrationTest < JavaScriptApplicationSystemTestCase - setup do - WebMock.allow_net_connect! - sign_in users(:admin) + setup do + WebMock.allow_net_connect! + sign_in users(:admin) - @registrar = registrars(:bestnames) - @white_ip = white_ips(:one) - end + @registrar = registrars(:bestnames) + @white_ip = white_ips(:one) + end - def test_visit_new_whitelisted_ip_page - visit_new_whitelisted_ip_page - end + def test_visit_new_whitelisted_ip_page + visit_new_whitelisted_ip_page + end - def test_create_new_whitelisted_ip - visit_new_whitelisted_ip_page - fill_in 'IPv4', with: "127.0.0.1" - fill_in 'IPv6', with: "::ffff:192.0.2.1" + def test_create_new_whitelisted_ip + visit_new_whitelisted_ip_page + fill_in 'IPv4', with: "127.0.0.1" + fill_in 'IPv6', with: "::ffff:192.0.2.1" - find(:css, "#white_ip_interfaces_api").set(true) - find(:css, "#white_ip_interfaces_registrar").set(true) + find(:css, "#white_ip_interfaces_api").set(true) + find(:css, "#white_ip_interfaces_registrar").set(true) - click_on 'Save' + click_on 'Save' - assert_text 'Record created' - end + assert_text 'Record created' + end - def test_failed_to_create_new_whitelisted_ip - visit_new_whitelisted_ip_page - fill_in 'IPv4', with: "asdadadad.asd" + def test_failed_to_create_new_whitelisted_ip + visit_new_whitelisted_ip_page + fill_in 'IPv4', with: "asdadadad.asd" - click_on 'Save' + click_on 'Save' - assert_text 'Failed to create record' - end + assert_text 'Failed to create record' + end - def test_visit_edit_whitelisted_ip_page - visit_edit_whitelisted_ip_page - end + def test_visit_edit_whitelisted_ip_page + visit_edit_whitelisted_ip_page + end - def test_update_whitelisted_ip - visit_info_whitelisted_ip_page - click_on 'Edit' + def test_update_whitelisted_ip + visit_info_whitelisted_ip_page + click_on 'Edit' - fill_in 'IPv4', with: "127.0.0.2" - find(:css, "#white_ip_interfaces_api").set(false) - click_on 'Save' + fill_in 'IPv4', with: "127.0.0.2" + find(:css, "#white_ip_interfaces_api").set(false) + click_on 'Save' - assert_text 'Record updated' - end + assert_text 'Record updated' + end - def test_failed_to_update_whitelisted_ip - visit_info_whitelisted_ip_page - click_on 'Edit' - fill_in 'IPv4', with: "asdadad#" + def test_failed_to_update_whitelisted_ip + visit_info_whitelisted_ip_page + click_on 'Edit' + fill_in 'IPv4', with: "asdadad#" - click_on 'Save' + click_on 'Save' - assert_text 'Failed to update record' - end + assert_text 'Failed to update record' + end - def test_visit_info_whitelisted_ip_page - visit_info_whitelisted_ip_page - end + def test_visit_info_whitelisted_ip_page + visit_info_whitelisted_ip_page + end - def test_delete_whitelisted_ip - visit_info_whitelisted_ip_page - click_on 'Delete' + def test_delete_whitelisted_ip + visit_info_whitelisted_ip_page + click_on 'Delete' - page.driver.browser.switch_to.alert.accept + page.driver.browser.switch_to.alert.accept - assert_text 'Record deleted' - end + assert_text 'Record deleted' + end - private + private - def visit_new_whitelisted_ip_page - visit new_admin_registrar_white_ip_path(registrar_id: @registrar.id) - assert_text 'New whitelisted IP' - end + def visit_new_whitelisted_ip_page + visit new_admin_registrar_white_ip_path(registrar_id: @registrar.id) + assert_text 'New whitelisted IP' + end - def visit_edit_whitelisted_ip_page - visit edit_admin_registrar_white_ip_path(registrar_id: @registrar.id, id: @white_ip.id) - assert_text 'Edit white IP' - end + def visit_edit_whitelisted_ip_page + visit edit_admin_registrar_white_ip_path(registrar_id: @registrar.id, id: @white_ip.id) + assert_text 'Edit white IP' + end - def visit_info_whitelisted_ip_page - visit admin_registrar_white_ip_path(registrar_id: @registrar.id, id: @white_ip.id) - assert_text 'White IP' - end + def visit_info_whitelisted_ip_page + visit admin_registrar_white_ip_path(registrar_id: @registrar.id, id: @white_ip.id) + assert_text 'White IP' + end end From 3c1b989723ae3981c418432a81da1f0f9cbbf096 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Fri, 29 Jan 2021 16:13:15 +0500 Subject: [PATCH 083/132] Add check if domain got *UpdateProhibited --- app/models/concerns/domain/bulk_updatable.rb | 17 +++++++++++++++++ app/models/domain.rb | 1 + app/models/tech_domain_contact.rb | 3 +-- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 app/models/concerns/domain/bulk_updatable.rb diff --git a/app/models/concerns/domain/bulk_updatable.rb b/app/models/concerns/domain/bulk_updatable.rb new file mode 100644 index 000000000..a0aadb95f --- /dev/null +++ b/app/models/concerns/domain/bulk_updatable.rb @@ -0,0 +1,17 @@ +module Concerns + module Domain + module BulkUpdatable + extend ActiveSupport::Concern + + def bulk_update_prohibited? + discarded? || statuses_blocks_update? + end + + def statuses_blocks_update? + prohibited_array = [DomainStatus::SERVER_UPDATE_PROHIBITED, + DomainStatus::CLIENT_UPDATE_PROHIBITED] + prohibited_array.any? { |block_status| statuses.include?(block_status) } + end + end + end +end diff --git a/app/models/domain.rb b/app/models/domain.rb index 3acc08575..53f0fa5b6 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -10,6 +10,7 @@ class Domain < ApplicationRecord include Concerns::Domain::RegistryLockable include Concerns::Domain::Releasable include Concerns::Domain::Disputable + include Concerns::Domain::BulkUpdatable attr_accessor :roles diff --git a/app/models/tech_domain_contact.rb b/app/models/tech_domain_contact.rb index 92799061c..20f21b6ed 100644 --- a/app/models/tech_domain_contact.rb +++ b/app/models/tech_domain_contact.rb @@ -6,7 +6,7 @@ class TechDomainContact < DomainContact tech_contacts = where(contact: current_contact) tech_contacts.each do |tech_contact| - if tech_contact.domain.discarded? + if tech_contact.domain.bulk_update_prohibited? skipped_domains << tech_contact.domain.name next end @@ -18,7 +18,6 @@ class TechDomainContact < DomainContact skipped_domains << tech_contact.domain.name end end - [affected_domains.sort, skipped_domains.sort] end end From 5de0645d41fbd1d6ee19705d61d2bda72e00546d Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 29 Jan 2021 18:00:51 +0200 Subject: [PATCH 084/132] added tests for domain locked notifications --- test/jobs/domain_update_confirm_job_test.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/jobs/domain_update_confirm_job_test.rb b/test/jobs/domain_update_confirm_job_test.rb index ded0d3d8a..51c42aa4f 100644 --- a/test/jobs/domain_update_confirm_job_test.rb +++ b/test/jobs/domain_update_confirm_job_test.rb @@ -1,5 +1,4 @@ require "test_helper" - class DomainUpdateConfirmJobTest < ActiveSupport::TestCase def setup super @@ -19,6 +18,22 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase super end + def test_registrant_locked_domain + refute @domain.locked_by_registrant? + @domain.apply_registry_lock + assert @domain.locked_by_registrant? + assert_equal(@domain.registrar.notifications.last.text, 'Domain has been locked by registrant') + end + + def test_registrant_unlocked_domain + refute @domain.locked_by_registrant? + @domain.apply_registry_lock + assert @domain.locked_by_registrant? + @domain.remove_registry_lock + refute @domain.locked_by_registrant? + assert_equal(@domain.registrar.notifications.last.text, 'Domain has been unlocked by registrant') + end + def test_rejected_registrant_verification_notifies_registrar DomainUpdateConfirmJob.perform_now(@domain.id, RegistrantVerification::REJECTED) From 3c068244cbc197d57da0066f5d5961d6f36dcbac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Mon, 1 Feb 2021 16:24:41 +0200 Subject: [PATCH 085/132] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5585ca6f1..4fe9d8a45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +01.02.2021 +* Improved tests for admin interface [#1805](https://github.com/internetee/registry/pull/1805) + 28.01.2021 * Fixed transfer with shared admin and tech contacts [#1808](https://github.com/internetee/registry/issues/1808) * Improved error handling with double admin/tech contacts [#1758](https://github.com/internetee/registry/issues/1758) From d07b6a9c7b08acc70f8cace60646c51585b4cb3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Tue, 2 Feb 2021 13:51:46 +0200 Subject: [PATCH 086/132] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fe9d8a45..45ab590db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +02.02.2021 +* Fixed updateProhibited status not affecting bulk tech contact change operation [#1820](https://github.com/internetee/registry/pull/1820) + 01.02.2021 * Improved tests for admin interface [#1805](https://github.com/internetee/registry/pull/1805) From 1bbacbf56c16b7345ac5d74e2a01410cbf22d56f Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 11 Jan 2021 13:29:22 +0500 Subject: [PATCH 087/132] Fix class/routes namespace for ContactRequest endpoint --- .../api/v1/contact_requests_controller.rb | 23 +++++++++++ app/models/contact_request.rb | 33 ++++++++++++++++ config/routes.rb | 1 + .../api/v1/contact_requests_test.rb | 39 +++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 app/controllers/api/v1/contact_requests_controller.rb create mode 100644 app/models/contact_request.rb create mode 100644 test/integration/api/v1/contact_requests_test.rb diff --git a/app/controllers/api/v1/contact_requests_controller.rb b/app/controllers/api/v1/contact_requests_controller.rb new file mode 100644 index 000000000..0ac379396 --- /dev/null +++ b/app/controllers/api/v1/contact_requests_controller.rb @@ -0,0 +1,23 @@ +module Api + module V1 + class ContactRequestsController < BaseController + before_action :authenticate_shared_key + + # POST api/v1/contact_requests/ + def create + return head(:bad_request) if contact_request_params[:email].blank? + + ContactRequest.save_record(contact_request_params) + head(:created) + rescue ActionController::ParameterMissing + head(:bad_request) + end + + def update; end + + def contact_request_params + params.require(:contact_request).permit(:email, :whois_record_id, :name, :status, :id) + end + end + end +end diff --git a/app/models/contact_request.rb b/app/models/contact_request.rb new file mode 100644 index 000000000..5da1587dc --- /dev/null +++ b/app/models/contact_request.rb @@ -0,0 +1,33 @@ +class ContactRequest < ApplicationRecord + establish_connection :"whois_#{Rails.env}" + self.table_name = 'contact_requests' + + STATUS_NEW = 'new'.freeze + STATUS_CONFIRMED = 'confirmed'.freeze + STATUS_SENT = 'sent'.freeze + STATUSES = [STATUS_NEW, STATUS_CONFIRMED, STATUS_SENT].freeze + + validates :whois_record_id, presence: true + validates :email, presence: true + validates :name, presence: true + validates :status, inclusion: { in: STATUSES } + + attr_readonly :secret, + :valid_to + + def self.save_record(params) + contact_request = new(params) + contact_request.secret = create_random_secret + contact_request.valid_to = set_valid_to_24_hours_from_now + contact_request.status = STATUS_NEW + contact_request.save! + end + + def self.create_random_secret + SecureRandom.hex(64) + end + + def self.set_valid_to_24_hours_from_now + (Time.zone.now + 24.hours) + end +end diff --git a/config/routes.rb b/config/routes.rb index 3042eced4..93897b0f1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -91,6 +91,7 @@ Rails.application.routes.draw do end resources :auctions, only: %i[index show update], param: :uuid + resources :contact_requests, only: %i[create update], param: :uuid resources :bounces, only: %i[create] end diff --git a/test/integration/api/v1/contact_requests_test.rb b/test/integration/api/v1/contact_requests_test.rb new file mode 100644 index 000000000..78525e0b5 --- /dev/null +++ b/test/integration/api/v1/contact_requests_test.rb @@ -0,0 +1,39 @@ +require 'test_helper' + +class ApiV1ContactRequestTest < ActionDispatch::IntegrationTest + def setup + @api_key = "Basic #{ENV['api_shared_key']}" + @headers = { "Authorization": "#{@api_key}" } + @json_body = { "contact_request": valid_contact_request_body }.as_json + end + + def test_authorizes_api_request + post api_v1_contact_requests_path, params: @json_body, headers: @headers + assert_response :created + + invalid_headers = { "Authorization": "Basic invalid_api_key" } + post api_v1_contact_requests_path, params: @json_body, headers: invalid_headers + assert_response :unauthorized + end + + def test_saves_new_contact_request + request_body = @json_body.dup + random_mail = "#{rand(10000..99999)}@registry.test" + request_body['contact_request']['email'] = random_mail + + post api_v1_contact_requests_path, params: request_body, headers: @headers + assert_response :created + + contact_request = ContactRequest.last + assert_equal contact_request.email, random_mail + assert ContactRequest::STATUS_NEW, contact_request.status + end + + def valid_contact_request_body + { + "email": "aaa@bbb.com", + "whois_record_id": "1", + "name": "test" + }.as_json + end +end From b708cebbfdd2f901e1c69886eb6c56c8892d887a Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 11 Jan 2021 14:52:03 +0500 Subject: [PATCH 088/132] Add update endpoint for ContactRequests --- .../api/v1/contact_requests_controller.rb | 16 ++++++-- app/models/contact_request.rb | 5 +++ config/routes.rb | 2 +- test/fixtures/contact_requests.yml | 8 ++++ .../api/v1/contact_requests_test.rb | 39 ++++++++++++++++--- 5 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 test/fixtures/contact_requests.yml diff --git a/app/controllers/api/v1/contact_requests_controller.rb b/app/controllers/api/v1/contact_requests_controller.rb index 0ac379396..114e3c64d 100644 --- a/app/controllers/api/v1/contact_requests_controller.rb +++ b/app/controllers/api/v1/contact_requests_controller.rb @@ -9,14 +9,24 @@ module Api ContactRequest.save_record(contact_request_params) head(:created) - rescue ActionController::ParameterMissing + rescue StandardError head(:bad_request) end - def update; end + def update + return head(:bad_request) if params[:id].blank? + + record = ContactRequest.find_by(id: params[:id]) + return head(:not_found) unless record + + record.update_status(contact_request_params[:status]) + head(:ok) + rescue StandardError + head(:bad_request) + end def contact_request_params - params.require(:contact_request).permit(:email, :whois_record_id, :name, :status, :id) + params.require(:contact_request).permit(:email, :whois_record_id, :name, :status) end end end diff --git a/app/models/contact_request.rb b/app/models/contact_request.rb index 5da1587dc..a49a92f41 100644 --- a/app/models/contact_request.rb +++ b/app/models/contact_request.rb @@ -23,6 +23,11 @@ class ContactRequest < ApplicationRecord contact_request.save! end + def update_status(status) + self.status = status + save! + end + def self.create_random_secret SecureRandom.hex(64) end diff --git a/config/routes.rb b/config/routes.rb index 93897b0f1..1635789fe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -91,7 +91,7 @@ Rails.application.routes.draw do end resources :auctions, only: %i[index show update], param: :uuid - resources :contact_requests, only: %i[create update], param: :uuid + resources :contact_requests, only: %i[create update], param: :id resources :bounces, only: %i[create] end diff --git a/test/fixtures/contact_requests.yml b/test/fixtures/contact_requests.yml new file mode 100644 index 000000000..030a4d726 --- /dev/null +++ b/test/fixtures/contact_requests.yml @@ -0,0 +1,8 @@ +new: + whois_record_id: 1 + email: aaa@bbb.com + name: Testname + status: new + secret: somesecret + valid_to: 2010-07-05 + diff --git a/test/integration/api/v1/contact_requests_test.rb b/test/integration/api/v1/contact_requests_test.rb index 78525e0b5..f0621b686 100644 --- a/test/integration/api/v1/contact_requests_test.rb +++ b/test/integration/api/v1/contact_requests_test.rb @@ -4,20 +4,22 @@ class ApiV1ContactRequestTest < ActionDispatch::IntegrationTest def setup @api_key = "Basic #{ENV['api_shared_key']}" @headers = { "Authorization": "#{@api_key}" } - @json_body = { "contact_request": valid_contact_request_body }.as_json + @json_create = { "contact_request": valid_contact_request_create }.as_json + @json_update = { "contact_request": valid_contact_request_update }.as_json + @contact_request = contact_requests(:new) end def test_authorizes_api_request - post api_v1_contact_requests_path, params: @json_body, headers: @headers + post api_v1_contact_requests_path, params: @json_create, headers: @headers assert_response :created invalid_headers = { "Authorization": "Basic invalid_api_key" } - post api_v1_contact_requests_path, params: @json_body, headers: invalid_headers + post api_v1_contact_requests_path, params: @json_create, headers: invalid_headers assert_response :unauthorized end def test_saves_new_contact_request - request_body = @json_body.dup + request_body = @json_create.dup random_mail = "#{rand(10000..99999)}@registry.test" request_body['contact_request']['email'] = random_mail @@ -29,11 +31,38 @@ class ApiV1ContactRequestTest < ActionDispatch::IntegrationTest assert ContactRequest::STATUS_NEW, contact_request.status end - def valid_contact_request_body + def test_updates_existing_contact_request + request_body = @json_update.dup + + put api_v1_contact_request_path(@contact_request.id), params: request_body, headers: @headers + assert_response :ok + + @contact_request.reload + assert ContactRequest::STATUS_CONFIRMED, @contact_request.status + end + + def test_not_updates_if_status_error + request_body = @json_update.dup + request_body['contact_request']['status'] = 'some_error_status' + + put api_v1_contact_request_path(@contact_request.id), params: request_body, headers: @headers + assert_response 400 + + @contact_request.reload + assert ContactRequest::STATUS_NEW, @contact_request.status + end + + def valid_contact_request_create { "email": "aaa@bbb.com", "whois_record_id": "1", "name": "test" }.as_json end + + def valid_contact_request_update + { + "status": "#{ContactRequest::STATUS_CONFIRMED}", + }.as_json + end end From 2d510ec3a6758ce4eade3fc6d8beb968a532d8ed Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 11 Jan 2021 14:58:42 +0500 Subject: [PATCH 089/132] Fix CC --- .../api/v1/contact_requests_controller.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/v1/contact_requests_controller.rb b/app/controllers/api/v1/contact_requests_controller.rb index 114e3c64d..a02a68606 100644 --- a/app/controllers/api/v1/contact_requests_controller.rb +++ b/app/controllers/api/v1/contact_requests_controller.rb @@ -16,13 +16,18 @@ module Api def update return head(:bad_request) if params[:id].blank? - record = ContactRequest.find_by(id: params[:id]) - return head(:not_found) unless record + result = process_id(params[:id]) + head(result) + end + + def process_id(id) + record = ContactRequest.find_by(id: id) + return :not_found unless record record.update_status(contact_request_params[:status]) - head(:ok) + :ok rescue StandardError - head(:bad_request) + :bad_request end def contact_request_params From 402005cda103017954b7720d86a47e31e2fff157 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 11 Jan 2021 15:30:05 +0500 Subject: [PATCH 090/132] Add IP address saving --- app/controllers/api/v1/contact_requests_controller.rb | 4 ++-- app/models/contact_request.rb | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/v1/contact_requests_controller.rb b/app/controllers/api/v1/contact_requests_controller.rb index a02a68606..531b7e506 100644 --- a/app/controllers/api/v1/contact_requests_controller.rb +++ b/app/controllers/api/v1/contact_requests_controller.rb @@ -24,14 +24,14 @@ module Api record = ContactRequest.find_by(id: id) return :not_found unless record - record.update_status(contact_request_params[:status]) + record.update_status(contact_request_params) :ok rescue StandardError :bad_request end def contact_request_params - params.require(:contact_request).permit(:email, :whois_record_id, :name, :status) + params.require(:contact_request).permit(:email, :whois_record_id, :name, :status, :ip) end end end diff --git a/app/models/contact_request.rb b/app/models/contact_request.rb index a49a92f41..7b91bdd78 100644 --- a/app/models/contact_request.rb +++ b/app/models/contact_request.rb @@ -23,8 +23,9 @@ class ContactRequest < ApplicationRecord contact_request.save! end - def update_status(status) - self.status = status + def update_status(params) + self.status = params['status'] + self.ip_address = params['ip'] save! end From 83b5dc6fc783db7696c199a675acdb4aaf3523e6 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 18 Jan 2021 14:23:08 +0500 Subject: [PATCH 091/132] Return created/updated ContactRequest in body --- app/controllers/api/v1/contact_requests_controller.rb | 11 +++++------ app/models/contact_request.rb | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/v1/contact_requests_controller.rb b/app/controllers/api/v1/contact_requests_controller.rb index 531b7e506..2b5977f59 100644 --- a/app/controllers/api/v1/contact_requests_controller.rb +++ b/app/controllers/api/v1/contact_requests_controller.rb @@ -7,8 +7,8 @@ module Api def create return head(:bad_request) if contact_request_params[:email].blank? - ContactRequest.save_record(contact_request_params) - head(:created) + contact_request = ContactRequest.save_record(contact_request_params) + render json: contact_request, status: :created rescue StandardError head(:bad_request) end @@ -16,8 +16,7 @@ module Api def update return head(:bad_request) if params[:id].blank? - result = process_id(params[:id]) - head(result) + process_id(params[:id]) end def process_id(id) @@ -25,9 +24,9 @@ module Api return :not_found unless record record.update_status(contact_request_params) - :ok + render json: record, status: :ok rescue StandardError - :bad_request + head :bad_request end def contact_request_params diff --git a/app/models/contact_request.rb b/app/models/contact_request.rb index 7b91bdd78..e6a5e9f7d 100644 --- a/app/models/contact_request.rb +++ b/app/models/contact_request.rb @@ -21,6 +21,7 @@ class ContactRequest < ApplicationRecord contact_request.valid_to = set_valid_to_24_hours_from_now contact_request.status = STATUS_NEW contact_request.save! + contact_request end def update_status(params) From bb7effc3705223f1322f8bbfe644299d0f2fe0ea Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Thu, 4 Feb 2021 12:30:13 +0500 Subject: [PATCH 092/132] Change name of API key --- app/controllers/api/v1/base_controller.rb | 2 +- config/application.yml.sample | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb index b62b3e063..045e4395e 100644 --- a/app/controllers/api/v1/base_controller.rb +++ b/app/controllers/api/v1/base_controller.rb @@ -11,7 +11,7 @@ module Api end def authenticate_shared_key - api_key = "Basic #{ENV['api_shared_key']}" + api_key = "Basic #{ENV['internal_api_key']}" head(:unauthorized) unless api_key == request.authorization end diff --git a/config/application.yml.sample b/config/application.yml.sample index 5885c47a2..21f1df8e0 100644 --- a/config/application.yml.sample +++ b/config/application.yml.sample @@ -90,6 +90,9 @@ registrant_api_auth_allowed_ips: '127.0.0.1, 0.0.0.0' #ips, separated with comma # Bounces API api_shared_key: testkey +# Link to REST-WHOIS API +internal_api_key: testkey + # Base URL (inc. https://) of REST registrant portal # Leave blank to use internal registrant portal registrant_portal_verifications_base_url: '' From ac50634a00d7de60caf000bc71bebd75db224252 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 4 Feb 2021 13:59:52 +0200 Subject: [PATCH 093/132] added tests for getting info from contact without prefix --- .../integration/epp/contact/info/base_test.rb | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/integration/epp/contact/info/base_test.rb b/test/integration/epp/contact/info/base_test.rb index 4e4a9190e..6b04d98a2 100644 --- a/test/integration/epp/contact/info/base_test.rb +++ b/test/integration/epp/contact/info/base_test.rb @@ -44,6 +44,56 @@ class EppContactInfoBaseTest < EppTestCase contact: xml_schema).text end + def test_get_info_about_contact_with_prefix + @contact.update_columns(code: 'TEST:JOHN-001') + + request_xml = <<-XML + + + + + + TEST:JOHN-001 + + + + + XML + + post epp_info_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + + response_xml = Nokogiri::XML(response.body) + assert_epp_response :completed_successfully + assert_equal 'TEST:JOHN-001', response_xml.at_xpath('//contact:id', contact: xml_schema).text + assert_equal '+555.555', response_xml.at_xpath('//contact:voice', contact: xml_schema).text + end + + def test_get_info_about_contact_without_prefix + @contact.update_columns(code: 'TEST:JOHN-001') + + request_xml = <<-XML + + + + + + JOHN-001 + + + + + XML + + post epp_info_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + + response_xml = Nokogiri::XML(response.body) + assert_epp_response :completed_successfully + assert_equal 'TEST:JOHN-001', response_xml.at_xpath('//contact:id', contact: xml_schema).text + assert_equal '+555.555', response_xml.at_xpath('//contact:voice', contact: xml_schema).text + end + def test_hides_password_and_name_when_current_registrar_is_not_sponsoring non_sponsoring_registrar = registrars(:goodnames) @contact.update!(registrar: non_sponsoring_registrar) From 8f4f2509ef607ab86d0761d40cf7a4ef199ac8a8 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 4 Feb 2021 14:02:48 +0200 Subject: [PATCH 094/132] mend --- .ruby-version | 2 +- test/integration/epp/contact/info/base_test.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index 37c2961c2..57cf282eb 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.2 +2.6.5 diff --git a/test/integration/epp/contact/info/base_test.rb b/test/integration/epp/contact/info/base_test.rb index 6b04d98a2..4b4cb017f 100644 --- a/test/integration/epp/contact/info/base_test.rb +++ b/test/integration/epp/contact/info/base_test.rb @@ -46,6 +46,7 @@ class EppContactInfoBaseTest < EppTestCase def test_get_info_about_contact_with_prefix @contact.update_columns(code: 'TEST:JOHN-001') + assert @contact.code, 'TEST:JOHN-001' request_xml = <<-XML @@ -71,6 +72,7 @@ class EppContactInfoBaseTest < EppTestCase def test_get_info_about_contact_without_prefix @contact.update_columns(code: 'TEST:JOHN-001') + assert @contact.code, 'TEST:JOHN-001' request_xml = <<-XML From 1bdfcef36b91e0fa2d9abc7daa1754d6b2571ac3 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 4 Feb 2021 14:04:03 +0200 Subject: [PATCH 095/132] Revert "mend" This reverts commit 8f4f2509ef607ab86d0761d40cf7a4ef199ac8a8. --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index 57cf282eb..37c2961c2 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.5 +2.7.2 From 8ed3aaf78151915871869b130e8c3eaf997c96b2 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Thu, 4 Feb 2021 12:52:42 +0200 Subject: [PATCH 096/132] test added --- test/models/white_ip_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/models/white_ip_test.rb b/test/models/white_ip_test.rb index 607887730..7a0c6078b 100644 --- a/test/models/white_ip_test.rb +++ b/test/models/white_ip_test.rb @@ -38,6 +38,20 @@ class WhiteIpTest < ActiveSupport::TestCase assert white_ip.valid? end + def test_validates_include_empty_ipv4 + white_ip = WhiteIp.new + + white_ip.ipv4 = '' + white_ip.ipv6 = '001:0db8:85a3:0000:0000:8a2e:0370:7334' + white_ip.registrar = registrars(:bestnames) + + assert_nothing_raised { white_ip.save } + assert white_ip.valid? + + assert WhiteIp.include_ip?(white_ip.ipv6) + assert_not WhiteIp.include_ip?('192.168.1.1') + end + private def valid_white_ip From dc428b3c18804d927eaa2b5de75f36d6c98fd6be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Thu, 4 Feb 2021 16:24:01 +0200 Subject: [PATCH 097/132] Fix IPv4/IPv6 parsing for empty string --- app/models/white_ip.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/white_ip.rb b/app/models/white_ip.rb index 417633b12..7bb3ccb37 100644 --- a/app/models/white_ip.rb +++ b/app/models/white_ip.rb @@ -50,10 +50,10 @@ class WhiteIp < ApplicationRecord def ids_including(ip) ipv4 = ipv6 = [] if check_ip4(ip).present? - ipv4 = select { |white_ip| IPAddr.new(white_ip.ipv4, Socket::AF_INET) === check_ip4(ip) } + ipv4 = select { |white_ip| check_ip4(white_ip.ipv4) === check_ip4(ip) } end if check_ip6(ip).present? - ipv6 = select { |white_ip| IPAddr.new(white_ip.ipv6, Socket::AF_INET6) === check_ip6(ip) } + ipv6 = select { |white_ip| check_ip6(white_ip.ipv6) === check_ip6(ip) } end (ipv4 + ipv6).pluck(:id).flatten.uniq end From b34be2c0273b75a1ca3fe29b31a3954ea9a451bc Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 5 Feb 2021 10:34:32 +0200 Subject: [PATCH 098/132] modifed test --- test/models/white_ip_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/models/white_ip_test.rb b/test/models/white_ip_test.rb index 7a0c6078b..ba5abe42f 100644 --- a/test/models/white_ip_test.rb +++ b/test/models/white_ip_test.rb @@ -41,7 +41,7 @@ class WhiteIpTest < ActiveSupport::TestCase def test_validates_include_empty_ipv4 white_ip = WhiteIp.new - white_ip.ipv4 = '' + white_ip.ipv4 = nil white_ip.ipv6 = '001:0db8:85a3:0000:0000:8a2e:0370:7334' white_ip.registrar = registrars(:bestnames) From d99dd477c6fd667faf70a30a1faf72a4088d4837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Fri, 5 Feb 2021 11:45:58 +0200 Subject: [PATCH 099/132] WhiteIP: Replace empty string with nil --- app/models/white_ip.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/white_ip.rb b/app/models/white_ip.rb index 7bb3ccb37..38cee7b6b 100644 --- a/app/models/white_ip.rb +++ b/app/models/white_ip.rb @@ -4,8 +4,13 @@ class WhiteIp < ApplicationRecord validate :valid_ipv4? validate :valid_ipv6? - validate :validate_ipv4_and_ipv6 + before_save :normalize_blank_values + + def normalize_blank_values + %i[ipv4 ipv6].each { |c| self[c].present? || self[c] = nil } + end + def validate_ipv4_and_ipv6 return if ipv4.present? || ipv6.present? errors.add(:base, I18n.t(:ipv4_or_ipv6_must_be_present)) From f4abad7a9fb8e50196d45ff088a152e089159e61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Fri, 5 Feb 2021 12:46:14 +0200 Subject: [PATCH 100/132] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45ab590db..064905ba7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +05.02.2021 +* Fixed IPv4 empty string issue in case of IPv6 only entries for IP whitelist [#1833](https://github.com/internetee/registry/issues/1833) + 02.02.2021 * Fixed updateProhibited status not affecting bulk tech contact change operation [#1820](https://github.com/internetee/registry/pull/1820) From a05f21c86cc0160f41f0a4a25e292b9f0a8266c0 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Tue, 26 Jan 2021 13:58:58 +0200 Subject: [PATCH 101/132] added domain admin contacts bulk change tests --- .../api/domain_admin_contacts_test.rb | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 test/integration/api/domain_admin_contacts_test.rb diff --git a/test/integration/api/domain_admin_contacts_test.rb b/test/integration/api/domain_admin_contacts_test.rb new file mode 100644 index 000000000..75b58d318 --- /dev/null +++ b/test/integration/api/domain_admin_contacts_test.rb @@ -0,0 +1,115 @@ +require 'test_helper' + +class APIDomainAdminContactsTest < ApplicationIntegrationTest + def test_replace_all_admin_contacts_of_the_current_registrar + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', + new_contact_id: 'john-001' }, + headers: { 'HTTP_AUTHORIZATION' => http_auth_key } + + assert_nil domains(:shop).admin_contacts.find_by(code: 'william-001') + assert domains(:shop).admin_contacts.find_by(code: 'john-001') + assert domains(:airport).admin_contacts.find_by(code: 'john-001') + end + + def test_skip_discarded_domains + domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE]) + + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', + new_contact_id: 'john-001' }, + headers: { 'HTTP_AUTHORIZATION' => http_auth_key } + + assert domains(:airport).admin_contacts.find_by(code: 'william-001') + end + + def test_return_affected_domains_in_alphabetical_order + patch '/repp/v1/domains/admin_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: %w[airport.test shop.test], + skipped_domains: [] }}), + JSON.parse(response.body, symbolize_names: true) + end + + def test_return_skipped_domains_in_alphabetical_order + domains(:shop).update!(statuses: [DomainStatus::DELETE_CANDIDATE]) + domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE]) + + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', + new_contact_id: 'john-001' }, + headers: { 'HTTP_AUTHORIZATION' => http_auth_key } + + assert_response :ok + assert_equal %w[airport.test shop.test], JSON.parse(response.body, + symbolize_names: true)[:data][:skipped_domains] + end + + def test_keep_other_admin_contacts_intact + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', + new_contact_id: 'john-001' }, + headers: { 'HTTP_AUTHORIZATION' => http_auth_key } + + assert domains(:shop).admin_contacts.find_by(code: 'acme-ltd-001') + end + + def test_keep_tech_contacts_intact + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', + new_contact_id: 'john-001' }, + headers: { 'HTTP_AUTHORIZATION' => http_auth_key } + + assert domains(:airport).tech_contacts.find_by(code: 'william-001') + end + + def test_restrict_contacts_to_the_current_registrar + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'jack-001', + new_contact_id: 'william-002' }, + headers: { 'HTTP_AUTHORIZATION' => http_auth_key } + + assert_response :not_found + assert_equal ({ code: 2303, message: 'Object does not exist' }), + JSON.parse(response.body, symbolize_names: true) + end + + def test_non_existent_current_contact + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'non-existent', + new_contact_id: 'john-001' }, + headers: { 'HTTP_AUTHORIZATION' => http_auth_key } + assert_response :not_found + assert_equal ({ code: 2303, message: 'Object does not exist' }), + JSON.parse(response.body, symbolize_names: true) + end + + def test_non_existent_new_contact + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', + new_contact_id: 'non-existent' }, + headers: { 'HTTP_AUTHORIZATION' => http_auth_key } + assert_response :not_found + assert_equal ({code: 2303, message: 'Object does not exist'}), + JSON.parse(response.body, symbolize_names: true) + end + + def test_disallow_invalid_new_contact + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', + new_contact_id: 'invalid' }, + headers: { 'HTTP_AUTHORIZATION' => http_auth_key } + assert_response :bad_request + assert_equal ({ code: 2304, message: 'New contact must be valid', data: {} }), + JSON.parse(response.body, symbolize_names: true) + end + + def test_disallow_self_replacement + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', + new_contact_id: 'william-001' }, + headers: { 'HTTP_AUTHORIZATION' => http_auth_key } + assert_response :bad_request + assert_equal ({ code: 2304, message: 'New contact must be different from current', data: {} }), + JSON.parse(response.body, symbolize_names: true) + end + + private + + def http_auth_key + ActionController::HttpAuthentication::Basic.encode_credentials('test_bestnames', 'testtest') + end +end From 275da4645a84733ad20ec9db3a7492a27a0f01f4 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Wed, 27 Jan 2021 13:52:42 +0200 Subject: [PATCH 102/132] added test for admin bulk change when domain has status update prohibited --- .../api/domain_admin_contacts_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/integration/api/domain_admin_contacts_test.rb b/test/integration/api/domain_admin_contacts_test.rb index 75b58d318..babc58207 100644 --- a/test/integration/api/domain_admin_contacts_test.rb +++ b/test/integration/api/domain_admin_contacts_test.rb @@ -107,6 +107,24 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest JSON.parse(response.body, symbolize_names: true) end + def test_admin_bulk_changed_when_domain_update_prohibited + domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED]) + + shop_admin_contact = Contact.find_by(code: 'jane-001') + assert domains(:shop).admin_contacts.include?(shop_admin_contact) + + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'jane-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 efdb445488e9484b827939107de31d2f88b51ac2 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 29 Jan 2021 14:41:23 +0200 Subject: [PATCH 103/132] added new test, changed contacts values --- .../api/domain_admin_contacts_test.rb | 71 ++++++++++++------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/test/integration/api/domain_admin_contacts_test.rb b/test/integration/api/domain_admin_contacts_test.rb index babc58207..ff56096d2 100644 --- a/test/integration/api/domain_admin_contacts_test.rb +++ b/test/integration/api/domain_admin_contacts_test.rb @@ -1,29 +1,52 @@ require 'test_helper' class APIDomainAdminContactsTest < ApplicationIntegrationTest - def test_replace_all_admin_contacts_of_the_current_registrar - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', - new_contact_id: 'john-001' }, + setup do + @admin_current = domains(:shop).admin_contacts.find_by(code: 'jane-001') + @admin_new = contacts(:william) + + @admin_new.update(ident: @admin_current.ident, + ident_type: @admin_current.ident_type, + ident_country_code: @admin_current.ident_country_code) + end + + def test_replace_all_admin_contacts_when_ident_data_doesnt_match + @admin_new.update(ident: '777' , + ident_type: 'priv', + ident_country_code: 'LV') + + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, + new_contact_id: @admin_new }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } - assert_nil domains(:shop).admin_contacts.find_by(code: 'william-001') - assert domains(:shop).admin_contacts.find_by(code: 'john-001') - assert domains(:airport).admin_contacts.find_by(code: 'john-001') + assert_response :bad_request + assert_equal ({ code: 2304, message: 'New admin contact must have same ident' }), + JSON.parse(response.body, symbolize_names: true) + end + + def test_replace_all_admin_contacts_of_the_current_registrar + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, + new_contact_id: @admin_new }, + headers: { 'HTTP_AUTHORIZATION' => http_auth_key } + + assert_nil domains(:shop).admin_contacts.find_by(code: @admin_current) + assert domains(:shop).admin_contacts.find_by(code: @admin_new) + assert domains(:airport).admin_contacts.find_by(code: @admin_new) end def test_skip_discarded_domains domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE]) - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', - new_contact_id: 'john-001' }, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, + new_contact_id: @admin_new }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } - assert domains(:airport).admin_contacts.find_by(code: 'william-001') + assert domains(:shop).admin_contacts.find_by(code: @admin_current) end def test_return_affected_domains_in_alphabetical_order - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', - new_contact_id: 'john-001' }, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, + new_contact_id: @admin_new }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :ok @@ -36,8 +59,8 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest domains(:shop).update!(statuses: [DomainStatus::DELETE_CANDIDATE]) domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE]) - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', - new_contact_id: 'john-001' }, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, + new_contact_id: @admin_new }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :ok @@ -46,23 +69,23 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest end def test_keep_other_admin_contacts_intact - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', - new_contact_id: 'john-001' }, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, + new_contact_id: @admin_new }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } - assert domains(:shop).admin_contacts.find_by(code: 'acme-ltd-001') + assert domains(:airport).admin_contacts.find_by(code: 'john-001') end def test_keep_tech_contacts_intact - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', - new_contact_id: 'john-001' }, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, + new_contact_id: @admin_new }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert domains(:airport).tech_contacts.find_by(code: 'william-001') end def test_restrict_contacts_to_the_current_registrar - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'jack-001', + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, new_contact_id: 'william-002' }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } @@ -73,7 +96,7 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest def test_non_existent_current_contact patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'non-existent', - new_contact_id: 'john-001' }, + new_contact_id: @admin_new}, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :not_found assert_equal ({ code: 2303, message: 'Object does not exist' }), @@ -81,7 +104,7 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest end def test_non_existent_new_contact - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, new_contact_id: 'non-existent' }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :not_found @@ -90,7 +113,7 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest end def test_disallow_invalid_new_contact - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, new_contact_id: 'invalid' }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :bad_request @@ -99,8 +122,8 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest end def test_disallow_self_replacement - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'william-001', - new_contact_id: 'william-001' }, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, + new_contact_id: @admin_current }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :bad_request assert_equal ({ code: 2304, message: 'New contact must be different from current', data: {} }), From f3f89bedd72ae1a998d6f916cca8232a37bc5c9e Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 1 Feb 2021 15:35:44 +0500 Subject: [PATCH 104/132] Add first version of admin bulk change --- .../v1/domains/admin_contacts_controller.rb | 40 +++++++++++++ app/models/admin_domain_contact.rb | 21 +++++++ app/models/concerns/contact/identical.rb | 6 ++ config/routes.rb | 1 + .../api/domain_admin_contacts_test.rb | 56 +++++++++---------- 5 files changed, 96 insertions(+), 28 deletions(-) create mode 100644 app/controllers/repp/v1/domains/admin_contacts_controller.rb diff --git a/app/controllers/repp/v1/domains/admin_contacts_controller.rb b/app/controllers/repp/v1/domains/admin_contacts_controller.rb new file mode 100644 index 000000000..035cd36fd --- /dev/null +++ b/app/controllers/repp/v1/domains/admin_contacts_controller.rb @@ -0,0 +1,40 @@ +module Repp + module V1 + module Domains + class AdminContactsController < BaseController + before_action :set_current_contact, only: [:update] + before_action :set_new_contact, only: [:update] + + def set_current_contact + @current_contact = current_user.registrar.contacts.find_by!(code: contact_params[:current_contact_id]) + end + + def set_new_contact + @new_contact = current_user.registrar.contacts.find_by!(code: params[:new_contact_id]) + end + + def update + @epp_errors ||= [] + @epp_errors << { code: 2304, msg: 'New contact must be valid' } if @new_contact.invalid? + + unless @new_contact.identical_to?(@current_contact) + @epp_errors << { code: 2304, msg: 'Admin contacts must be identical' } + end + + return handle_errors if @epp_errors.any? + + affected, skipped = AdminDomainContact.replace(@current_contact, @new_contact) + @response = { affected_domains: affected, skipped_domains: skipped } + render_success(data: @response) + end + + private + + def contact_params + params.require(%i[current_contact_id new_contact_id]) + params.permit(:current_contact_id, :new_contact_id) + end + end + end + end +end diff --git a/app/models/admin_domain_contact.rb b/app/models/admin_domain_contact.rb index 14907403d..9fb8166af 100644 --- a/app/models/admin_domain_contact.rb +++ b/app/models/admin_domain_contact.rb @@ -1,2 +1,23 @@ class AdminDomainContact < DomainContact + def self.replace(current_contact, new_contact) + affected_domains = [] + skipped_domains = [] + admin_contacts = where(contact: current_contact) + + admin_contacts.each do |admin_contact| + if admin_contact.domain.discarded? + skipped_domains << admin_contact.domain.name + next + end + begin + admin_contact.contact = new_contact + admin_contact.save! + affected_domains << admin_contact.domain.name + rescue ActiveRecord::RecordNotUnique + skipped_domains << admin_contact.domain.name + end + end + + [affected_domains.sort, skipped_domains.sort] + end end diff --git a/app/models/concerns/contact/identical.rb b/app/models/concerns/contact/identical.rb index f529e09ac..aa527f723 100644 --- a/app/models/concerns/contact/identical.rb +++ b/app/models/concerns/contact/identical.rb @@ -20,6 +20,12 @@ module Concerns::Contact::Identical .where.not(id: id).take end + def identical_to?(contact) + IDENTIFIABLE_ATTRIBUTES.all? do |attribute| + self.attributes[attribute] == contact.attributes[attribute] + end + end + private def identifiable_hash diff --git a/config/routes.rb b/config/routes.rb index 3042eced4..16102f2b6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -64,6 +64,7 @@ Rails.application.routes.draw do get ':id/transfer_info', to: 'domains#transfer_info', constraints: { id: /.*/ } post 'transfer', to: 'domains#transfer' patch 'contacts', to: 'domains/contacts#update' + patch 'admin_contacts', to: 'domains/admin_contacts#update' post 'renew/bulk', to: 'domains/renews#bulk_renew' end end diff --git a/test/integration/api/domain_admin_contacts_test.rb b/test/integration/api/domain_admin_contacts_test.rb index ff56096d2..f1ad9ff27 100644 --- a/test/integration/api/domain_admin_contacts_test.rb +++ b/test/integration/api/domain_admin_contacts_test.rb @@ -5,48 +5,48 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest @admin_current = domains(:shop).admin_contacts.find_by(code: 'jane-001') @admin_new = contacts(:william) - @admin_new.update(ident: @admin_current.ident, - ident_type: @admin_current.ident_type, + @admin_new.update(ident: @admin_current.ident, + ident_type: @admin_current.ident_type, ident_country_code: @admin_current.ident_country_code) end def test_replace_all_admin_contacts_when_ident_data_doesnt_match @admin_new.update(ident: '777' , - ident_type: 'priv', + ident_type: 'priv', ident_country_code: 'LV') - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, - new_contact_id: @admin_new }, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code, + new_contact_id: @admin_new.code }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :bad_request - assert_equal ({ code: 2304, message: 'New admin contact must have same ident' }), + assert_equal ({ code: 2304, message: 'Admin contacts must be identical', data: {} }), JSON.parse(response.body, symbolize_names: true) end def test_replace_all_admin_contacts_of_the_current_registrar - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, - new_contact_id: @admin_new }, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code, + new_contact_id: @admin_new.code }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } - assert_nil domains(:shop).admin_contacts.find_by(code: @admin_current) - assert domains(:shop).admin_contacts.find_by(code: @admin_new) - assert domains(:airport).admin_contacts.find_by(code: @admin_new) + assert_nil domains(:shop).admin_contacts.find_by(code: @admin_current.code) + assert domains(:shop).admin_contacts.find_by(code: @admin_new.code) + assert domains(:airport).admin_contacts.find_by(code: @admin_new.code) end def test_skip_discarded_domains domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE]) - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, - new_contact_id: @admin_new }, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code, + new_contact_id: @admin_new.code }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } - assert domains(:shop).admin_contacts.find_by(code: @admin_current) + assert domains(:shop).admin_contacts.find_by(code: @admin_current.code) end def test_return_affected_domains_in_alphabetical_order - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, - new_contact_id: @admin_new }, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code, + new_contact_id: @admin_new.code }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :ok @@ -59,8 +59,8 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest domains(:shop).update!(statuses: [DomainStatus::DELETE_CANDIDATE]) domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE]) - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, - new_contact_id: @admin_new }, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code, + new_contact_id: @admin_new.code }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :ok @@ -69,23 +69,23 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest end def test_keep_other_admin_contacts_intact - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, - new_contact_id: @admin_new }, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code, + new_contact_id: @admin_new.code }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert domains(:airport).admin_contacts.find_by(code: 'john-001') end def test_keep_tech_contacts_intact - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, - new_contact_id: @admin_new }, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code, + new_contact_id: @admin_new.code }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert domains(:airport).tech_contacts.find_by(code: 'william-001') end def test_restrict_contacts_to_the_current_registrar - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code, new_contact_id: 'william-002' }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } @@ -96,7 +96,7 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest def test_non_existent_current_contact patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'non-existent', - new_contact_id: @admin_new}, + new_contact_id: @admin_new.code}, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :not_found assert_equal ({ code: 2303, message: 'Object does not exist' }), @@ -104,7 +104,7 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest end def test_non_existent_new_contact - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code, new_contact_id: 'non-existent' }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :not_found @@ -113,7 +113,7 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest end def test_disallow_invalid_new_contact - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code, new_contact_id: 'invalid' }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :bad_request @@ -122,8 +122,8 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest end def test_disallow_self_replacement - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current, - new_contact_id: @admin_current }, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code, + new_contact_id: @admin_current.code }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :bad_request assert_equal ({ code: 2304, message: 'New contact must be different from current', data: {} }), From 3c0f7b3a86d5366a7c9514afeb4c833ac8895380 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 1 Feb 2021 15:50:31 +0500 Subject: [PATCH 105/132] Modify tests to make sure working pair of contacts is identical --- app/models/admin_domain_contact.rb | 1 - test/integration/api/domain_admin_contacts_test.rb | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/admin_domain_contact.rb b/app/models/admin_domain_contact.rb index 9fb8166af..426ea2ead 100644 --- a/app/models/admin_domain_contact.rb +++ b/app/models/admin_domain_contact.rb @@ -17,7 +17,6 @@ class AdminDomainContact < DomainContact skipped_domains << admin_contact.domain.name end end - [affected_domains.sort, skipped_domains.sort] end end diff --git a/test/integration/api/domain_admin_contacts_test.rb b/test/integration/api/domain_admin_contacts_test.rb index f1ad9ff27..bea1a9545 100644 --- a/test/integration/api/domain_admin_contacts_test.rb +++ b/test/integration/api/domain_admin_contacts_test.rb @@ -7,7 +7,12 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest @admin_new.update(ident: @admin_current.ident, ident_type: @admin_current.ident_type, - ident_country_code: @admin_current.ident_country_code) + ident_country_code: @admin_current.ident_country_code, + name: @admin_current.name, + email: @admin_current.email, + phone: @admin_current.phone, + fax: @admin_current.fax, + org_name: @admin_current.org_name) end def test_replace_all_admin_contacts_when_ident_data_doesnt_match @@ -25,6 +30,7 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest end def test_replace_all_admin_contacts_of_the_current_registrar + assert @admin_new.identical_to?(@admin_current) patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code, new_contact_id: @admin_new.code }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } From 38b7e52ac8b8dd19fac44d6f850855d91ba91323 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 1 Feb 2021 16:08:51 +0500 Subject: [PATCH 106/132] Modify tests to have :airport domain included in processing --- test/integration/api/domain_admin_contacts_test.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/integration/api/domain_admin_contacts_test.rb b/test/integration/api/domain_admin_contacts_test.rb index bea1a9545..cce80e0c3 100644 --- a/test/integration/api/domain_admin_contacts_test.rb +++ b/test/integration/api/domain_admin_contacts_test.rb @@ -3,6 +3,8 @@ require 'test_helper' class APIDomainAdminContactsTest < ApplicationIntegrationTest setup do @admin_current = domains(:shop).admin_contacts.find_by(code: 'jane-001') + domain = domains(:airport) + domain.admin_contacts = [@admin_current] @admin_new = contacts(:william) @admin_new.update(ident: @admin_current.ident, From fc3a764896e473e0cd69a369f843260cf41e978e Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 1 Feb 2021 16:52:38 +0500 Subject: [PATCH 107/132] Fix discarded domains test --- app/models/concerns/contact/identical.rb | 9 ++++++++- test/integration/api/domain_admin_contacts_test.rb | 9 ++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/models/concerns/contact/identical.rb b/app/models/concerns/contact/identical.rb index aa527f723..1a5516bc5 100644 --- a/app/models/concerns/contact/identical.rb +++ b/app/models/concerns/contact/identical.rb @@ -11,6 +11,13 @@ module Concerns::Contact::Identical ident_country_code org_name ] + + IDENTICAL_ATTRIBUTES = %w[ + ident + ident_type + ident_country_code + ] + private_constant :IDENTIFIABLE_ATTRIBUTES def identical(registrar) @@ -21,7 +28,7 @@ module Concerns::Contact::Identical end def identical_to?(contact) - IDENTIFIABLE_ATTRIBUTES.all? do |attribute| + IDENTICAL_ATTRIBUTES.all? do |attribute| self.attributes[attribute] == contact.attributes[attribute] end end diff --git a/test/integration/api/domain_admin_contacts_test.rb b/test/integration/api/domain_admin_contacts_test.rb index cce80e0c3..2e8cbe6da 100644 --- a/test/integration/api/domain_admin_contacts_test.rb +++ b/test/integration/api/domain_admin_contacts_test.rb @@ -9,12 +9,7 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest @admin_new.update(ident: @admin_current.ident, ident_type: @admin_current.ident_type, - ident_country_code: @admin_current.ident_country_code, - name: @admin_current.name, - email: @admin_current.email, - phone: @admin_current.phone, - fax: @admin_current.fax, - org_name: @admin_current.org_name) + ident_country_code: @admin_current.ident_country_code) end def test_replace_all_admin_contacts_when_ident_data_doesnt_match @@ -49,7 +44,7 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest new_contact_id: @admin_new.code }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } - assert domains(:shop).admin_contacts.find_by(code: @admin_current.code) + assert domains(:airport).admin_contacts.find_by(code: @admin_current.code) end def test_return_affected_domains_in_alphabetical_order From da032dad798545dc5e955429ebdbb80b5fd0d8d0 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 1 Feb 2021 17:13:19 +0500 Subject: [PATCH 108/132] Add BulkUpdatable concern, fix tests --- app/models/admin_domain_contact.rb | 2 +- .../api/domain_admin_contacts_test.rb | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/app/models/admin_domain_contact.rb b/app/models/admin_domain_contact.rb index 426ea2ead..d84ac7793 100644 --- a/app/models/admin_domain_contact.rb +++ b/app/models/admin_domain_contact.rb @@ -5,7 +5,7 @@ class AdminDomainContact < DomainContact admin_contacts = where(contact: current_contact) admin_contacts.each do |admin_contact| - if admin_contact.domain.discarded? + if admin_contact.domain.bulk_update_prohibited? skipped_domains << admin_contact.domain.name next end diff --git a/test/integration/api/domain_admin_contacts_test.rb b/test/integration/api/domain_admin_contacts_test.rb index 2e8cbe6da..cd5b92865 100644 --- a/test/integration/api/domain_admin_contacts_test.rb +++ b/test/integration/api/domain_admin_contacts_test.rb @@ -4,7 +4,7 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest setup do @admin_current = domains(:shop).admin_contacts.find_by(code: 'jane-001') domain = domains(:airport) - domain.admin_contacts = [@admin_current] + domain.admin_contacts << @admin_current @admin_new = contacts(:william) @admin_new.update(ident: @admin_current.ident, @@ -48,6 +48,8 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest end def test_return_affected_domains_in_alphabetical_order + domain = domains(:airport) + domain.admin_contacts = [@admin_current] patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code, new_contact_id: @admin_new.code }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } @@ -124,23 +126,15 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest JSON.parse(response.body, symbolize_names: true) end - def test_disallow_self_replacement - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code, - new_contact_id: @admin_current.code }, - headers: { 'HTTP_AUTHORIZATION' => http_auth_key } - assert_response :bad_request - assert_equal ({ code: 2304, message: 'New contact must be different from current', data: {} }), - JSON.parse(response.body, symbolize_names: true) - end - def test_admin_bulk_changed_when_domain_update_prohibited domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED]) + domains(:airport).admin_contacts = [@admin_current] shop_admin_contact = Contact.find_by(code: 'jane-001') assert domains(:shop).admin_contacts.include?(shop_admin_contact) - patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'jane-001', - new_contact_id: 'john-001' }, + patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code, + new_contact_id: @admin_new.code }, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :ok From f6a2d91d61c311ceff292dd210b5ed54743b6eed Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 1 Feb 2021 17:21:29 +0500 Subject: [PATCH 109/132] Fix CC issues --- .../v1/domains/admin_contacts_controller.rb | 23 ++------------ .../v1/domains/base_contacts_controller.rb | 31 +++++++++++++++++++ .../repp/v1/domains/contacts_controller.rb | 25 ++------------- app/models/admin_domain_contact.rb | 4 +++ app/models/concerns/contact/identical.rb | 4 +-- 5 files changed, 41 insertions(+), 46 deletions(-) create mode 100644 app/controllers/repp/v1/domains/base_contacts_controller.rb diff --git a/app/controllers/repp/v1/domains/admin_contacts_controller.rb b/app/controllers/repp/v1/domains/admin_contacts_controller.rb index 035cd36fd..2e9a285eb 100644 --- a/app/controllers/repp/v1/domains/admin_contacts_controller.rb +++ b/app/controllers/repp/v1/domains/admin_contacts_controller.rb @@ -1,21 +1,9 @@ module Repp module V1 module Domains - class AdminContactsController < BaseController - before_action :set_current_contact, only: [:update] - before_action :set_new_contact, only: [:update] - - def set_current_contact - @current_contact = current_user.registrar.contacts.find_by!(code: contact_params[:current_contact_id]) - end - - def set_new_contact - @new_contact = current_user.registrar.contacts.find_by!(code: params[:new_contact_id]) - end - + class AdminContactsController < BaseContactsController def update - @epp_errors ||= [] - @epp_errors << { code: 2304, msg: 'New contact must be valid' } if @new_contact.invalid? + super unless @new_contact.identical_to?(@current_contact) @epp_errors << { code: 2304, msg: 'Admin contacts must be identical' } @@ -27,13 +15,6 @@ module Repp @response = { affected_domains: affected, skipped_domains: skipped } render_success(data: @response) end - - private - - def contact_params - params.require(%i[current_contact_id new_contact_id]) - params.permit(:current_contact_id, :new_contact_id) - end end end end diff --git a/app/controllers/repp/v1/domains/base_contacts_controller.rb b/app/controllers/repp/v1/domains/base_contacts_controller.rb new file mode 100644 index 000000000..b601c5313 --- /dev/null +++ b/app/controllers/repp/v1/domains/base_contacts_controller.rb @@ -0,0 +1,31 @@ +module Repp + module V1 + module Domains + class BaseContactsController < BaseController + before_action :set_current_contact, only: [:update] + before_action :set_new_contact, only: [:update] + + def set_current_contact + @current_contact = current_user.registrar.contacts + .find_by!(code: contact_params[:current_contact_id]) + end + + def set_new_contact + @new_contact = current_user.registrar.contacts.find_by!(code: params[:new_contact_id]) + end + + def update + @epp_errors ||= [] + @epp_errors << { code: 2304, msg: 'New contact must be valid' } if @new_contact.invalid? + end + + private + + def contact_params + params.require(%i[current_contact_id new_contact_id]) + params.permit(:current_contact_id, :new_contact_id) + end + end + end + end +end diff --git a/app/controllers/repp/v1/domains/contacts_controller.rb b/app/controllers/repp/v1/domains/contacts_controller.rb index 75404e0c6..131615570 100644 --- a/app/controllers/repp/v1/domains/contacts_controller.rb +++ b/app/controllers/repp/v1/domains/contacts_controller.rb @@ -1,23 +1,9 @@ module Repp module V1 module Domains - class ContactsController < BaseController - before_action :set_current_contact, only: [:update] - before_action :set_new_contact, only: [:update] - - def set_current_contact - @current_contact = current_user.registrar.contacts.find_by!( - code: contact_params[:current_contact_id] - ) - end - - def set_new_contact - @new_contact = current_user.registrar.contacts.find_by!(code: params[:new_contact_id]) - end - + class ContactsController < BaseContactsController def update - @epp_errors ||= [] - @epp_errors << { code: 2304, msg: 'New contact must be valid' } if @new_contact.invalid? + super if @new_contact == @current_contact @epp_errors << { code: 2304, msg: 'New contact must be different from current' } @@ -29,13 +15,6 @@ module Repp @response = { affected_domains: affected, skipped_domains: skipped } render_success(data: @response) end - - private - - def contact_params - params.require(%i[current_contact_id new_contact_id]) - params.permit(:current_contact_id, :new_contact_id) - end end end end diff --git a/app/models/admin_domain_contact.rb b/app/models/admin_domain_contact.rb index d84ac7793..7ccf3efcb 100644 --- a/app/models/admin_domain_contact.rb +++ b/app/models/admin_domain_contact.rb @@ -1,4 +1,6 @@ class AdminDomainContact < DomainContact + # rubocop:disable Metrics/AbcSize + # rubocop:disable Metrics/MethodLength def self.replace(current_contact, new_contact) affected_domains = [] skipped_domains = [] @@ -19,4 +21,6 @@ class AdminDomainContact < DomainContact end [affected_domains.sort, skipped_domains.sort] end + # rubocop:enable Metrics/AbcSize + # rubocop:enable Metrics/MethodLength end diff --git a/app/models/concerns/contact/identical.rb b/app/models/concerns/contact/identical.rb index 1a5516bc5..5327d1704 100644 --- a/app/models/concerns/contact/identical.rb +++ b/app/models/concerns/contact/identical.rb @@ -16,7 +16,7 @@ module Concerns::Contact::Identical ident ident_type ident_country_code - ] + ].freeze private_constant :IDENTIFIABLE_ATTRIBUTES @@ -29,7 +29,7 @@ module Concerns::Contact::Identical def identical_to?(contact) IDENTICAL_ATTRIBUTES.all? do |attribute| - self.attributes[attribute] == contact.attributes[attribute] + attributes[attribute] == contact.attributes[attribute] end end From fbad7b00b27c785365bca23150672303cb66682d Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Fri, 5 Feb 2021 15:12:36 +0500 Subject: [PATCH 110/132] Refactor bulk_change & tech_contact controllers code to be more reusable --- .../registrar/bulk_change_controller.rb | 30 ++++++++++++++++++ .../registrar/tech_contacts_controller.rb | 31 +++---------------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/app/controllers/registrar/bulk_change_controller.rb b/app/controllers/registrar/bulk_change_controller.rb index 801ab0516..218e7dc5d 100644 --- a/app/controllers/registrar/bulk_change_controller.rb +++ b/app/controllers/registrar/bulk_change_controller.rb @@ -26,6 +26,36 @@ class Registrar private + def do_request(request, uri) + if Rails.env.test? + response = Net::HTTP.start(uri.hostname, uri.port, + use_ssl: (uri.scheme == 'https'), + verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http| + http.request(request) + end + elsif Rails.env.development? + client_cert = File.read(ENV['cert_path']) + client_key = File.read(ENV['key_path']) + response = Net::HTTP.start(uri.hostname, uri.port, + use_ssl: (uri.scheme == 'https'), + verify_mode: OpenSSL::SSL::VERIFY_NONE, + cert: OpenSSL::X509::Certificate.new(client_cert), + key: OpenSSL::PKey::RSA.new(client_key)) do |http| + http.request(request) + end + else + client_cert = File.read(ENV['cert_path']) + client_key = File.read(ENV['key_path']) + response = Net::HTTP.start(uri.hostname, uri.port, + use_ssl: (uri.scheme == 'https'), + cert: OpenSSL::X509::Certificate.new(client_cert), + key: OpenSSL::PKey::RSA.new(client_key)) do |http| + http.request(request) + end + end + response + end + def ready_to_renew? domain_ids_for_bulk_renew.present? && params[:renew].present? end diff --git a/app/controllers/registrar/tech_contacts_controller.rb b/app/controllers/registrar/tech_contacts_controller.rb index 001651250..5cb0e8ee6 100644 --- a/app/controllers/registrar/tech_contacts_controller.rb +++ b/app/controllers/registrar/tech_contacts_controller.rb @@ -1,9 +1,11 @@ class Registrar class TechContactsController < BulkChangeController + BASE_URL = URI.parse("#{ENV['repp_url']}domains/contacts").freeze + def update authorize! :manage, :repp - uri = URI.parse("#{ENV['repp_url']}domains/contacts") + uri = BASE_URL request = Net::HTTP::Patch.new(uri) request.set_form_data(current_contact_id: params[:current_contact_id], @@ -11,32 +13,7 @@ class Registrar request.basic_auth(current_registrar_user.username, current_registrar_user.plain_text_password) - if Rails.env.test? - response = Net::HTTP.start(uri.hostname, uri.port, - use_ssl: (uri.scheme == 'https'), - verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http| - http.request(request) - end - elsif Rails.env.development? - client_cert = File.read(ENV['cert_path']) - client_key = File.read(ENV['key_path']) - response = Net::HTTP.start(uri.hostname, uri.port, - use_ssl: (uri.scheme == 'https'), - verify_mode: OpenSSL::SSL::VERIFY_NONE, - cert: OpenSSL::X509::Certificate.new(client_cert), - key: OpenSSL::PKey::RSA.new(client_key)) do |http| - http.request(request) - end - else - client_cert = File.read(ENV['cert_path']) - client_key = File.read(ENV['key_path']) - response = Net::HTTP.start(uri.hostname, uri.port, - use_ssl: (uri.scheme == 'https'), - cert: OpenSSL::X509::Certificate.new(client_cert), - key: OpenSSL::PKey::RSA.new(client_key)) do |http| - http.request(request) - end - end + response = do_request(request, uri) parsed_response = JSON.parse(response.body, symbolize_names: true) From 3979fc5f8f1702dd271200d58393e9d2c33547c0 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Fri, 5 Feb 2021 15:27:10 +0500 Subject: [PATCH 111/132] Fix CC issues --- .../registrar/bulk_change_controller.rb | 82 +++++++++++++------ .../registrar/domain_transfers_controller.rb | 27 +----- .../registrar/nameservers_controller.rb | 27 +----- .../registrar/tech_contacts_controller.rb | 24 ++---- 4 files changed, 65 insertions(+), 95 deletions(-) diff --git a/app/controllers/registrar/bulk_change_controller.rb b/app/controllers/registrar/bulk_change_controller.rb index 218e7dc5d..63d7b6cb1 100644 --- a/app/controllers/registrar/bulk_change_controller.rb +++ b/app/controllers/registrar/bulk_change_controller.rb @@ -26,36 +26,70 @@ class Registrar private - def do_request(request, uri) - if Rails.env.test? - response = Net::HTTP.start(uri.hostname, uri.port, - use_ssl: (uri.scheme == 'https'), - verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http| - http.request(request) - end - elsif Rails.env.development? - client_cert = File.read(ENV['cert_path']) - client_key = File.read(ENV['key_path']) - response = Net::HTTP.start(uri.hostname, uri.port, - use_ssl: (uri.scheme == 'https'), - verify_mode: OpenSSL::SSL::VERIFY_NONE, - cert: OpenSSL::X509::Certificate.new(client_cert), - key: OpenSSL::PKey::RSA.new(client_key)) do |http| - http.request(request) + def process_response(response:, start_notice: "", active_tab:) + parsed_response = JSON.parse(response.body, symbolize_names: true) + + if response.code == '200' + notices = [start_notice] + + notices << "#{t('registrar.tech_contacts.process_request.affected_domains')}: " \ + "#{parsed_response[:data][:affected_domains].join(', ')}" + + if parsed_response[:data][:skipped_domains] + notices << "#{t('registrar.tech_contacts.process_request.skipped_domains')}: " \ + "#{parsed_response[:data][:skipped_domains].join(', ')}" end + + flash[:notice] = notices.join(', ') + redirect_to registrar_domains_url else - client_cert = File.read(ENV['cert_path']) - client_key = File.read(ENV['key_path']) - response = Net::HTTP.start(uri.hostname, uri.port, - use_ssl: (uri.scheme == 'https'), - cert: OpenSSL::X509::Certificate.new(client_cert), - key: OpenSSL::PKey::RSA.new(client_key)) do |http| - http.request(request) - end + @error = response.code == '404' ? 'Contact(s) not found' : parsed_response[:message] + render file: 'registrar/bulk_change/new', locals: { active_tab: active_tab } end + end + + def do_request(request, uri) + response = if Rails.env.test? + do_test_request(request, uri) + elsif Rails.env.development? + do_dev_request(request, uri) + else + do_live_request(request, uri) + end response end + def do_live_request(request, uri) + client_cert = File.read(ENV['cert_path']) + client_key = File.read(ENV['key_path']) + Net::HTTP.start(uri.hostname, uri.port, + use_ssl: (uri.scheme == 'https'), + cert: OpenSSL::X509::Certificate.new(client_cert), + key: OpenSSL::PKey::RSA.new(client_key)) do |http| + http.request(request) + end + end + + def do_dev_request(request, uri) + client_cert = File.read(ENV['cert_path']) + client_key = File.read(ENV['key_path']) + Net::HTTP.start(uri.hostname, uri.port, + use_ssl: (uri.scheme == 'https'), + verify_mode: OpenSSL::SSL::VERIFY_NONE, + cert: OpenSSL::X509::Certificate.new(client_cert), + key: OpenSSL::PKey::RSA.new(client_key)) do |http| + http.request(request) + end + end + + def do_test_request(request, uri) + Net::HTTP.start(uri.hostname, uri.port, + use_ssl: (uri.scheme == 'https'), + verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http| + http.request(request) + end + end + def ready_to_renew? domain_ids_for_bulk_renew.present? && params[:renew].present? end diff --git a/app/controllers/registrar/domain_transfers_controller.rb b/app/controllers/registrar/domain_transfers_controller.rb index 584a50d33..e055c38d8 100644 --- a/app/controllers/registrar/domain_transfers_controller.rb +++ b/app/controllers/registrar/domain_transfers_controller.rb @@ -25,32 +25,7 @@ class Registrar current_registrar_user.plain_text_password) - if Rails.env.test? - response = Net::HTTP.start(uri.hostname, uri.port, - use_ssl: (uri.scheme == 'https'), - verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http| - http.request(request) - end - elsif Rails.env.development? - client_cert = File.read(ENV['cert_path']) - client_key = File.read(ENV['key_path']) - response = Net::HTTP.start(uri.hostname, uri.port, - use_ssl: (uri.scheme == 'https'), - verify_mode: OpenSSL::SSL::VERIFY_NONE, - cert: OpenSSL::X509::Certificate.new(client_cert), - key: OpenSSL::PKey::RSA.new(client_key)) do |http| - http.request(request) - end - else - client_cert = File.read(ENV['cert_path']) - client_key = File.read(ENV['key_path']) - response = Net::HTTP.start(uri.hostname, uri.port, - use_ssl: (uri.scheme == 'https'), - cert: OpenSSL::X509::Certificate.new(client_cert), - key: OpenSSL::PKey::RSA.new(client_key)) do |http| - http.request(request) - end - end + response = do_request(request, uri) parsed_response = JSON.parse(response.body, symbolize_names: true) diff --git a/app/controllers/registrar/nameservers_controller.rb b/app/controllers/registrar/nameservers_controller.rb index 52c43bb1d..3eb23cd48 100644 --- a/app/controllers/registrar/nameservers_controller.rb +++ b/app/controllers/registrar/nameservers_controller.rb @@ -18,32 +18,7 @@ class Registrar request.basic_auth(current_registrar_user.username, current_registrar_user.plain_text_password) - if Rails.env.test? - response = Net::HTTP.start(uri.hostname, uri.port, - use_ssl: (uri.scheme == 'https'), - verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http| - http.request(request) - end - elsif Rails.env.development? - client_cert = File.read(ENV['cert_path']) - client_key = File.read(ENV['key_path']) - response = Net::HTTP.start(uri.hostname, uri.port, - use_ssl: (uri.scheme == 'https'), - verify_mode: OpenSSL::SSL::VERIFY_NONE, - cert: OpenSSL::X509::Certificate.new(client_cert), - key: OpenSSL::PKey::RSA.new(client_key)) do |http| - http.request(request) - end - else - client_cert = File.read(ENV['cert_path']) - client_key = File.read(ENV['key_path']) - response = Net::HTTP.start(uri.hostname, uri.port, - use_ssl: (uri.scheme == 'https'), - cert: OpenSSL::X509::Certificate.new(client_cert), - key: OpenSSL::PKey::RSA.new(client_key)) do |http| - http.request(request) - end - end + response = do_request(request, uri) parsed_response = JSON.parse(response.body, symbolize_names: true) diff --git a/app/controllers/registrar/tech_contacts_controller.rb b/app/controllers/registrar/tech_contacts_controller.rb index 5cb0e8ee6..90dc333f6 100644 --- a/app/controllers/registrar/tech_contacts_controller.rb +++ b/app/controllers/registrar/tech_contacts_controller.rb @@ -1,12 +1,12 @@ class Registrar class TechContactsController < BulkChangeController BASE_URL = URI.parse("#{ENV['repp_url']}domains/contacts").freeze + ACTIVE_TAB = :technical_contact def update authorize! :manage, :repp uri = BASE_URL - request = Net::HTTP::Patch.new(uri) request.set_form_data(current_contact_id: params[:current_contact_id], new_contact_id: params[:new_contact_id]) @@ -15,25 +15,11 @@ class Registrar response = do_request(request, uri) - parsed_response = JSON.parse(response.body, symbolize_names: true) + start_notice = t('registrar.tech_contacts.process_request.replaced') - if response.code == '200' - notices = [t('.replaced')] - - notices << "#{t('.affected_domains')}: " \ - "#{parsed_response[:data][:affected_domains].join(', ')}" - - if parsed_response[:data][:skipped_domains] - notices << "#{t('.skipped_domains')}: " \ - "#{parsed_response[:data][:skipped_domains].join(', ')}" - end - - flash[:notice] = notices.join(', ') - redirect_to registrar_domains_url - else - @error = response.code == '404' ? 'Contact(s) not found' : parsed_response[:message] - render file: 'registrar/bulk_change/new', locals: { active_tab: :technical_contact } - end + process_response(response: response, + start_notice: start_notice, + active_tab: ACTIVE_TAB) end end end From 489cd2f7e50da44f7a42f923f71466680be69522 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Fri, 5 Feb 2021 15:59:34 +0500 Subject: [PATCH 112/132] Fix i18n --- .../registrar/bulk_change_controller.rb | 25 +++++++++++-------- .../registrar/tech_contacts_controller.rb | 2 +- config/locales/registrar/bulk_change.en.yml | 3 +++ config/locales/registrar/tech_contacts.en.yml | 4 +++ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/app/controllers/registrar/bulk_change_controller.rb b/app/controllers/registrar/bulk_change_controller.rb index 63d7b6cb1..b11883d6a 100644 --- a/app/controllers/registrar/bulk_change_controller.rb +++ b/app/controllers/registrar/bulk_change_controller.rb @@ -26,19 +26,11 @@ class Registrar private - def process_response(response:, start_notice: "", active_tab:) + def process_response(response:, start_notice: '', active_tab:) parsed_response = JSON.parse(response.body, symbolize_names: true) if response.code == '200' - notices = [start_notice] - - notices << "#{t('registrar.tech_contacts.process_request.affected_domains')}: " \ - "#{parsed_response[:data][:affected_domains].join(', ')}" - - if parsed_response[:data][:skipped_domains] - notices << "#{t('registrar.tech_contacts.process_request.skipped_domains')}: " \ - "#{parsed_response[:data][:skipped_domains].join(', ')}" - end + notices = success_notices(parsed_response, start_notice) flash[:notice] = notices.join(', ') redirect_to registrar_domains_url @@ -48,6 +40,19 @@ class Registrar end end + def success_notices(parsed_response, start_notice) + notices = [start_notice] + + notices << "#{t('.affected_domains')}: " \ + "#{parsed_response[:data][:affected_domains].join(', ')}" + + if parsed_response[:data][:skipped_domains] + notices << "#{t('.skipped_domains')}: " \ + "#{parsed_response[:data][:skipped_domains].join(', ')}" + end + notices + end + def do_request(request, uri) response = if Rails.env.test? do_test_request(request, uri) diff --git a/app/controllers/registrar/tech_contacts_controller.rb b/app/controllers/registrar/tech_contacts_controller.rb index 90dc333f6..3cddb5f36 100644 --- a/app/controllers/registrar/tech_contacts_controller.rb +++ b/app/controllers/registrar/tech_contacts_controller.rb @@ -15,7 +15,7 @@ class Registrar response = do_request(request, uri) - start_notice = t('registrar.tech_contacts.process_request.replaced') + start_notice = t('.replaced') process_response(response: response, start_notice: start_notice, diff --git a/config/locales/registrar/bulk_change.en.yml b/config/locales/registrar/bulk_change.en.yml index 75becfada..58d5fce97 100644 --- a/config/locales/registrar/bulk_change.en.yml +++ b/config/locales/registrar/bulk_change.en.yml @@ -4,6 +4,7 @@ en: new: header: Bulk change technical_contact: Technical contact + admin_contact: Admin contact nameserver: Nameserver bulk_transfer: Bulk transfer bulk_renew: Bulk renew @@ -38,3 +39,5 @@ en: domain_ids: Domains for bulk renewal current_balance: Current balance period: Period + affected_domains: Affected domains + skipped_domains: Skipped domains diff --git a/config/locales/registrar/tech_contacts.en.yml b/config/locales/registrar/tech_contacts.en.yml index bf57f0cc7..b6e5d041b 100644 --- a/config/locales/registrar/tech_contacts.en.yml +++ b/config/locales/registrar/tech_contacts.en.yml @@ -5,3 +5,7 @@ en: replaced: Technical contacts have been successfully replaced. affected_domains: Affected domains skipped_domains: Skipped domains + process_request: + affected_domains: Affected domains + skipped_domains: Skipped domains + replaced: Technical contacts have been successfully replaced. From fca12fdb34f57550daa6b7623383a5720a16e25a Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Fri, 5 Feb 2021 16:51:38 +0500 Subject: [PATCH 113/132] Add a view and routes --- .codeclimate.yml | 6 +- .../registrar/admin_contacts_controller.rb | 19 ++++++ .../registrar/bulk_change_controller.rb | 9 +++ .../registrar/tech_contacts_controller.rb | 8 +-- .../bulk_change/_admin_contact_form.html.erb | 60 +++++++++++++++++++ app/views/registrar/bulk_change/new.html.erb | 9 +++ .../locales/registrar/admin_contacts.en.yml | 6 ++ config/locales/registrar/bulk_change.en.yml | 10 ++++ config/routes.rb | 1 + 9 files changed, 119 insertions(+), 9 deletions(-) create mode 100644 app/controllers/registrar/admin_contacts_controller.rb create mode 100644 app/views/registrar/bulk_change/_admin_contact_form.html.erb create mode 100644 config/locales/registrar/admin_contacts.en.yml diff --git a/.codeclimate.yml b/.codeclimate.yml index 2324522fc..31da9b9cb 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -16,8 +16,10 @@ plugins: enabled: true config: languages: - - ruby - - javascript + ruby: + mass_threshold: 100 + javascript: + mass_threshold: 100 eslint: enabled: true channel: eslint-5 diff --git a/app/controllers/registrar/admin_contacts_controller.rb b/app/controllers/registrar/admin_contacts_controller.rb new file mode 100644 index 000000000..55cfbae9e --- /dev/null +++ b/app/controllers/registrar/admin_contacts_controller.rb @@ -0,0 +1,19 @@ +class Registrar + class AdminContactsController < BulkChangeController + BASE_URL = URI.parse("#{ENV['repp_url']}domains/admin_contacts").freeze + ACTIVE_TAB = :admin_contact + + def update + authorize! :manage, :repp + + uri = BASE_URL + request = form_request(uri) + response = do_request(request, uri) + start_notice = t('.replaced') + + process_response(response: response, + start_notice: start_notice, + active_tab: ACTIVE_TAB) + end + end +end diff --git a/app/controllers/registrar/bulk_change_controller.rb b/app/controllers/registrar/bulk_change_controller.rb index b11883d6a..74bbf89e8 100644 --- a/app/controllers/registrar/bulk_change_controller.rb +++ b/app/controllers/registrar/bulk_change_controller.rb @@ -26,6 +26,15 @@ class Registrar private + def form_request(uri) + request = Net::HTTP::Patch.new(uri) + request.set_form_data(current_contact_id: params[:current_contact_id], + new_contact_id: params[:new_contact_id]) + request.basic_auth(current_registrar_user.username, + current_registrar_user.plain_text_password) + request + end + def process_response(response:, start_notice: '', active_tab:) parsed_response = JSON.parse(response.body, symbolize_names: true) diff --git a/app/controllers/registrar/tech_contacts_controller.rb b/app/controllers/registrar/tech_contacts_controller.rb index 3cddb5f36..cc9238730 100644 --- a/app/controllers/registrar/tech_contacts_controller.rb +++ b/app/controllers/registrar/tech_contacts_controller.rb @@ -7,14 +7,8 @@ class Registrar authorize! :manage, :repp uri = BASE_URL - request = Net::HTTP::Patch.new(uri) - request.set_form_data(current_contact_id: params[:current_contact_id], - new_contact_id: params[:new_contact_id]) - request.basic_auth(current_registrar_user.username, - current_registrar_user.plain_text_password) - + request = form_request(uri) response = do_request(request, uri) - start_notice = t('.replaced') process_response(response: response, diff --git a/app/views/registrar/bulk_change/_admin_contact_form.html.erb b/app/views/registrar/bulk_change/_admin_contact_form.html.erb new file mode 100644 index 000000000..d8b4beb55 --- /dev/null +++ b/app/views/registrar/bulk_change/_admin_contact_form.html.erb @@ -0,0 +1,60 @@ +<%= form_tag registrar_admin_contacts_path, method: :patch, class: 'form-horizontal' do %> + <% if @error %> +
+ <%= @error %> +
+ <% end %> + +
+
+ <%= label_tag :current_contact_id, t('.current_contact_id') %> +
+ +
+ <%= text_field_tag :current_contact_id, params[:current_contact_id], + list: :contacts, + required: true, + autofocus: true, + class: 'form-control' %> +
+
+ +
+
+ <%= label_tag :new_contact_id, t('.new_contact_id') %> +
+ +
+ <%= text_field_tag :new_contact_id, params[:new_contact_id], + list: :contacts, + required: true, + class: 'form-control' %> +
+
+ +
+
+ +
+
+ +
+
+ <%= t '.help_btn' %> +
+
+ <%= t '.help' %> +
+
+
+
+<% end %> + + + <% available_contacts.each do |data| %> + + <% end %> + diff --git a/app/views/registrar/bulk_change/new.html.erb b/app/views/registrar/bulk_change/new.html.erb index e61270b6d..f3095a53d 100644 --- a/app/views/registrar/bulk_change/new.html.erb +++ b/app/views/registrar/bulk_change/new.html.erb @@ -12,6 +12,10 @@ <%= t '.technical_contact' %> +
  • + <%= t '.admin_contact' %> +
  • +
  • <%= t '.nameserver' %>
  • @@ -31,6 +35,11 @@ <%= render 'tech_contact_form', available_contacts: available_contacts %>
    +
    + <%= render 'admin_contact_form', available_contacts: available_contacts %> +
    +
    <%= render 'nameserver_form' %>
    diff --git a/config/locales/registrar/admin_contacts.en.yml b/config/locales/registrar/admin_contacts.en.yml new file mode 100644 index 000000000..9265a6d10 --- /dev/null +++ b/config/locales/registrar/admin_contacts.en.yml @@ -0,0 +1,6 @@ +en: + registrar: + admin_contacts: + update: + replaced: Admin contacts have been successfully replaced. + replaced: Technical contacts have been successfully replaced. diff --git a/config/locales/registrar/bulk_change.en.yml b/config/locales/registrar/bulk_change.en.yml index 58d5fce97..6bd7fd84c 100644 --- a/config/locales/registrar/bulk_change.en.yml +++ b/config/locales/registrar/bulk_change.en.yml @@ -18,6 +18,16 @@ en: Replace technical contact specified in "current contact ID" with the one in "new contact ID" on any domain registered under this registrar + admin_contact_form: + current_contact_id: Current admin contact ID + new_contact_id: New admin contact ID + submit_btn: Replace admin contacts + help_btn: Toggle help + help: >- + Replace admin contact specified in "current contact ID" with the one in "new + contact ID" on any domain registered under this registrar. Contact idents must + be the same + nameserver_form: ip_hint: One IP per line replace_btn: Replace nameserver diff --git a/config/routes.rb b/config/routes.rb index 16102f2b6..2c9590477 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -137,6 +137,7 @@ Rails.application.routes.draw do resource :bulk_change, controller: :bulk_change, only: :new post '/bulk_renew/new', to: 'bulk_change#bulk_renew', as: :bulk_renew resource :tech_contacts, only: :update + resource :admin_contacts, only: :update resource :nameservers, only: :update resources :contacts, constraints: {:id => /[^\/]+(?=#{ ActionController::Renderers::RENDERERS.map{|e| "\\.#{e}\\z"}.join("|") })|[^\/]+/} do member do From e5c41cf531d99137e68abfd3ad463ecfbf646475 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 8 Feb 2021 14:53:54 +0500 Subject: [PATCH 114/132] Fix tests --- .../registrar/bulk_change/_admin_contact_form.html.erb | 4 ++-- .../registrar/bulk_change/_tech_contact_form.html.erb | 4 ++-- .../registrar_area/bulk_change/tech_contact_test.rb | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/registrar/bulk_change/_admin_contact_form.html.erb b/app/views/registrar/bulk_change/_admin_contact_form.html.erb index d8b4beb55..bb682aa60 100644 --- a/app/views/registrar/bulk_change/_admin_contact_form.html.erb +++ b/app/views/registrar/bulk_change/_admin_contact_form.html.erb @@ -10,7 +10,7 @@ <%= label_tag :current_contact_id, t('.current_contact_id') %>
    -
    +
    <%= text_field_tag :current_contact_id, params[:current_contact_id], list: :contacts, required: true, @@ -24,7 +24,7 @@ <%= label_tag :new_contact_id, t('.new_contact_id') %>
    -
    +
    <%= text_field_tag :new_contact_id, params[:new_contact_id], list: :contacts, required: true, diff --git a/app/views/registrar/bulk_change/_tech_contact_form.html.erb b/app/views/registrar/bulk_change/_tech_contact_form.html.erb index 2848e3634..789db92ba 100644 --- a/app/views/registrar/bulk_change/_tech_contact_form.html.erb +++ b/app/views/registrar/bulk_change/_tech_contact_form.html.erb @@ -10,7 +10,7 @@ <%= label_tag :current_contact_id, t('.current_contact_id') %>
    -
    +
    <%= text_field_tag :current_contact_id, params[:current_contact_id], list: :contacts, required: true, @@ -24,7 +24,7 @@ <%= label_tag :new_contact_id, t('.new_contact_id') %>
    -
    +
    <%= text_field_tag :new_contact_id, params[:new_contact_id], list: :contacts, required: true, diff --git a/test/system/registrar_area/bulk_change/tech_contact_test.rb b/test/system/registrar_area/bulk_change/tech_contact_test.rb index e08457f60..055ec25ca 100644 --- a/test/system/registrar_area/bulk_change/tech_contact_test.rb +++ b/test/system/registrar_area/bulk_change/tech_contact_test.rb @@ -16,8 +16,8 @@ class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase visit registrar_domains_url click_link 'Bulk change' - fill_in 'Current contact ID', with: 'william-001' - fill_in 'New contact ID', with: 'john-001' + find('.current_tech_contact').fill_in 'Current contact ID', with: 'william-001' + find('.new_tech_contact').fill_in 'New contact ID', with: 'john-001' click_on 'Replace technical contacts' assert_requested request_stub @@ -36,8 +36,8 @@ class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase visit registrar_domains_url click_link 'Bulk change' - fill_in 'Current contact ID', with: 'william-001' - fill_in 'New contact ID', with: 'john-001' + find('.current_tech_contact').fill_in 'Current contact ID', with: 'william-001' + find('.new_tech_contact').fill_in 'New contact ID', with: 'john-001' click_on 'Replace technical contacts' assert_text 'epic fail' From 9611df92b0f0f1a86cddd05069dd9211144d2941 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 8 Feb 2021 15:35:46 +0500 Subject: [PATCH 115/132] Add system test & fix locale --- .../registrar/admin_contacts_controller.rb | 1 - config/locales/registrar/admin_contacts.yml | 11 +++++ .../bulk_change/admin_contact_test.rb | 49 +++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 config/locales/registrar/admin_contacts.yml create mode 100644 test/system/registrar_area/bulk_change/admin_contact_test.rb diff --git a/app/controllers/registrar/admin_contacts_controller.rb b/app/controllers/registrar/admin_contacts_controller.rb index 55cfbae9e..a1400b6dc 100644 --- a/app/controllers/registrar/admin_contacts_controller.rb +++ b/app/controllers/registrar/admin_contacts_controller.rb @@ -5,7 +5,6 @@ class Registrar def update authorize! :manage, :repp - uri = BASE_URL request = form_request(uri) response = do_request(request, uri) diff --git a/config/locales/registrar/admin_contacts.yml b/config/locales/registrar/admin_contacts.yml new file mode 100644 index 000000000..d258b4275 --- /dev/null +++ b/config/locales/registrar/admin_contacts.yml @@ -0,0 +1,11 @@ +en: + registrar: + admin_contacts: + update: + replaced: Admin contacts have been successfully replaced. + affected_domains: Affected domains + skipped_domains: Skipped domains + process_request: + affected_domains: Affected domains + skipped_domains: Skipped domains + replaced: Admin contacts have been successfully replaced. diff --git a/test/system/registrar_area/bulk_change/admin_contact_test.rb b/test/system/registrar_area/bulk_change/admin_contact_test.rb new file mode 100644 index 000000000..8847812cb --- /dev/null +++ b/test/system/registrar_area/bulk_change/admin_contact_test.rb @@ -0,0 +1,49 @@ +require 'application_system_test_case' + +class RegistrarAreaAdminContactBulkChangeTest < ApplicationSystemTestCase + setup do + sign_in users(:api_bestnames) + end + + def test_replace_domain_contacts_of_current_registrar + request_stub = stub_request(:patch, /domains\/admin_contacts/) + .with(body: { current_contact_id: 'william-001', new_contact_id: 'john-001' }, + basic_auth: ['test_bestnames', 'testtest']) + .to_return(body: { data: { affected_domains: %w[foo.test bar.test], + skipped_domains: %w[baz.test qux.test] } }.to_json, + status: 200) + + visit registrar_domains_url + click_link 'Bulk change' + click_link 'Admin contact' + + find('.current_admin_contact').fill_in 'Current contact ID', with: 'william-001' + find('.new_admin_contact').fill_in 'New contact ID', with: 'john-001' + click_on 'Replace admin contacts' + + assert_requested request_stub + assert_current_path registrar_domains_path + assert_text 'Admin contacts have been successfully replaced' + assert_text 'Affected domains: foo.test, bar.test' + assert_text 'Skipped domains: baz.test, qux.test' + end + + def test_fails_gracefully + stub_request(:patch, /domains\/admin_contacts/) + .to_return(status: 400, + body: { message: 'epic fail' }.to_json, + headers: { 'Content-type' => Mime[:json] }) + + visit registrar_domains_url + click_link 'Bulk change' + click_link 'Admin contact' + + find('.current_admin_contact').fill_in 'Current contact ID', with: 'william-001' + find('.new_admin_contact').fill_in 'New contact ID', with: 'john-001' + click_on 'Replace admin contacts' + + assert_text 'epic fail' + assert_field 'Current contact ID', with: 'william-001' + assert_field 'New contact ID', with: 'john-001' + end +end From 6304ebdbc63605fa152b47966dc64fcab040301a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 8 Feb 2021 16:28:04 +0200 Subject: [PATCH 116/132] Add Amazon SDK gem --- Gemfile | 2 ++ Gemfile.lock | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/Gemfile b/Gemfile index dd879a11b..2d156c829 100644 --- a/Gemfile +++ b/Gemfile @@ -92,3 +92,5 @@ group :test do gem 'webdrivers' gem 'webmock' end + +gem "aws-sdk-ses", "~> 1.37" diff --git a/Gemfile.lock b/Gemfile.lock index 51c880c9e..01408ebd7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -148,6 +148,18 @@ GEM attr_required (1.0.1) autoprefixer-rails (10.0.0.2) execjs + aws-eventstream (1.1.0) + aws-partitions (1.424.0) + aws-sdk-core (3.112.0) + aws-eventstream (~> 1, >= 1.0.2) + aws-partitions (~> 1, >= 1.239.0) + aws-sigv4 (~> 1.1) + jmespath (~> 1.0) + aws-sdk-ses (1.37.0) + aws-sdk-core (~> 3, >= 3.112.0) + aws-sigv4 (~> 1.1) + aws-sigv4 (1.2.2) + aws-eventstream (~> 1, >= 1.0.2) bcrypt (3.1.16) bindata (2.4.8) bootsnap (1.4.8) @@ -226,6 +238,7 @@ GEM i18n_data (0.10.0) isikukood (0.1.2) iso8601 (0.12.1) + jmespath (1.4.0) jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -484,6 +497,7 @@ DEPENDENCIES active_interaction (~> 3.8) activerecord-import airbrake + aws-sdk-ses (~> 1.37) bootsnap (>= 1.1.0) bootstrap-sass (~> 3.4) cancancan From 2af0bfdda04f5427080385507f2faf8a31e7e783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 8 Feb 2021 16:52:31 +0200 Subject: [PATCH 117/132] BouncedMailAddress: Remove from AWS suppression list upon destroy --- Gemfile | 2 +- Gemfile.lock | 4 ++-- app/models/bounced_mail_address.rb | 17 +++++++++++++++++ config/initializers/aws_ses.rb | 4 ++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 config/initializers/aws_ses.rb diff --git a/Gemfile b/Gemfile index 2d156c829..79862bd69 100644 --- a/Gemfile +++ b/Gemfile @@ -93,4 +93,4 @@ group :test do gem 'webmock' end -gem "aws-sdk-ses", "~> 1.37" +gem "aws-sdk-sesv2", "~> 1.16" diff --git a/Gemfile.lock b/Gemfile.lock index 01408ebd7..08daf4226 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -155,7 +155,7 @@ GEM aws-partitions (~> 1, >= 1.239.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-ses (1.37.0) + aws-sdk-sesv2 (1.16.0) aws-sdk-core (~> 3, >= 3.112.0) aws-sigv4 (~> 1.1) aws-sigv4 (1.2.2) @@ -497,7 +497,7 @@ DEPENDENCIES active_interaction (~> 3.8) activerecord-import airbrake - aws-sdk-ses (~> 1.37) + aws-sdk-sesv2 (~> 1.16) bootsnap (>= 1.1.0) bootstrap-sass (~> 3.4) cancancan diff --git a/app/models/bounced_mail_address.rb b/app/models/bounced_mail_address.rb index 73c6a0941..d0411a6c9 100644 --- a/app/models/bounced_mail_address.rb +++ b/app/models/bounced_mail_address.rb @@ -1,5 +1,6 @@ class BouncedMailAddress < ApplicationRecord validates :email, :message_id, :bounce_type, :bounce_subtype, :action, :status, presence: true + after_destroy :destroy_aws_suppression def bounce_reason "#{action} (#{status} #{diagnostic})" @@ -25,4 +26,20 @@ class BouncedMailAddress < ApplicationRecord diagnostic: bounced_record['diagnosticCode'], } end + + def destroy_aws_suppression + return unless BouncedMailAddress.ses_configured? + + res = Aws::SESV2::Client.new.delete_suppressed_destination({ email_address: email }) + res.successful? + rescue Aws::SESV2::Errors::ServiceError => e + logger.warn("Suppression not removed. #{e}") + end + + def self.ses_configured? + ses ||= Aws::SES::Client.new + ses.config.credentials.access_key_id.present? + rescue Aws::Errors::MissingRegionError + false + end end diff --git a/config/initializers/aws_ses.rb b/config/initializers/aws_ses.rb new file mode 100644 index 000000000..baa148e65 --- /dev/null +++ b/config/initializers/aws_ses.rb @@ -0,0 +1,4 @@ +Aws.config.update( + region: ENV['aws_default_region'], + credentials: Aws::Credentials.new(ENV['aws_access_key_id'], ENV['aws_secret_access_key']) +) From f6fd10b01767bb3aa0421200ef9901ad0d387042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 8 Feb 2021 16:57:16 +0200 Subject: [PATCH 118/132] Fix CC issues --- Gemfile | 2 +- app/models/bounced_mail_address.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 79862bd69..82a0b4666 100644 --- a/Gemfile +++ b/Gemfile @@ -93,4 +93,4 @@ group :test do gem 'webmock' end -gem "aws-sdk-sesv2", "~> 1.16" +gem 'aws-sdk-sesv2', '~> 1.16' diff --git a/app/models/bounced_mail_address.rb b/app/models/bounced_mail_address.rb index d0411a6c9..db4413829 100644 --- a/app/models/bounced_mail_address.rb +++ b/app/models/bounced_mail_address.rb @@ -30,14 +30,14 @@ class BouncedMailAddress < ApplicationRecord def destroy_aws_suppression return unless BouncedMailAddress.ses_configured? - res = Aws::SESV2::Client.new.delete_suppressed_destination({ email_address: email }) + res = Aws::SESV2::Client.new.delete_suppressed_destination(email_address: email) res.successful? rescue Aws::SESV2::Errors::ServiceError => e logger.warn("Suppression not removed. #{e}") end def self.ses_configured? - ses ||= Aws::SES::Client.new + ses ||= Aws::SESV2::Client.new ses.config.credentials.access_key_id.present? rescue Aws::Errors::MissingRegionError false From c7b40450184f959472bd25bc1017a593eb1e7ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Tue, 9 Feb 2021 11:46:47 +0200 Subject: [PATCH 119/132] Contact: Append prefix unless present --- app/controllers/epp/contacts_controller.rb | 6 +++++- test/integration/epp/contact/info/base_test.rb | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/epp/contacts_controller.rb b/app/controllers/epp/contacts_controller.rb index 85305213b..a0c3f503f 100644 --- a/app/controllers/epp/contacts_controller.rb +++ b/app/controllers/epp/contacts_controller.rb @@ -93,7 +93,11 @@ module Epp def find_contact code = params[:parsed_frame].css('id').text.strip.upcase - @contact = Epp::Contact.find_by!(code: code) + reg_code = current_user.registrar.code.upcase + arr = [code, "#{reg_code}:#{code}", "CID:#{code}", "CID:#{reg_code}:#{code}"] + + contact = arr.find { |c| Epp::Contact.find_by(code: c).present? } + @contact = Epp::Contact.find_by!(code: contact || code) end # diff --git a/test/integration/epp/contact/info/base_test.rb b/test/integration/epp/contact/info/base_test.rb index 4b4cb017f..3edb6d461 100644 --- a/test/integration/epp/contact/info/base_test.rb +++ b/test/integration/epp/contact/info/base_test.rb @@ -71,8 +71,8 @@ class EppContactInfoBaseTest < EppTestCase end def test_get_info_about_contact_without_prefix - @contact.update_columns(code: 'TEST:JOHN-001') - assert @contact.code, 'TEST:JOHN-001' + @contact.update_columns(code: "#{@contact.registrar.code}:JOHN-001".upcase) + assert @contact.code, "#{@contact.registrar.code}:JOHN-001".upcase request_xml = <<-XML @@ -92,7 +92,7 @@ class EppContactInfoBaseTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_epp_response :completed_successfully - assert_equal 'TEST:JOHN-001', response_xml.at_xpath('//contact:id', contact: xml_schema).text + assert_equal "#{@contact.registrar.code}:JOHN-001".upcase, response_xml.at_xpath('//contact:id', contact: xml_schema).text assert_equal '+555.555', response_xml.at_xpath('//contact:voice', contact: xml_schema).text end From b892927f11c98b961cae8d33ee3daa605a966600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Tue, 9 Feb 2021 16:12:57 +0200 Subject: [PATCH 120/132] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 064905ba7..891059845 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +09.02.2021 +* Added new endpoint for WHOIS contact requests [#1794](https://github.com/internetee/registry/pull/1794) + 05.02.2021 * Fixed IPv4 empty string issue in case of IPv6 only entries for IP whitelist [#1833](https://github.com/internetee/registry/issues/1833) From aefb7e42aea9611db582d9f892cb574f46c1d31a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Tue, 9 Feb 2021 16:27:15 +0200 Subject: [PATCH 121/132] Registry lock: Notify Registrar by EPP notification --- app/models/concerns/domain/registry_lockable.rb | 12 ++++++++++++ config/locales/notifications.en.yml | 2 ++ test/jobs/domain_update_confirm_job_test.rb | 6 +++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/domain/registry_lockable.rb b/app/models/concerns/domain/registry_lockable.rb index 4a759296d..4190722f3 100644 --- a/app/models/concerns/domain/registry_lockable.rb +++ b/app/models/concerns/domain/registry_lockable.rb @@ -12,6 +12,7 @@ module Concerns statuses << DomainStatus::SERVER_DELETE_PROHIBITED statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED self.locked_by_registrant_at = Time.zone.now + alert_registrar_lock_changes! save! end @@ -42,10 +43,21 @@ module Concerns statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED) statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED) self.locked_by_registrant_at = nil + alert_registrar_lock_changes! save! end end + + def alert_registrar_lock_changes! + translation = locked_by_registrant? ? 'locked' : 'unlocked' + registrar.notifications.create!( + text: I18n.t("notifications.texts.registrar_#{translation}", + domain_name: domain.name), + attached_obj_id: name, + attached_obj_type: self.class.name + ) + end end end end diff --git a/config/locales/notifications.en.yml b/config/locales/notifications.en.yml index 1dff4a97c..d67fb5a5b 100644 --- a/config/locales/notifications.en.yml +++ b/config/locales/notifications.en.yml @@ -6,3 +6,5 @@ en: It was associated with registrant %{old_registrant_code} and contacts %{old_contacts_codes}. contact_update: Contact %{contact} has been updated by registrant + registrar_locked: Domain %{domain_name} has been locked by registrant + registrar_unlocked: Domain %{domain_name} has been unlocked by registrant diff --git a/test/jobs/domain_update_confirm_job_test.rb b/test/jobs/domain_update_confirm_job_test.rb index 51c42aa4f..dc6e14bf9 100644 --- a/test/jobs/domain_update_confirm_job_test.rb +++ b/test/jobs/domain_update_confirm_job_test.rb @@ -18,11 +18,11 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase super end - def test_registrant_locked_domain + def test_registrant_locked_domain refute @domain.locked_by_registrant? @domain.apply_registry_lock assert @domain.locked_by_registrant? - assert_equal(@domain.registrar.notifications.last.text, 'Domain has been locked by registrant') + assert_equal(@domain.registrar.notifications.last.text, "Domain #{@domain.name} has been unlocked by registrant") end def test_registrant_unlocked_domain @@ -31,7 +31,7 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase assert @domain.locked_by_registrant? @domain.remove_registry_lock refute @domain.locked_by_registrant? - assert_equal(@domain.registrar.notifications.last.text, 'Domain has been unlocked by registrant') + assert_equal(@domain.registrar.notifications.last.text, "Domain #{@domain.name} has been unlocked by registrant") end def test_rejected_registrant_verification_notifies_registrar From 66dfa730ec1c8f3a00d94c51b37d3088f71a5ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Tue, 9 Feb 2021 16:27:15 +0200 Subject: [PATCH 122/132] Registry lock: Notify Registrar by EPP notification --- app/models/concerns/domain/registry_lockable.rb | 12 ++++++++++++ config/locales/notifications.en.yml | 2 ++ test/jobs/domain_update_confirm_job_test.rb | 6 +++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/domain/registry_lockable.rb b/app/models/concerns/domain/registry_lockable.rb index 4a759296d..ccb0f305e 100644 --- a/app/models/concerns/domain/registry_lockable.rb +++ b/app/models/concerns/domain/registry_lockable.rb @@ -12,6 +12,7 @@ module Concerns statuses << DomainStatus::SERVER_DELETE_PROHIBITED statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED self.locked_by_registrant_at = Time.zone.now + alert_registrar_lock_changes! save! end @@ -42,10 +43,21 @@ module Concerns statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED) statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED) self.locked_by_registrant_at = nil + alert_registrar_lock_changes! save! end end + + def alert_registrar_lock_changes! + translation = locked_by_registrant? ? 'locked' : 'unlocked' + registrar.notifications.create!( + text: I18n.t("notifications.texts.registrar_#{translation}", + domain_name: name), + attached_obj_id: name, + attached_obj_type: self.class.name + ) + end end end end diff --git a/config/locales/notifications.en.yml b/config/locales/notifications.en.yml index 1dff4a97c..d67fb5a5b 100644 --- a/config/locales/notifications.en.yml +++ b/config/locales/notifications.en.yml @@ -6,3 +6,5 @@ en: It was associated with registrant %{old_registrant_code} and contacts %{old_contacts_codes}. contact_update: Contact %{contact} has been updated by registrant + registrar_locked: Domain %{domain_name} has been locked by registrant + registrar_unlocked: Domain %{domain_name} has been unlocked by registrant diff --git a/test/jobs/domain_update_confirm_job_test.rb b/test/jobs/domain_update_confirm_job_test.rb index 51c42aa4f..dc6e14bf9 100644 --- a/test/jobs/domain_update_confirm_job_test.rb +++ b/test/jobs/domain_update_confirm_job_test.rb @@ -18,11 +18,11 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase super end - def test_registrant_locked_domain + def test_registrant_locked_domain refute @domain.locked_by_registrant? @domain.apply_registry_lock assert @domain.locked_by_registrant? - assert_equal(@domain.registrar.notifications.last.text, 'Domain has been locked by registrant') + assert_equal(@domain.registrar.notifications.last.text, "Domain #{@domain.name} has been unlocked by registrant") end def test_registrant_unlocked_domain @@ -31,7 +31,7 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase assert @domain.locked_by_registrant? @domain.remove_registry_lock refute @domain.locked_by_registrant? - assert_equal(@domain.registrar.notifications.last.text, 'Domain has been unlocked by registrant') + assert_equal(@domain.registrar.notifications.last.text, "Domain #{@domain.name} has been unlocked by registrant") end def test_rejected_registrant_verification_notifies_registrar From 43ff03e6e147c65620363d8c6356f15879c1f4fd Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Wed, 10 Feb 2021 10:42:59 +0200 Subject: [PATCH 123/132] added test for check --- .../epp/contact/check/base_test.rb | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/test/integration/epp/contact/check/base_test.rb b/test/integration/epp/contact/check/base_test.rb index 528d69d86..3fc9f64ac 100644 --- a/test/integration/epp/contact/check/base_test.rb +++ b/test/integration/epp/contact/check/base_test.rb @@ -98,6 +98,58 @@ class EppContactCheckBaseTest < EppTestCase assert_equal 3, response_xml.xpath('//contact:cd', contact: xml_schema).size end + def test_check_contact_with_prefix + @contact.update_columns(code: 'TEST:JOHN-001') + assert @contact.code, 'TEST:JOHN-001' + + request_xml = <<-XML + + + + + + TEST:JOHN-001 + + + + + XML + + post epp_check_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + + response_xml = Nokogiri::XML(response.body) + assert_epp_response :completed_successfully + assert_equal 'TEST:JOHN-001', response_xml.at_xpath('//contact:id', contact: xml_schema).text + assert_equal 'in use', response_xml.at_xpath('//contact:reason', contact: xml_schema).text + end + + def test_check_contact_without_prefix + @contact.update_columns(code: "#{@contact.registrar.code}:JOHN-001".upcase) + assert @contact.code, "#{@contact.registrar.code}:JOHN-001".upcase + + request_xml = <<-XML + + + + + + JOHN-001 + + + + + XML + + post epp_check_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + + response_xml = Nokogiri::XML(response.body) + assert_epp_response :completed_successfully + assert_equal 'TEST:JOHN-001', response_xml.at_xpath('//contact:id', contact: xml_schema).text + assert_equal 'in use', response_xml.at_xpath('//contact:reason', contact: xml_schema).text + end + private def xml_schema From 0617ef9d7d3e82b3785fcf0520a4149a165a51e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Wed, 10 Feb 2021 12:03:22 +0200 Subject: [PATCH 124/132] Fix contact code check --- app/controllers/epp/contacts_controller.rb | 2 +- app/models/epp/contact.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/epp/contacts_controller.rb b/app/controllers/epp/contacts_controller.rb index a0c3f503f..65354ff48 100644 --- a/app/controllers/epp/contacts_controller.rb +++ b/app/controllers/epp/contacts_controller.rb @@ -14,7 +14,7 @@ module Epp authorize! :check, Epp::Contact ids = params[:parsed_frame].css('id').map(&:text) - @results = Epp::Contact.check_availability(ids) + @results = Epp::Contact.check_availability(ids, reg: current_user.registrar.code) render_epp_response '/epp/contacts/check' end diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 50ebac065..edc828f81 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -42,8 +42,9 @@ class Epp::Contact < Contact ) end - def check_availability(codes) + def check_availability(codes, reg:) codes = [codes] if codes.is_a?(String) + codes = codes.map { |c| c.include?(':') ? c : "#{reg}:#{c}" } res = [] codes.each do |x| From 1b6c4516564343679715fc852aecb7db4987739b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Wed, 10 Feb 2021 12:17:32 +0200 Subject: [PATCH 125/132] Create separate key for Bounces API --- app/controllers/api/v1/base_controller.rb | 2 +- app/controllers/api/v1/bounces_controller.rb | 9 ++++++++- config/application.yml.sample | 6 +++--- test/integration/api/v1/bounces/create_test.rb | 2 +- test/integration/api/v1/contact_requests_test.rb | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb index 045e4395e..6ee986a48 100644 --- a/app/controllers/api/v1/base_controller.rb +++ b/app/controllers/api/v1/base_controller.rb @@ -11,7 +11,7 @@ module Api end def authenticate_shared_key - api_key = "Basic #{ENV['internal_api_key']}" + api_key = "Basic #{ENV['rwhois_internal_api_shared_key']}" head(:unauthorized) unless api_key == request.authorization end diff --git a/app/controllers/api/v1/bounces_controller.rb b/app/controllers/api/v1/bounces_controller.rb index fd10a3398..de2814250 100644 --- a/app/controllers/api/v1/bounces_controller.rb +++ b/app/controllers/api/v1/bounces_controller.rb @@ -1,7 +1,7 @@ module Api module V1 class BouncesController < BaseController - before_action :authenticate_shared_key + before_action :validate_shared_key_integrity # POST api/v1/bounces/ def create @@ -20,6 +20,13 @@ module Api params.require(:data) end + + private + + def validate_shared_key_integrity + api_key = "Basic #{ENV['rwhois_bounces_api_shared_key']}" + head(:unauthorized) unless api_key == request.authorization + end end end end diff --git a/config/application.yml.sample b/config/application.yml.sample index 21f1df8e0..dd38e206c 100644 --- a/config/application.yml.sample +++ b/config/application.yml.sample @@ -87,11 +87,11 @@ sk_digi_doc_service_name: 'Testimine' registrant_api_base_url: registrant_api_auth_allowed_ips: '127.0.0.1, 0.0.0.0' #ips, separated with commas -# Bounces API -api_shared_key: testkey +# Shared key for REST-WHOIS Bounces API incl. CERT +rwhois_bounces_api_shared_key: testkey # Link to REST-WHOIS API -internal_api_key: testkey +rwhois_internal_api_shared_key: testkey # Base URL (inc. https://) of REST registrant portal # Leave blank to use internal registrant portal diff --git a/test/integration/api/v1/bounces/create_test.rb b/test/integration/api/v1/bounces/create_test.rb index 899b6c5c7..0d3dc65d7 100644 --- a/test/integration/api/v1/bounces/create_test.rb +++ b/test/integration/api/v1/bounces/create_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class BouncesApiV1CreateTest < ActionDispatch::IntegrationTest def setup - @api_key = "Basic #{ENV['api_shared_key']}" + @api_key = "Basic #{ENV['rwhois_bounces_api_shared_key']}" @headers = { "Authorization": "#{@api_key}" } @json_body = { "data": valid_bounce_request }.as_json end diff --git a/test/integration/api/v1/contact_requests_test.rb b/test/integration/api/v1/contact_requests_test.rb index f0621b686..c9e2ac9bd 100644 --- a/test/integration/api/v1/contact_requests_test.rb +++ b/test/integration/api/v1/contact_requests_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class ApiV1ContactRequestTest < ActionDispatch::IntegrationTest def setup - @api_key = "Basic #{ENV['api_shared_key']}" + @api_key = "Basic #{ENV['rwhois_internal_api_shared_key']}" @headers = { "Authorization": "#{@api_key}" } @json_create = { "contact_request": valid_contact_request_create }.as_json @json_update = { "contact_request": valid_contact_request_update }.as_json From 476093f3ce0a8741354160980a6189f376189146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Wed, 10 Feb 2021 14:14:23 +0200 Subject: [PATCH 126/132] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 891059845..6e53f4714 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +10.02.2021 +* Option to remove email addresses from AWS SES Supression list [#1839](https://github.com/internetee/registry/issues/1839) +* Added separate key for bounce API [#1842](https://github.com/internetee/registry/pull/1842) + 09.02.2021 * Added new endpoint for WHOIS contact requests [#1794](https://github.com/internetee/registry/pull/1794) From 7638bff5466fd74f5fc80f48493c82fc96b67230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Wed, 10 Feb 2021 16:36:57 +0200 Subject: [PATCH 127/132] Add registry lock operation to epp notification --- app/models/notification.rb | 4 ++++ app/views/epp/poll/poll_req.xml.builder | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/models/notification.rb b/app/models/notification.rb index e83b2c9da..07e824367 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -25,6 +25,10 @@ class Notification < ApplicationRecord '' end + def registry_lock? + text.include?('has been locked') || text.include?('has been unlocked') + end + private def set_defaults diff --git a/app/views/epp/poll/poll_req.xml.builder b/app/views/epp/poll/poll_req.xml.builder index 664327dae..a58b082c5 100644 --- a/app/views/epp/poll/poll_req.xml.builder +++ b/app/views/epp/poll/poll_req.xml.builder @@ -15,12 +15,22 @@ xml.epp_head do end if @object end - if @notification.action&.contact - render(partial: 'epp/poll/action', - locals: { - builder: xml, - action: @notification.action - }) + if @notification.action&.contact || @notification.registry_lock? + if @notification.registry_lock? + state = @notification.text.include?('unlocked') ? 'unlock' : 'lock' + xml.extension do + xml.tag!('changePoll:changeData', + 'xmlns:changePoll': 'https://epp.tld.ee/schema/changePoll-1.0.xsd') do + xml.tag!('changePoll:operation', state) + end + end + else + render(partial: 'epp/poll/action', + locals: { + builder: xml, + action: @notification.action, + }) + end end render('epp/shared/trID', builder: xml) From 4051c1941b4e861bee9a406829243aba70b7c7cf Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 10 Feb 2021 19:57:39 +0500 Subject: [PATCH 128/132] Add a commenting message to UI form --- app/views/registrar/bulk_change/_admin_contact_form.html.erb | 5 +++++ config/locales/registrar/bulk_change.en.yml | 3 +++ 2 files changed, 8 insertions(+) diff --git a/app/views/registrar/bulk_change/_admin_contact_form.html.erb b/app/views/registrar/bulk_change/_admin_contact_form.html.erb index bb682aa60..77734e872 100644 --- a/app/views/registrar/bulk_change/_admin_contact_form.html.erb +++ b/app/views/registrar/bulk_change/_admin_contact_form.html.erb @@ -6,6 +6,11 @@ <% end %>
    +
    +
    +

    <%= t '.comment' %>

    +
    +
    <%= label_tag :current_contact_id, t('.current_contact_id') %>
    diff --git a/config/locales/registrar/bulk_change.en.yml b/config/locales/registrar/bulk_change.en.yml index 6bd7fd84c..d9f6ebbd2 100644 --- a/config/locales/registrar/bulk_change.en.yml +++ b/config/locales/registrar/bulk_change.en.yml @@ -27,6 +27,9 @@ en: Replace admin contact specified in "current contact ID" with the one in "new contact ID" on any domain registered under this registrar. Contact idents must be the same + comment: >- + Bulk admin change is only allowed in case of old and new contact are sharing identical + ident data ie for updating contact information. nameserver_form: ip_hint: One IP per line From 7063aa1210cd488ee99c38da2a4e2d78f2e0486e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Wed, 10 Feb 2021 17:04:08 +0200 Subject: [PATCH 129/132] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e53f4714..7f6065826 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ 10.02.2021 +* Admin contact bulk change option for registrars [#1764](https://github.com/internetee/registry/issues/1764) * Option to remove email addresses from AWS SES Supression list [#1839](https://github.com/internetee/registry/issues/1839) * Added separate key for bounce API [#1842](https://github.com/internetee/registry/pull/1842) From b2e489630d9effe967a8ebb88d5bd0ab556c2015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Thu, 11 Feb 2021 13:15:47 +0200 Subject: [PATCH 130/132] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f6065826..b935ae6e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +11.02.2021 +* Poll messages on locking and unlocking a domain [#1828](https://github.com/internetee/registry/issues/1828) + 10.02.2021 * Admin contact bulk change option for registrars [#1764](https://github.com/internetee/registry/issues/1764) * Option to remove email addresses from AWS SES Supression list [#1839](https://github.com/internetee/registry/issues/1839) From 8dfe1c83e6da53d7fe1d8577120ad2ad188ea4a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Thu, 11 Feb 2021 14:06:51 +0200 Subject: [PATCH 131/132] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b935ae6e4..9afedbf17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ 11.02.2021 * Poll messages on locking and unlocking a domain [#1828](https://github.com/internetee/registry/issues/1828) +* Registrar's prefix is now checked and added to contact id for info and check requests [#1832](https://github.com/internetee/registry/issues/1832) 10.02.2021 * Admin contact bulk change option for registrars [#1764](https://github.com/internetee/registry/issues/1764) From ac726a955495d917abe13b61a0b067260e0d657a Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Thu, 11 Feb 2021 19:58:02 +0500 Subject: [PATCH 132/132] Add admin_contact bulk update endpoint documentation --- doc/repp/v1/admin_contacts.md | 30 ++++++++++++++++++++++++++++++ doc/repp/v1/domain_contacts.md | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 doc/repp/v1/admin_contacts.md diff --git a/doc/repp/v1/admin_contacts.md b/doc/repp/v1/admin_contacts.md new file mode 100644 index 000000000..3b78829d0 --- /dev/null +++ b/doc/repp/v1/admin_contacts.md @@ -0,0 +1,30 @@ +# Admin domain contacts + +## PATCH https://repp.internet.ee/v1/domains/admin_contacts +Replaces admin domain contacts of the current registrar. + +### Example request +``` +PATCH /repp/v1/domains/admin_contacts HTTP/1.1 +Accept: application/json +Content-Type: application/json +Authorization: Basic dGVzdDp0ZXN0dGVzdA== + +{ + "current_contact_id": "ATSAA:749AA80F", + "new_contact_id": "ATSAA:E36957D7" +} +``` +### Example response +``` +{ + "code": 1000, + "message": "Command completed successfully", + "data": { + "affected_domains": [ + "private.ee", + ], + "skipped_domains": [] + } +} +``` diff --git a/doc/repp/v1/domain_contacts.md b/doc/repp/v1/domain_contacts.md index 2e542bf81..8c3c9b9de 100644 --- a/doc/repp/v1/domain_contacts.md +++ b/doc/repp/v1/domain_contacts.md @@ -1,7 +1,7 @@ -# Domain contacts +# Tech domain contacts ## PATCH https://repp.internet.ee/v1/domains/contacts -Replaces all domain contacts of the current registrar. +Replaces technical domain contacts of the current registrar. ### Example request ```