From 78d473f3e660e89c6635f635f345e7f1bddb6bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Thu, 30 Jul 2020 13:10:13 +0300 Subject: [PATCH 01/30] Create tests for jobs triggered by registrant confirmations --- config/application.yml.sample | 1 + test/fixtures/files/legaldoc.pdf | Bin 0 -> 7613 bytes test/jobs/domain_delete_confirm_job_test.rb | 62 +++++++++++++++++--- test/jobs/domain_update_confirm_job_test.rb | 31 ++++++++++ 4 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 test/fixtures/files/legaldoc.pdf diff --git a/config/application.yml.sample b/config/application.yml.sample index 691740b2a..8f71d75d8 100644 --- a/config/application.yml.sample +++ b/config/application.yml.sample @@ -166,6 +166,7 @@ test: lhv_keystore: 'test/fixtures/files/keystore.jks' lhv_keystore_password: 'testtest' lhv_keystore_alias: 'testtest' + legal_documents_dir: 'test/fixtures/files' # Airbrake // Errbit: airbrake_host: "https://your-errbit-host.ee" diff --git a/test/fixtures/files/legaldoc.pdf b/test/fixtures/files/legaldoc.pdf new file mode 100644 index 0000000000000000000000000000000000000000..1ddf7a0e8cd4188cf5af1650ae4745eecf5d1d61 GIT binary patch literal 7613 zcmaiZc|6oz`+t$8LAEH_##+{yF)Jqf64|n4XE4TC2D3zDDP)%=5h4^JiDWC1J+f!1 zEFpxfE%y9odhX}B@B4Q@-`Deby=Kli*XLT^=epkK^T%~0Otf_5Ao4JPM9YJgmo3#T zxc~(q80h2d0YIZc23P`)><)xdC8i)9ycZcu1nGET$XG3`i;pW-MFl`26R{X?KtQ(K z8yP^D2?s;JN@?x;^_K-}XQS2oXY$O@#Ot~J$1aNmQTVo`N!Py# z&rCi<9^WXvoqzEu!`vg2=IT3LvGDWsV%#KL6su&aLBP?OggOp!Rx7p&oxd{)Lob^XW`yQ$W?{+PIZGOaEJjaR!%YB4o-gT>;ZlIJ&byM^g<8B8k?9(k3 zYvwcOdN-6BUS}{KItm|LJ-E89+&~X#>Yn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kPEhDa;3 z0p^c63IMu{cO|=%Y!Ose{I8$=zpDKw2Z1z-ngT%PJ{AN#?Q#T2EBW6z00I9AUx!M% zf4qnM9T_lDxcLAfw1QL5pq>`c7Kqk>Dk62j zFc=gHr6wJv1A|h_se@9~)YMRisB42&0RLNs##}8Q7fpApizkWV4Fth8sj#S(K_b;* r8tN!GN)xH2rKo|>M8FW*5Df^8ej3^A*-$ie literal 0 HcmV?d00001 diff --git a/test/jobs/domain_delete_confirm_job_test.rb b/test/jobs/domain_delete_confirm_job_test.rb index 51af58c24..b999bd3c7 100644 --- a/test/jobs/domain_delete_confirm_job_test.rb +++ b/test/jobs/domain_delete_confirm_job_test.rb @@ -1,17 +1,11 @@ require "test_helper" class DomainDeleteConfirmJobTest < ActiveSupport::TestCase - def setup - super - + setup do + @legal_doc_path = 'test/fixtures/files/legaldoc.pdf' @domain = domains(:shop) @new_registrant = contacts(:william) @user = users(:api_bestnames) - - @domain.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 }) end def teardown @@ -19,6 +13,11 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase end def test_rejected_registrant_verification_notifies_registrar + @domain.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 }) + DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED) last_registrar_notification = @domain.registrar.notifications.last @@ -27,10 +26,57 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase end def test_accepted_registrant_verification_notifies_registrar + @domain.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 }) + DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED) last_registrar_notification = @domain.registrar.notifications.last assert_equal(last_registrar_notification.attached_obj_id, @domain.id) assert_equal(last_registrar_notification.text, 'Registrant confirmed domain deletion: shop.test') end + + def test_marks_domain_as_pending_delete_after_acceptance + epp_xml = "\n\n \n \n" \ + " \n #{@domain.name}\n \n \n \n" \ + " \n #{@legal_doc_path}\n" \ + " \n \n 20alla-1594212240\n \n\n" + + @domain.registrant_verification_asked!(epp_xml, @user.id) + @domain.pending_delete! + @domain.reload + + assert @domain.registrant_delete_confirmable?(@domain.registrant_verification_token) + assert_equal @user.id, @domain.pending_json['current_user_id'] + + DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED) + @domain.reload + + assert @domain.statuses.include? DomainStatus::PENDING_DELETE + assert @domain.statuses.include? DomainStatus::SERVER_HOLD + assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE_CONFIRMATION + end + + def test_clears_pending_flags_after_delete_denial + epp_xml = "\n\n \n \n" \ + " \n #{@domain.name}\n \n \n \n" \ + " \n #{@legal_doc_path}\n" \ + " \n \n 20alla-1594212240\n \n\n" + + @domain.registrant_verification_asked!(epp_xml, @user.id) + @domain.pending_delete! + @domain.reload + + assert @domain.registrant_delete_confirmable?(@domain.registrant_verification_token) + assert_equal @user.id, @domain.pending_json['current_user_id'] + + DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED) + @domain.reload + + assert_equal ['ok'], @domain.statuses + assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE_CONFIRMATION + assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE + end end diff --git a/test/jobs/domain_update_confirm_job_test.rb b/test/jobs/domain_update_confirm_job_test.rb index 070b5d5f7..59bbf758d 100644 --- a/test/jobs/domain_update_confirm_job_test.rb +++ b/test/jobs/domain_update_confirm_job_test.rb @@ -7,6 +7,7 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase @domain = domains(:shop) @new_registrant = contacts(:william) @user = users(:api_bestnames) + @legal_doc_path = 'test/fixtures/files/legaldoc.pdf' @domain.update!(pending_json: { new_registrant_id: @new_registrant.id, new_registrant_name: @new_registrant.name, @@ -33,4 +34,34 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase assert_equal(last_registrar_notification.attached_obj_id, @domain.id) assert_equal(last_registrar_notification.text, 'Registrant confirmed domain update: shop.test') end + + def test_changes_domain_registrant_after_approval + epp_xml = "\n\n \n \n \n #{@domain.name}\n" \ + " \n #{@new_registrant.code}\n \n \n \n \n \n" \ + " \n #{@legal_doc_path}\n \n" \ + " \n 20alla-1594199756\n \n\n" + @domain.pending_json['frame'] = epp_xml + @domain.update(pending_json: @domain.pending_json) + + @domain.reload + DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED) + @domain.reload + + assert_equal @domain.registrant.code, @new_registrant.code + end + + def test_clears_pending_update_after_denial + epp_xml = "\n\n \n \n \n #{@domain.name}\n" \ + " \n #{@new_registrant.code}\n \n \n \n \n \n" \ + " \n #{@legal_doc_path}\n \n" \ + " \n 20alla-1594199756\n \n\n" + @domain.pending_json['frame'] = epp_xml + @domain.update(pending_json: @domain.pending_json) + + DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED) + @domain.reload + + assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE_CONFIRMATION + assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE + end end From 310e0adac81897d9289d63024699780078d73f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Thu, 30 Jul 2020 16:35:52 +0300 Subject: [PATCH 02/30] Pass whole Customer object to Directo --- app/models/concerns/invoice/book_keeping.rb | 10 +++++++++- app/models/concerns/registrar/book_keeping.rb | 10 +++++++++- test/jobs/directo_invoice_forward_job_test.rb | 9 +++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/invoice/book_keeping.rb b/app/models/concerns/invoice/book_keeping.rb index 2469f45eb..82e6506c9 100644 --- a/app/models/concerns/invoice/book_keeping.rb +++ b/app/models/concerns/invoice/book_keeping.rb @@ -5,7 +5,7 @@ module Concerns def as_directo_json invoice = ActiveSupport::JSON.decode(ActiveSupport::JSON.encode(self)) - invoice['customer_code'] = buyer.accounting_customer_code + invoice['customer'] = compose_directo_customer invoice['issue_date'] = issue_date.strftime('%Y-%m-%d') invoice['transaction_date'] = account_activity .bank_transaction&.paid_at&.strftime('%Y-%m-%d') @@ -21,6 +21,14 @@ module Concerns subtotal, precision: 2, separator: '.' ) }].as_json end + + def compose_directo_customer + { + 'code': buyer.accounting_customer_code, + 'destination': buyer_country_code, + 'vat_reg_no': buyer_vat_no, + }.as_json + end end end end diff --git a/app/models/concerns/registrar/book_keeping.rb b/app/models/concerns/registrar/book_keeping.rb index 27645d2cb..60b9c2b1a 100644 --- a/app/models/concerns/registrar/book_keeping.rb +++ b/app/models/concerns/registrar/book_keeping.rb @@ -12,7 +12,7 @@ module Concerns invoice = { 'number': 1, - 'customer_code': accounting_customer_code, + 'customer': compose_directo_customer, 'language': language == 'en' ? 'ENG' : '', 'currency': activities.first.currency, 'date': month.end_of_month.strftime('%Y-%m-%d') }.as_json @@ -109,6 +109,14 @@ module Concerns } end + def compose_directo_customer + { + 'code': accounting_customer_code, + 'destination': address_country_code, + 'vat_reg_no': vat_no, + }.as_json + end + def load_price(account_activity) @pricelists ||= {} return @pricelists[account_activity.price_id] if @pricelists.key? account_activity.price_id diff --git a/test/jobs/directo_invoice_forward_job_test.rb b/test/jobs/directo_invoice_forward_job_test.rb index 8a4fb43aa..57b1759ff 100644 --- a/test/jobs/directo_invoice_forward_job_test.rb +++ b/test/jobs/directo_invoice_forward_job_test.rb @@ -14,6 +14,15 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase Setting.directo_monthly_number_last = 309901 end + def test_directo_json_sends_customer_as_hash + @invoice.update!(buyer_country_code: @user.address_country_code) + + json_output = @invoice.as_directo_json + assert json_output['customer'].is_a? Hash + assert_equal @user.accounting_customer_code, json_output['customer']['code'] + assert_equal @user.address_country_code, json_output['customer']['destination'] + end + def test_xml_is_include_transaction_date @invoice.update(total: @invoice.account_activity.bank_transaction.sum) @invoice.account_activity.bank_transaction.update(paid_at: Time.zone.now) From 59a6251510084360159d27dfeb767409036e33ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 3 Aug 2020 13:00:48 +0300 Subject: [PATCH 03/30] Call valid Job when confirming domain delete action --- .../registrant/domain_delete_confirms_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/registrant/domain_delete_confirms_controller.rb b/app/controllers/registrant/domain_delete_confirms_controller.rb index ba5dd2ba7..337ca2403 100644 --- a/app/controllers/registrant/domain_delete_confirms_controller.rb +++ b/app/controllers/registrant/domain_delete_confirms_controller.rb @@ -24,9 +24,9 @@ class Registrant::DomainDeleteConfirmsController < RegistrantController confirmed = params[:confirmed] ? true : false action = if confirmed - @registrant_verification.domain_registrant_delete_reject!("email link #{initiator}") - else @registrant_verification.domain_registrant_delete_confirm!("email link #{initiator}") + else + @registrant_verification.domain_registrant_delete_reject!("email link #{initiator}") end fail_msg = t("registrant_domain_delete_#{confirmed ? 'confirmed' : 'rejected'}_failed".to_sym) @@ -36,9 +36,9 @@ class Registrant::DomainDeleteConfirmsController < RegistrantController (render 'show' && return) unless action if confirmed - redirect_to registrant_domain_delete_confirm_path(@domain.id, confirmed: true) && return + redirect_to registrant_domain_delete_confirm_path(@domain.id, confirmed: true) else - redirect_to registrant_domain_delete_confirm_path(@domain.id, rejected: true) unless confirmed + redirect_to registrant_domain_delete_confirm_path(@domain.id, rejected: true) end end end From 1b0c264f547209c59789bf27f9c1ba05ddd36ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 3 Aug 2020 13:38:35 +0300 Subject: [PATCH 04/30] Add tests for domain delete confirm UI --- .../domains/domain_delete_confirms_test.rb | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/system/registrant_area/domains/domain_delete_confirms_test.rb diff --git a/test/system/registrant_area/domains/domain_delete_confirms_test.rb b/test/system/registrant_area/domains/domain_delete_confirms_test.rb new file mode 100644 index 000000000..fac381dc4 --- /dev/null +++ b/test/system/registrant_area/domains/domain_delete_confirms_test.rb @@ -0,0 +1,32 @@ +require 'application_system_test_case' + +class DomainDeleteConfirmsTest < ApplicationSystemTestCase + setup do + @user = users(:registrant) + sign_in @user + + @domain = domains(:shop) + @domain.registrant_verification_asked!('\n', @user.id) + @domain.pending_delete! + end + + def test_enqueues_approve_job_after_verification + visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token) + + click_on 'Confirm domain delete' + assert_text 'Domain registrant change has successfully received.' + + @domain.reload + assert_includes @domain.statuses, 'serverHold' + end + + def test_enqueues_reject_job_after_verification + visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token) + + click_on 'Reject domain delete' + assert_text 'Domain registrant change has been rejected successfully.' + + @domain.reload + assert_equal ['ok'], @domain.statuses + end +end From 18337c4f8d26f4eb55c3d3348fba2826f8dc09f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Mon, 3 Aug 2020 16:24:15 +0300 Subject: [PATCH 05/30] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59fb46eb4..589ff5bd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +03.08.2020 +* Fixed 0 vat issue with invoices sent to Directo [#1647](https://github.com/internetee/registry/issues/1647) + 17.07.2020 * Added turemail gem for validating email addresses syntactically and on MX record level [#297](https://github.com/internetee/registry/issues/297) From a56dc03565238de7cfb29757f62e0ceb772d797e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 3 Aug 2020 17:45:17 +0300 Subject: [PATCH 06/30] Set PaperTrail :whodunnit for all Registrar-related controllers --- app/controllers/epp/base_controller.rb | 1 + app/controllers/registrar/base_controller.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/controllers/epp/base_controller.rb b/app/controllers/epp/base_controller.rb index b8d73f8da..525131cf4 100644 --- a/app/controllers/epp/base_controller.rb +++ b/app/controllers/epp/base_controller.rb @@ -20,6 +20,7 @@ module Epp rescue_from StandardError, with: :respond_with_command_failed_error rescue_from AuthorizationError, with: :respond_with_authorization_error rescue_from ActiveRecord::RecordNotFound, with: :respond_with_object_does_not_exist_error + before_action :set_paper_trail_whodunnit protected diff --git a/app/controllers/registrar/base_controller.rb b/app/controllers/registrar/base_controller.rb index 499d44594..54bed977b 100644 --- a/app/controllers/registrar/base_controller.rb +++ b/app/controllers/registrar/base_controller.rb @@ -6,6 +6,7 @@ class Registrar before_action :check_ip_restriction helper_method :depp_controller? helper_method :head_title_sufix + before_action :set_paper_trail_whodunnit protected From a44466b0a6b5a0d382c2309716ace0b1d9fe8a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Tue, 4 Aug 2020 12:12:55 +0300 Subject: [PATCH 07/30] Provide ApiUser name as whodunnit --- app/controllers/epp/base_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/epp/base_controller.rb b/app/controllers/epp/base_controller.rb index 525131cf4..e9d58a4ed 100644 --- a/app/controllers/epp/base_controller.rb +++ b/app/controllers/epp/base_controller.rb @@ -398,5 +398,9 @@ module Epp logger.error(([exception.message] + exception.backtrace).join($INPUT_RECORD_SEPARATOR)) notify_airbrake(exception) end + + def user_for_paper_trail + current_user ? current_user.id_role_username : 'anonymous' + end end end From 6dbdedfa807ec580f618942c417e370c79494df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Tue, 4 Aug 2020 14:39:30 +0300 Subject: [PATCH 08/30] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 589ff5bd3..266a820b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +04.08.2020 +* FIxed registrant verification for domain delete [#1631](https://github.com/internetee/registry/issues/1631) + 03.08.2020 * Fixed 0 vat issue with invoices sent to Directo [#1647](https://github.com/internetee/registry/issues/1647) From 9ce85e155fbd711868d56163a88a48787753082f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Tue, 4 Aug 2020 16:10:58 +0300 Subject: [PATCH 09/30] Transfer: Do not reuse identical contacts --- app/models/concerns/contact/transferable.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/models/concerns/contact/transferable.rb b/app/models/concerns/contact/transferable.rb index 987933a8d..2466e4726 100644 --- a/app/models/concerns/contact/transferable.rb +++ b/app/models/concerns/contact/transferable.rb @@ -7,8 +7,6 @@ module Concerns::Contact::Transferable end def transfer(new_registrar) - return identical(new_registrar) if identical(new_registrar) - new_contact = self.dup new_contact.registrar = new_registrar new_contact.original = self From 6318535fe1e53cb93adb2ae9535db2b235ef9563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Tue, 4 Aug 2020 16:35:43 +0300 Subject: [PATCH 10/30] Create test for identical contact transfer --- test/models/domain_transfer_test.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/models/domain_transfer_test.rb b/test/models/domain_transfer_test.rb index 943fc2a0a..a955f37a6 100644 --- a/test/models/domain_transfer_test.rb +++ b/test/models/domain_transfer_test.rb @@ -29,4 +29,23 @@ class DomainTransferTest < ActiveSupport::TestCase assert_equal id, notification.attached_obj_id assert_equal class_name, notification.attached_obj_type end + + def test_does_not_reuse_identical_contacts_on_transfer + # Create identical contact and assign it to domain + domain = @domain_transfer.domain + identical_contact = domain.contacts.first.transfer(domain.registrar) + + assert_equal 3, domain.domain_contacts.count + domain.domain_contacts.create!(contact: identical_contact, type: 'AdminDomainContact') + + assert_equal 4, domain.domain_contacts.count + + @domain_transfer.approve + @domain_transfer.reload + domain.reload + + assert @domain_transfer.approved? + assert_equal 4, domain.domain_contacts.count + assert_equal domain.registrar, @domain_transfer.new_registrar + end end From 40d68fc7f133076f1ab5be54153a47867954d670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Tue, 4 Aug 2020 17:47:16 +0300 Subject: [PATCH 11/30] Transfer: Return identical objects occassionally --- app/models/concerns/contact/transferable.rb | 9 +++++++++ test/integration/api/domain_transfers_test.rb | 4 ++-- test/integration/epp/domain/transfer/request_test.rb | 4 ++-- test/models/contact/transfer_test.rb | 5 ----- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/models/concerns/contact/transferable.rb b/app/models/concerns/contact/transferable.rb index 2466e4726..407922f25 100644 --- a/app/models/concerns/contact/transferable.rb +++ b/app/models/concerns/contact/transferable.rb @@ -7,6 +7,8 @@ module Concerns::Contact::Transferable end def transfer(new_registrar) + return identical(new_registrar) if identical_with_registrar?(new_registrar) + new_contact = self.dup new_contact.registrar = new_registrar new_contact.original = self @@ -21,6 +23,13 @@ module Concerns::Contact::Transferable protected + def identical_with_registrar?(registrar) + return false unless identical(registrar) + return true unless DomainContact.where(contact_id: id).any? + + false + end + def generate_auth_info self.auth_info = SecureRandom.hex(11) end diff --git a/test/integration/api/domain_transfers_test.rb b/test/integration/api/domain_transfers_test.rb index aabaeb728..dac04bd2c 100644 --- a/test/integration/api/domain_transfers_test.rb +++ b/test/integration/api/domain_transfers_test.rb @@ -64,7 +64,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest end def test_duplicates_registrant_admin_and_tech_contacts - assert_difference -> { @new_registrar.contacts.size }, 3 do + assert_difference -> { @new_registrar.contacts.size }, 4 do post '/repp/v1/domain_transfers', params: request_params, as: :json, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } end @@ -73,7 +73,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest def test_reuses_identical_contact post '/repp/v1/domain_transfers', params: request_params, as: :json, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } - assert_equal 1, @new_registrar.contacts.where(name: 'William').size + assert_equal 2, @new_registrar.contacts.where(name: 'William').size end def test_fails_if_domain_does_not_exist diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index c7a838ca6..5b8dad6ad 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -59,7 +59,7 @@ class EppDomainTransferRequestTest < EppTestCase end def test_duplicates_registrant_admin_and_tech_contacts - assert_difference -> { @new_registrar.contacts.size }, 3 do + assert_difference -> { @new_registrar.contacts.size }, 4 do post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } end @@ -68,7 +68,7 @@ class EppDomainTransferRequestTest < EppTestCase def test_reuses_identical_contact post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } - assert_equal 1, @new_registrar.contacts.where(name: 'William').size + assert_equal 2, @new_registrar.contacts.where(name: 'William').size end def test_saves_legal_document diff --git a/test/models/contact/transfer_test.rb b/test/models/contact/transfer_test.rb index cc35cfdea..af51048aa 100644 --- a/test/models/contact/transfer_test.rb +++ b/test/models/contact/transfer_test.rb @@ -47,11 +47,6 @@ class ContactTransferTest < ActiveSupport::TestCase end end - def test_reuses_identical_contact - identical = contacts(:identical_to_william) - assert_equal identical, contacts(:william).transfer(@new_registrar) - end - def test_bypasses_validation @contact = contacts(:invalid) From a96106bcccd90832969294d6a0fd6a9041756da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Tue, 4 Aug 2020 21:00:46 +0300 Subject: [PATCH 12/30] Remove duplicate domain_contacts on transfer --- app/models/concerns/domain/transferable.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb index 56e77f34d..9de2fff83 100644 --- a/app/models/concerns/domain/transferable.rb +++ b/app/models/concerns/domain/transferable.rb @@ -57,7 +57,8 @@ module Concerns::Domain::Transferable def transfer_domain_contacts(new_registrar) copied_ids = [] - contacts.each do |contact| + domain_contacts.each do |dc| + contact = Contact.find(dc.contact_id) next if copied_ids.include?(contact.id) || contact.registrar == new_registrar if registrant_id_was == contact.id # registrant was copied previously, do not copy it again @@ -66,7 +67,11 @@ module Concerns::Domain::Transferable oc = contact.transfer(new_registrar) end - domain_contacts.where(contact_id: contact.id).update_all({ contact_id: oc.id }) # n+1 workaround + if domain_contacts.find_by(contact_id: oc.id, domain_id: id, type: dc.type).present? + dc.destroy + else + dc.update(contact_id: oc.id) + end copied_ids << contact.id end end From 7ed938484803ab8ebd74399e314ac07ccc9ca3c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Tue, 4 Aug 2020 22:12:36 +0300 Subject: [PATCH 13/30] Revert "Domain transfer: Conditionally reuse contacts" --- app/models/concerns/contact/transferable.rb | 9 +-------- test/integration/api/domain_transfers_test.rb | 4 ++-- .../epp/domain/transfer/request_test.rb | 4 ++-- test/models/contact/transfer_test.rb | 5 +++++ test/models/domain_transfer_test.rb | 19 ------------------- 5 files changed, 10 insertions(+), 31 deletions(-) diff --git a/app/models/concerns/contact/transferable.rb b/app/models/concerns/contact/transferable.rb index 407922f25..987933a8d 100644 --- a/app/models/concerns/contact/transferable.rb +++ b/app/models/concerns/contact/transferable.rb @@ -7,7 +7,7 @@ module Concerns::Contact::Transferable end def transfer(new_registrar) - return identical(new_registrar) if identical_with_registrar?(new_registrar) + return identical(new_registrar) if identical(new_registrar) new_contact = self.dup new_contact.registrar = new_registrar @@ -23,13 +23,6 @@ module Concerns::Contact::Transferable protected - def identical_with_registrar?(registrar) - return false unless identical(registrar) - return true unless DomainContact.where(contact_id: id).any? - - false - end - def generate_auth_info self.auth_info = SecureRandom.hex(11) end diff --git a/test/integration/api/domain_transfers_test.rb b/test/integration/api/domain_transfers_test.rb index dac04bd2c..aabaeb728 100644 --- a/test/integration/api/domain_transfers_test.rb +++ b/test/integration/api/domain_transfers_test.rb @@ -64,7 +64,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest end def test_duplicates_registrant_admin_and_tech_contacts - assert_difference -> { @new_registrar.contacts.size }, 4 do + assert_difference -> { @new_registrar.contacts.size }, 3 do post '/repp/v1/domain_transfers', params: request_params, as: :json, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } end @@ -73,7 +73,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest def test_reuses_identical_contact post '/repp/v1/domain_transfers', params: request_params, as: :json, headers: { 'HTTP_AUTHORIZATION' => http_auth_key } - assert_equal 2, @new_registrar.contacts.where(name: 'William').size + assert_equal 1, @new_registrar.contacts.where(name: 'William').size end def test_fails_if_domain_does_not_exist diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 5b8dad6ad..c7a838ca6 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -59,7 +59,7 @@ class EppDomainTransferRequestTest < EppTestCase end def test_duplicates_registrant_admin_and_tech_contacts - assert_difference -> { @new_registrar.contacts.size }, 4 do + assert_difference -> { @new_registrar.contacts.size }, 3 do post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } end @@ -68,7 +68,7 @@ class EppDomainTransferRequestTest < EppTestCase def test_reuses_identical_contact post epp_transfer_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_goodnames' } - assert_equal 2, @new_registrar.contacts.where(name: 'William').size + assert_equal 1, @new_registrar.contacts.where(name: 'William').size end def test_saves_legal_document diff --git a/test/models/contact/transfer_test.rb b/test/models/contact/transfer_test.rb index af51048aa..cc35cfdea 100644 --- a/test/models/contact/transfer_test.rb +++ b/test/models/contact/transfer_test.rb @@ -47,6 +47,11 @@ class ContactTransferTest < ActiveSupport::TestCase end end + def test_reuses_identical_contact + identical = contacts(:identical_to_william) + assert_equal identical, contacts(:william).transfer(@new_registrar) + end + def test_bypasses_validation @contact = contacts(:invalid) diff --git a/test/models/domain_transfer_test.rb b/test/models/domain_transfer_test.rb index a955f37a6..943fc2a0a 100644 --- a/test/models/domain_transfer_test.rb +++ b/test/models/domain_transfer_test.rb @@ -29,23 +29,4 @@ class DomainTransferTest < ActiveSupport::TestCase assert_equal id, notification.attached_obj_id assert_equal class_name, notification.attached_obj_type end - - def test_does_not_reuse_identical_contacts_on_transfer - # Create identical contact and assign it to domain - domain = @domain_transfer.domain - identical_contact = domain.contacts.first.transfer(domain.registrar) - - assert_equal 3, domain.domain_contacts.count - domain.domain_contacts.create!(contact: identical_contact, type: 'AdminDomainContact') - - assert_equal 4, domain.domain_contacts.count - - @domain_transfer.approve - @domain_transfer.reload - domain.reload - - assert @domain_transfer.approved? - assert_equal 4, domain.domain_contacts.count - assert_equal domain.registrar, @domain_transfer.new_registrar - end end From a0229e5e857b44750b4f5a638b9ba1d4042a2300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Tue, 4 Aug 2020 23:00:13 +0300 Subject: [PATCH 14/30] Revert "Domain transfer: remove duplicate domain_contacts on transfer" --- app/models/concerns/domain/transferable.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb index 9de2fff83..56e77f34d 100644 --- a/app/models/concerns/domain/transferable.rb +++ b/app/models/concerns/domain/transferable.rb @@ -57,8 +57,7 @@ module Concerns::Domain::Transferable def transfer_domain_contacts(new_registrar) copied_ids = [] - domain_contacts.each do |dc| - contact = Contact.find(dc.contact_id) + contacts.each do |contact| next if copied_ids.include?(contact.id) || contact.registrar == new_registrar if registrant_id_was == contact.id # registrant was copied previously, do not copy it again @@ -67,11 +66,7 @@ module Concerns::Domain::Transferable oc = contact.transfer(new_registrar) end - if domain_contacts.find_by(contact_id: oc.id, domain_id: id, type: dc.type).present? - dc.destroy - else - dc.update(contact_id: oc.id) - end + domain_contacts.where(contact_id: contact.id).update_all({ contact_id: oc.id }) # n+1 workaround copied_ids << contact.id end end From 7b170b5026e58aa58e441f608181e08612befecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Tue, 4 Aug 2020 23:09:43 +0300 Subject: [PATCH 15/30] Revert "Revert "Domain transfer: remove duplicate domain_contacts on transfer"" --- app/models/concerns/domain/transferable.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb index 56e77f34d..9de2fff83 100644 --- a/app/models/concerns/domain/transferable.rb +++ b/app/models/concerns/domain/transferable.rb @@ -57,7 +57,8 @@ module Concerns::Domain::Transferable def transfer_domain_contacts(new_registrar) copied_ids = [] - contacts.each do |contact| + domain_contacts.each do |dc| + contact = Contact.find(dc.contact_id) next if copied_ids.include?(contact.id) || contact.registrar == new_registrar if registrant_id_was == contact.id # registrant was copied previously, do not copy it again @@ -66,7 +67,11 @@ module Concerns::Domain::Transferable oc = contact.transfer(new_registrar) end - domain_contacts.where(contact_id: contact.id).update_all({ contact_id: oc.id }) # n+1 workaround + if domain_contacts.find_by(contact_id: oc.id, domain_id: id, type: dc.type).present? + dc.destroy + else + dc.update(contact_id: oc.id) + end copied_ids << contact.id end end From 8688de3248fafd79d6be58cd683456e085dff1a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Wed, 5 Aug 2020 01:01:09 +0300 Subject: [PATCH 16/30] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 266a820b1..e1c63e4ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ 04.08.2020 -* FIxed registrant verification for domain delete [#1631](https://github.com/internetee/registry/issues/1631) +* Fixed registrant verification for domain delete [#1631](https://github.com/internetee/registry/issues/1631) +* Fixed domain transfer issue when one person was present in the same role more than once (different objects) [#1651](https://github.com/internetee/registry/issues/1651) 03.08.2020 * Fixed 0 vat issue with invoices sent to Directo [#1647](https://github.com/internetee/registry/issues/1647) From 5b963d9e97c5455551c8a4ee26c0a59091ed8d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Fri, 7 Aug 2020 13:31:55 +0300 Subject: [PATCH 17/30] Force whodunnit hook on registrant controllers --- app/controllers/registrant_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/registrant_controller.rb b/app/controllers/registrant_controller.rb index 6589d6f89..1e97281e7 100644 --- a/app/controllers/registrant_controller.rb +++ b/app/controllers/registrant_controller.rb @@ -1,5 +1,6 @@ class RegistrantController < ApplicationController before_action :authenticate_registrant_user! + before_action :set_paper_trail_whodunnit layout 'registrant/application' include Registrant::ApplicationHelper @@ -33,4 +34,4 @@ class RegistrantController < ApplicationController flash.now[:notice] = t('registrant.company_register_unavailable') current_registrant_user.direct_domains end -end \ No newline at end of file +end From cca51b8a037a91cb0ba77bee6a6f0e1b2931f1c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Fri, 7 Aug 2020 14:48:54 +0300 Subject: [PATCH 18/30] Fix paper trail versioning for RegistrantVerification --- app/models/concerns/versions.rb | 2 + app/models/registrant_verification.rb | 2 +- ...rification_creator_updator_id_to_string.rb | 9 + db/structure.sql | 192 +++++++++--------- .../domains/domain_delete_confirms_test.rb | 9 + 5 files changed, 118 insertions(+), 96 deletions(-) create mode 100644 db/migrate/20200807110611_change_registrant_verification_creator_updator_id_to_string.rb diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb index a016a8a04..033ebe52a 100644 --- a/app/models/concerns/versions.rb +++ b/app/models/concerns/versions.rb @@ -30,12 +30,14 @@ module Versions def creator return nil if creator_str.blank? + creator = user_from_id_role_username creator_str creator.present? ? creator : creator_str end def updator return nil if updator_str.blank? + updator = user_from_id_role_username updator_str updator.present? ? updator : updator_str end diff --git a/app/models/registrant_verification.rb b/app/models/registrant_verification.rb index 10f6b4881..097f0cfa9 100644 --- a/app/models/registrant_verification.rb +++ b/app/models/registrant_verification.rb @@ -1,7 +1,7 @@ # Used in Registrant portal to collect registrant verifications # Registrant postgres user can access this table directly. class RegistrantVerification < ApplicationRecord - has_paper_trail versions: { class_name: 'RegistrantVerificationVersion' } + include Versions # version/domain_version.rb # actions CONFIRMED = 'confirmed' diff --git a/db/migrate/20200807110611_change_registrant_verification_creator_updator_id_to_string.rb b/db/migrate/20200807110611_change_registrant_verification_creator_updator_id_to_string.rb new file mode 100644 index 000000000..144a80ceb --- /dev/null +++ b/db/migrate/20200807110611_change_registrant_verification_creator_updator_id_to_string.rb @@ -0,0 +1,9 @@ +class ChangeRegistrantVerificationCreatorUpdatorIdToString < ActiveRecord::Migration[6.0] + def change + add_column :registrant_verifications, :creator_str, :string + add_column :registrant_verifications, :updator_str, :string + + remove_column :registrant_verifications, :creator_id + remove_column :registrant_verifications, :updater_id + end +end diff --git a/db/structure.sql b/db/structure.sql index 29e59a8a0..59492ff4a 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1,6 +1,6 @@ ----- ----- PostgreSQL database dump ----- +--- +--- PostgreSQL database dump +--- SET statement_timeout = 0; SET lock_timeout = 0; @@ -31,7 +31,6 @@ COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public; - -- -- Name: citext; Type: EXTENSION; Schema: -; Owner: - -- @@ -567,7 +566,7 @@ ALTER SEQUENCE public.contacts_id_seq OWNED BY public.contacts.id; -- --- Name: data_migrations; Type: TABLE; Schema: public; Owner: - +-- Name: data_migrations; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.data_migrations ( @@ -576,7 +575,7 @@ CREATE TABLE public.data_migrations ( -- --- Name: directos; Type: TABLE; Schema: public; Owner: - +-- Name: directos; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.directos ( @@ -824,7 +823,7 @@ ALTER SEQUENCE public.domains_id_seq OWNED BY public.domains.id; -- --- Name: email_address_verifications; Type: TABLE; Schema: public; Owner: - +-- Name: email_address_verifications; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.email_address_verifications ( @@ -856,7 +855,7 @@ ALTER SEQUENCE public.email_address_verifications_id_seq OWNED BY public.email_a -- --- Name: email_addresses_validations; Type: TABLE; Schema: public; Owner: - +-- Name: email_addresses_validations; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.email_addresses_validations ( @@ -886,7 +885,7 @@ ALTER SEQUENCE public.email_addresses_validations_id_seq OWNED BY public.email_a -- --- Name: email_addresses_verifications; Type: TABLE; Schema: public; Owner: - +-- Name: email_addresses_verifications; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.email_addresses_verifications ( @@ -916,7 +915,7 @@ ALTER SEQUENCE public.email_addresses_verifications_id_seq OWNED BY public.email -- --- Name: epp_sessions; Type: TABLE; Schema: public; Owner: - +-- Name: epp_sessions; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.epp_sessions ( @@ -2132,8 +2131,8 @@ CREATE TABLE public.registrant_verifications ( action character varying NOT NULL, domain_id integer NOT NULL, action_type character varying NOT NULL, - creator_id integer, - updater_id integer + creator_str character varying, + updator_str character varying ); @@ -2591,42 +2590,42 @@ ALTER TABLE ONLY public.domain_transfers ALTER COLUMN id SET DEFAULT nextval('pu -- --- Name: domains id; Type: DEFAULT; Schema: public; Owner: - +-- Name: id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.domains ALTER COLUMN id SET DEFAULT nextval('public.domains_id_seq'::regclass); -- --- Name: email_address_verifications id; Type: DEFAULT; Schema: public; Owner: - +-- Name: id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_address_verifications ALTER COLUMN id SET DEFAULT nextval('public.email_address_verifications_id_seq'::regclass); -- --- Name: email_addresses_validations id; Type: DEFAULT; Schema: public; Owner: - +-- Name: id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_addresses_validations ALTER COLUMN id SET DEFAULT nextval('public.email_addresses_validations_id_seq'::regclass); -- --- Name: email_addresses_verifications id; Type: DEFAULT; Schema: public; Owner: - +-- Name: id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_addresses_verifications ALTER COLUMN id SET DEFAULT nextval('public.email_addresses_verifications_id_seq'::regclass); -- --- Name: epp_sessions id; Type: DEFAULT; Schema: public; Owner: - +-- Name: id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.epp_sessions ALTER COLUMN id SET DEFAULT nextval('public.epp_sessions_id_seq'::regclass); -- --- Name: invoice_items id; Type: DEFAULT; Schema: public; Owner: - +-- Name: id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.invoice_items ALTER COLUMN id SET DEFAULT nextval('public.invoice_items_id_seq'::regclass); @@ -3027,7 +3026,7 @@ ALTER TABLE ONLY public.domains -- --- Name: email_address_verifications email_address_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: email_address_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.email_address_verifications @@ -3035,7 +3034,7 @@ ALTER TABLE ONLY public.email_address_verifications -- --- Name: email_addresses_validations email_addresses_validations_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: email_addresses_validations_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.email_addresses_validations @@ -3043,7 +3042,7 @@ ALTER TABLE ONLY public.email_addresses_validations -- --- Name: email_addresses_verifications email_addresses_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: email_addresses_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.email_addresses_verifications @@ -3051,7 +3050,7 @@ ALTER TABLE ONLY public.email_addresses_verifications -- --- Name: epp_sessions epp_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: epp_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.epp_sessions @@ -3059,7 +3058,7 @@ ALTER TABLE ONLY public.epp_sessions -- --- Name: invoice_items invoice_items_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: invoice_items_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.invoice_items @@ -3339,7 +3338,7 @@ ALTER TABLE ONLY public.blocked_domains -- --- Name: domain_contacts uniq_contact_of_type_per_domain; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: uniq_contact_of_type_per_domain; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.domain_contacts @@ -3347,7 +3346,7 @@ ALTER TABLE ONLY public.domain_contacts -- --- Name: contacts uniq_contact_uuid; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: uniq_contact_uuid; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.contacts @@ -3355,7 +3354,7 @@ ALTER TABLE ONLY public.contacts -- --- Name: domains uniq_domain_uuid; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: uniq_domain_uuid; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.domains @@ -3363,7 +3362,7 @@ ALTER TABLE ONLY public.domains -- --- Name: nameservers uniq_hostname_per_domain; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: uniq_hostname_per_domain; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.nameservers @@ -3371,7 +3370,7 @@ ALTER TABLE ONLY public.nameservers -- --- Name: reserved_domains uniq_reserved_domains_name; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: uniq_reserved_domains_name; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.reserved_domains @@ -3379,7 +3378,7 @@ ALTER TABLE ONLY public.reserved_domains -- --- Name: auctions uniq_uuid; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: uniq_uuid; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.auctions @@ -3638,447 +3637,448 @@ CREATE INDEX index_domains_on_registrar_id ON public.domains USING btree (regist -- --- Name: index_domains_on_statuses; Type: INDEX; Schema: public; Owner: - +-- Name: index_domains_on_statuses; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_domains_on_statuses ON public.domains USING gin (statuses); -- --- Name: index_email_address_verifications_on_domain; Type: INDEX; Schema: public; Owner: - +-- Name: index_email_address_verifications_on_domain; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_email_address_verifications_on_domain ON public.email_address_verifications USING btree (domain); -- --- Name: index_epp_sessions_on_updated_at; Type: INDEX; Schema: public; Owner: - +-- Name: index_epp_sessions_on_updated_at; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_epp_sessions_on_updated_at ON public.epp_sessions USING btree (updated_at); -- --- Name: index_invoice_items_on_invoice_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_invoice_items_on_invoice_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_invoice_items_on_invoice_id ON public.invoice_items USING btree (invoice_id); -- --- Name: index_invoices_on_buyer_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_invoices_on_buyer_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_invoices_on_buyer_id ON public.invoices USING btree (buyer_id); -- --- Name: index_legal_documents_on_checksum; Type: INDEX; Schema: public; Owner: - +-- Name: index_legal_documents_on_checksum; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_legal_documents_on_checksum ON public.legal_documents USING btree (checksum); -- --- Name: index_legal_documents_on_documentable_type_and_documentable_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_legal_documents_on_documentable_type_and_documentable_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_legal_documents_on_documentable_type_and_documentable_id ON public.legal_documents USING btree (documentable_type, documentable_id); -- --- Name: index_log_account_activities_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_account_activities_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_account_activities_on_item_type_and_item_id ON public.log_account_activities USING btree (item_type, item_id); -- --- Name: index_log_account_activities_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_account_activities_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_account_activities_on_whodunnit ON public.log_account_activities USING btree (whodunnit); -- --- Name: index_log_accounts_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_accounts_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_accounts_on_item_type_and_item_id ON public.log_accounts USING btree (item_type, item_id); -- --- Name: index_log_accounts_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_accounts_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_accounts_on_whodunnit ON public.log_accounts USING btree (whodunnit); -- --- Name: index_log_bank_statements_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_bank_statements_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_bank_statements_on_item_type_and_item_id ON public.log_bank_statements USING btree (item_type, item_id); -- --- Name: index_log_bank_statements_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_bank_statements_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_bank_statements_on_whodunnit ON public.log_bank_statements USING btree (whodunnit); -- --- Name: index_log_bank_transactions_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_bank_transactions_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_bank_transactions_on_item_type_and_item_id ON public.log_bank_transactions USING btree (item_type, item_id); -- --- Name: index_log_bank_transactions_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_bank_transactions_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_bank_transactions_on_whodunnit ON public.log_bank_transactions USING btree (whodunnit); -- --- Name: index_log_blocked_domains_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_blocked_domains_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_blocked_domains_on_item_type_and_item_id ON public.log_blocked_domains USING btree (item_type, item_id); -- --- Name: index_log_blocked_domains_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_blocked_domains_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_blocked_domains_on_whodunnit ON public.log_blocked_domains USING btree (whodunnit); -- --- Name: index_log_certificates_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_certificates_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_certificates_on_item_type_and_item_id ON public.log_certificates USING btree (item_type, item_id); -- --- Name: index_log_certificates_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_certificates_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_certificates_on_whodunnit ON public.log_certificates USING btree (whodunnit); -- --- Name: index_log_contacts_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_contacts_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_contacts_on_item_type_and_item_id ON public.log_contacts USING btree (item_type, item_id); -- --- Name: index_log_contacts_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_contacts_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_contacts_on_whodunnit ON public.log_contacts USING btree (whodunnit); -- --- Name: index_log_dnskeys_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_dnskeys_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_dnskeys_on_item_type_and_item_id ON public.log_dnskeys USING btree (item_type, item_id); -- --- Name: index_log_dnskeys_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_dnskeys_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_dnskeys_on_whodunnit ON public.log_dnskeys USING btree (whodunnit); -- --- Name: index_log_domain_contacts_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_domain_contacts_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_domain_contacts_on_item_type_and_item_id ON public.log_domain_contacts USING btree (item_type, item_id); -- --- Name: index_log_domain_contacts_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_domain_contacts_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_domain_contacts_on_whodunnit ON public.log_domain_contacts USING btree (whodunnit); -- --- Name: index_log_domains_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_domains_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_domains_on_item_type_and_item_id ON public.log_domains USING btree (item_type, item_id); -- --- Name: index_log_domains_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_domains_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_domains_on_whodunnit ON public.log_domains USING btree (whodunnit); -- --- Name: index_log_invoice_items_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_invoice_items_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_invoice_items_on_item_type_and_item_id ON public.log_invoice_items USING btree (item_type, item_id); -- --- Name: index_log_invoice_items_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_invoice_items_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_invoice_items_on_whodunnit ON public.log_invoice_items USING btree (whodunnit); -- --- Name: index_log_invoices_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_invoices_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_invoices_on_item_type_and_item_id ON public.log_invoices USING btree (item_type, item_id); -- --- Name: index_log_invoices_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_invoices_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_invoices_on_whodunnit ON public.log_invoices USING btree (whodunnit); -- --- Name: index_log_nameservers_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_nameservers_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_nameservers_on_item_type_and_item_id ON public.log_nameservers USING btree (item_type, item_id); -- --- Name: index_log_nameservers_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_nameservers_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_nameservers_on_whodunnit ON public.log_nameservers USING btree (whodunnit); -- --- Name: index_log_notifications_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_notifications_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_notifications_on_item_type_and_item_id ON public.log_notifications USING btree (item_type, item_id); -- --- Name: index_log_notifications_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_notifications_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_notifications_on_whodunnit ON public.log_notifications USING btree (whodunnit); -- --- Name: index_log_registrant_verifications_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_registrant_verifications_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_registrant_verifications_on_item_type_and_item_id ON public.log_registrant_verifications USING btree (item_type, item_id); -- --- Name: index_log_registrant_verifications_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_registrant_verifications_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_registrant_verifications_on_whodunnit ON public.log_registrant_verifications USING btree (whodunnit); -- --- Name: index_log_registrars_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_registrars_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_registrars_on_item_type_and_item_id ON public.log_registrars USING btree (item_type, item_id); -- --- Name: index_log_registrars_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_registrars_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_registrars_on_whodunnit ON public.log_registrars USING btree (whodunnit); -- --- Name: index_log_reserved_domains_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_reserved_domains_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_reserved_domains_on_item_type_and_item_id ON public.log_reserved_domains USING btree (item_type, item_id); -- --- Name: index_log_reserved_domains_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_reserved_domains_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_reserved_domains_on_whodunnit ON public.log_reserved_domains USING btree (whodunnit); -- --- Name: index_log_settings_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_settings_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_settings_on_item_type_and_item_id ON public.log_settings USING btree (item_type, item_id); -- --- Name: index_log_settings_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_settings_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_settings_on_whodunnit ON public.log_settings USING btree (whodunnit); -- --- Name: index_log_users_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_users_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_users_on_item_type_and_item_id ON public.log_users USING btree (item_type, item_id); -- --- Name: index_log_users_on_whodunnit; Type: INDEX; Schema: public; Owner: - +-- Name: index_log_users_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_log_users_on_whodunnit ON public.log_users USING btree (whodunnit); -- --- Name: index_nameservers_on_domain_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_nameservers_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_nameservers_on_domain_id ON public.nameservers USING btree (domain_id); -- --- Name: index_notifications_on_registrar_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_notifications_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_notifications_on_registrar_id ON public.notifications USING btree (registrar_id); -- --- Name: index_payment_orders_on_invoice_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_payment_orders_on_invoice_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_payment_orders_on_invoice_id ON public.payment_orders USING btree (invoice_id); -- --- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_prices_on_zone_id ON public.prices USING btree (zone_id); -- --- Name: index_registrant_verifications_on_created_at; Type: INDEX; Schema: public; Owner: - +-- Name: index_registrant_verifications_on_created_at; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_registrant_verifications_on_created_at ON public.registrant_verifications USING btree (created_at); -- --- Name: index_registrant_verifications_on_domain_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_registrant_verifications_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_registrant_verifications_on_domain_id ON public.registrant_verifications USING btree (domain_id); -- --- Name: index_settings_on_thing_type_and_thing_id_and_var; Type: INDEX; Schema: public; Owner: - +-- Name: index_settings_on_thing_type_and_thing_id_and_var; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX index_settings_on_thing_type_and_thing_id_and_var ON public.settings USING btree (thing_type, thing_id, var); -- --- Name: index_users_on_identity_code; Type: INDEX; Schema: public; Owner: - +-- Name: index_users_on_identity_code; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_users_on_identity_code ON public.users USING btree (identity_code); -- --- Name: index_users_on_registrar_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_users_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_users_on_registrar_id ON public.users USING btree (registrar_id); -- --- Name: index_versions_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_versions_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_versions_on_item_type_and_item_id ON public.versions USING btree (item_type, item_id); -- --- Name: index_whois_records_on_domain_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_whois_records_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_whois_records_on_domain_id ON public.whois_records USING btree (domain_id); -- --- Name: index_whois_records_on_registrar_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_whois_records_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_whois_records_on_registrar_id ON public.whois_records USING btree (registrar_id); -- --- Name: log_contacts_object_legacy_id; Type: INDEX; Schema: public; Owner: - +-- Name: log_contacts_object_legacy_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX log_contacts_object_legacy_id ON public.log_contacts USING btree ((((object ->> 'legacy_id'::text))::integer)); -- --- Name: log_dnskeys_object_legacy_id; Type: INDEX; Schema: public; Owner: - +-- Name: log_dnskeys_object_legacy_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX log_dnskeys_object_legacy_id ON public.log_contacts USING btree ((((object ->> 'legacy_domain_id'::text))::integer)); -- --- Name: log_domains_object_legacy_id; Type: INDEX; Schema: public; Owner: - +-- Name: log_domains_object_legacy_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX log_domains_object_legacy_id ON public.log_contacts USING btree ((((object ->> 'legacy_id'::text))::integer)); -- --- Name: log_nameservers_object_legacy_id; Type: INDEX; Schema: public; Owner: - +-- Name: log_nameservers_object_legacy_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX log_nameservers_object_legacy_id ON public.log_contacts USING btree ((((object ->> 'legacy_domain_id'::text))::integer)); -- --- Name: unique_data_migrations; Type: INDEX; Schema: public; Owner: - +-- Name: unique_data_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX unique_data_migrations ON public.data_migrations USING btree (version); -- --- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: - +-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX unique_schema_migrations ON public.schema_migrations USING btree (version); + -- --- Name: contacts contacts_registrar_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- Name: contacts_registrar_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.contacts @@ -4086,7 +4086,7 @@ ALTER TABLE ONLY public.contacts -- --- Name: domain_contacts domain_contacts_contact_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- Name: domain_contacts_contact_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.domain_contacts @@ -4711,5 +4711,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20200605100827'), ('20200610090110'), ('20200630081231'), -('20200714115338'); +('20200714115338'), +('20200807110611'); + diff --git a/test/system/registrant_area/domains/domain_delete_confirms_test.rb b/test/system/registrant_area/domains/domain_delete_confirms_test.rb index fac381dc4..0eb61ada8 100644 --- a/test/system/registrant_area/domains/domain_delete_confirms_test.rb +++ b/test/system/registrant_area/domains/domain_delete_confirms_test.rb @@ -29,4 +29,13 @@ class DomainDeleteConfirmsTest < ApplicationSystemTestCase @domain.reload assert_equal ['ok'], @domain.statuses end + + def test_saves_whodunnit_info_after_verifivation + visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token) + token = @domain.registrant_verification_token + click_on 'Confirm domain delete' + assert_text 'Domain registrant change has successfully received.' + + refute RegistrantVerification.find_by(verification_token:token).updator_str.empty? + end end From 8e0b02af2dd8d9ae353a0938c22a3e141f0b161b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Fri, 7 Aug 2020 15:37:35 +0300 Subject: [PATCH 19/30] Upgrade sdoc to 1.1, json to 2.3.1 --- Gemfile | 2 +- Gemfile.lock | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index 99091f556..f1d03f8a8 100644 --- a/Gemfile +++ b/Gemfile @@ -81,10 +81,10 @@ end group :development, :test do gem 'pry', '0.10.1' - gem 'sdoc', '0.4.1' # bundle exec rake doc:rails generates the API under doc/api. gem 'railroady', '1.3.0' # to generate database diagrams gem 'autodoc' gem 'puma' + gem 'sdoc', '~> 1.1' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index e4ad26396..dcf62a343 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -253,7 +253,7 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (5.0.5) railties (>= 3.2.16) - json (1.8.6) + json (2.3.1) kaminari (1.2.1) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.1) @@ -377,7 +377,7 @@ GEM rb-inotify (0.10.1) ffi (~> 1.0) rbtree3 (0.6.0) - rdoc (4.3.0) + rdoc (6.2.1) regexp_parser (1.7.1) request_store (1.5.0) rack (>= 1.4) @@ -423,9 +423,8 @@ GEM nokogiri (>= 1.8.1) nori (~> 2.4) wasabi (~> 3.4) - sdoc (0.4.1) - json (~> 1.7, >= 1.7.7) - rdoc (~> 4.0) + sdoc (1.1.0) + rdoc (>= 5.0) select2-rails (3.5.9.3) thor (~> 0.14) selectize-rails (0.12.1) @@ -545,7 +544,7 @@ DEPENDENCIES ransack (~> 2.3) rest-client sass-rails - sdoc (= 0.4.1) + sdoc (~> 1.1) select2-rails (= 3.5.9.3) selectize-rails (= 0.12.1) simplecov (= 0.17.1) From e7f8c83eb6139b30aa0e5276e5d07ac1ee9f9aa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Fri, 7 Aug 2020 15:47:56 +0300 Subject: [PATCH 20/30] Force whodunnit hook on admin controllers --- app/controllers/admin/base_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb index 17e75785a..1fec2a18f 100644 --- a/app/controllers/admin/base_controller.rb +++ b/app/controllers/admin/base_controller.rb @@ -2,6 +2,7 @@ module Admin class BaseController < ApplicationController before_action :authenticate_admin_user! helper_method :head_title_sufix + before_action :set_paper_trail_whodunnit def head_title_sufix t(:admin_head_title_sufix) @@ -17,4 +18,4 @@ module Admin current_admin_user ? current_admin_user.id_role_username : 'anonymous' end end -end \ No newline at end of file +end From 3303e246d11ce37b95b07eccd12eb5a4d686ec54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Fri, 7 Aug 2020 19:16:27 +0300 Subject: [PATCH 21/30] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1c63e4ab..ac69189d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +07.08.2020 +* Restored creator and updator strings to contacts and related object records [#1636](https://github.com/internetee/registry/issues/1636) + 04.08.2020 * Fixed registrant verification for domain delete [#1631](https://github.com/internetee/registry/issues/1631) * Fixed domain transfer issue when one person was present in the same role more than once (different objects) [#1651](https://github.com/internetee/registry/issues/1651) From 21d246cc3e2eb35ea0b2c4d076f78cf536b70b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Fri, 7 Aug 2020 19:35:19 +0300 Subject: [PATCH 22/30] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac69189d5..f6a9ff66a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ 07.08.2020 * Restored creator and updator strings to contacts and related object records [#1636](https://github.com/internetee/registry/issues/1636) +* Security gem updates: sdoc to 1.1 and json to 2.3.1 [#1657](https://github.com/internetee/registry/pull/1657) 04.08.2020 * Fixed registrant verification for domain delete [#1631](https://github.com/internetee/registry/issues/1631) From 3b53e122845c395d87a57847644068982c67d881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 10 Aug 2020 12:47:02 +0300 Subject: [PATCH 23/30] Clear contact address fields if address processing turned off --- app/models/contact.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/models/contact.rb b/app/models/contact.rb index ac64b059f..e91dab3b5 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -62,6 +62,7 @@ class Contact < ApplicationRecord mapping: [%w[ident code], %w[ident_type type], %w[ident_country_code country_code]] after_save :update_related_whois_records + before_save :clear_address_modifications, if: -> { !self.class.address_processing? } self.ignored_columns = %w[legacy_id legacy_history_id] @@ -507,6 +508,21 @@ class Contact < ApplicationRecord ]).present? end + def clear_address_modifications + return unless modifies_address? + + addr_fields = %i[city street zip state country_code] + addr_fields.each { |field| self[field] = nil } + end + + def modifies_address? + addr_fields = %i[city street zip state country_code] + modified = false + addr_fields.each { |field| modified = true if changes.key?(field) } + + modified + end + def update_related_whois_records # not doing anything if no real changes ignored_columns = %w[updated_at created_at statuses status_notes] From 1bc0ec07d38b39c86875780473775fa1f80d353e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 10 Aug 2020 13:59:50 +0300 Subject: [PATCH 24/30] Fix registrant API test --- test/integration/api/v1/registrant/contacts/update_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/api/v1/registrant/contacts/update_test.rb b/test/integration/api/v1/registrant/contacts/update_test.rb index 6e0c0eea3..e2e9abe9a 100644 --- a/test/integration/api/v1/registrant/contacts/update_test.rb +++ b/test/integration/api/v1/registrant/contacts/update_test.rb @@ -91,8 +91,8 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest end def test_address_is_optional_when_enabled - @contact.update!(street: 'any', zip: 'any', city: 'any', state: 'any', country_code: 'US') Setting.address_processing = true + @contact.update!(street: 'any', zip: 'any', city: 'any', state: 'any', country_code: 'US') patch api_v1_registrant_contact_path(@contact.uuid), params: { name: 'any' }, as: :json, From 55ae0dc0b785e1a3fd3c514e215dd353039ab59a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 10 Aug 2020 14:05:22 +0300 Subject: [PATCH 25/30] Remove redundant functions --- app/models/contact.rb | 6 ++---- test/models/contact_test.rb | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index e91dab3b5..a2057f229 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -511,14 +511,12 @@ class Contact < ApplicationRecord def clear_address_modifications return unless modifies_address? - addr_fields = %i[city street zip state country_code] - addr_fields.each { |field| self[field] = nil } + remove_address end def modifies_address? - addr_fields = %i[city street zip state country_code] modified = false - addr_fields.each { |field| modified = true if changes.key?(field) } + self.class.address_attribute_names.each { |field| modified = true if changes.key?(field) } modified end diff --git a/test/models/contact_test.rb b/test/models/contact_test.rb index f833011c6..48b98a0d2 100644 --- a/test/models/contact_test.rb +++ b/test/models/contact_test.rb @@ -152,6 +152,8 @@ class ContactTest < ActiveSupport::TestCase end def test_address + Setting.address_processing = true + address = Contact::Address.new('new street', '83746', 'new city', 'new state', 'EE') @contact.address = address @contact.save! From 625bd459de045ae7f923acefc47b81e57a10164b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 10 Aug 2020 14:27:05 +0300 Subject: [PATCH 26/30] Explicitly set address_processing to false in tests --- test/test_helper.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index bee6fdcf9..1b70baf49 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -47,6 +47,7 @@ class ActiveSupport::TestCase teardown do travel_back + Setting.address_processing = false end end @@ -60,9 +61,14 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest WebMock.reset! Capybara.reset_sessions! Capybara.use_default_driver + Setting.address_processing = false end end class EppTestCase < ActionDispatch::IntegrationTest include Assertions::EppAssertions + + teardown do + Setting.address_processing = false + end end From 8f8b246e493779503dd7c19e6c13d9ff51d093d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 10 Aug 2020 16:04:02 +0300 Subject: [PATCH 27/30] Query address mandatoryness via Contact.address_processing? --- app/models/actions/contact_update.rb | 2 +- app/models/contact.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/actions/contact_update.rb b/app/models/actions/contact_update.rb index 5b94cf918..f8b39ecb4 100644 --- a/app/models/actions/contact_update.rb +++ b/app/models/actions/contact_update.rb @@ -23,7 +23,7 @@ module Actions end def maybe_remove_address - return if Setting.address_processing? + return if Contact.address_processing? new_attributes.delete(:city) new_attributes.delete(:zip) diff --git a/app/models/contact.rb b/app/models/contact.rb index a2057f229..4199e6dc7 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -62,7 +62,7 @@ class Contact < ApplicationRecord mapping: [%w[ident code], %w[ident_type type], %w[ident_country_code country_code]] after_save :update_related_whois_records - before_save :clear_address_modifications, if: -> { !self.class.address_processing? } + before_validation :clear_address_modifications, if: -> { !self.class.address_processing? } self.ignored_columns = %w[legacy_id legacy_history_id] From e40353042e7d509c9b1196db1f7d9a9b75296ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 10 Aug 2020 16:04:52 +0300 Subject: [PATCH 28/30] Include tests for EPP contact create/update actions regarding to addressing --- app/models/epp/response/result/code.rb | 1 + .../epp/contact/create/base_test.rb | 111 ++++++++++++++++++ .../epp/contact/update/base_test.rb | 93 +++++++++++++++ 3 files changed, 205 insertions(+) diff --git a/app/models/epp/response/result/code.rb b/app/models/epp/response/result/code.rb index 2a65f6747..e2af0823d 100644 --- a/app/models/epp/response/result/code.rb +++ b/app/models/epp/response/result/code.rb @@ -7,6 +7,7 @@ module Epp KEY_TO_VALUE = { completed_successfully: 1000, completed_successfully_action_pending: 1001, + completed_without_address: 1100, completed_successfully_no_messages: 1300, completed_successfully_ack_to_dequeue: 1301, completed_successfully_ending_session: 1500, diff --git a/test/integration/epp/contact/create/base_test.rb b/test/integration/epp/contact/create/base_test.rb index e9a59b8d2..262487a1e 100644 --- a/test/integration/epp/contact/create/base_test.rb +++ b/test/integration/epp/contact/create/base_test.rb @@ -140,4 +140,115 @@ class EppContactCreateBaseTest < EppTestCase end assert_epp_response :required_parameter_missing end + + def test_does_not_save_address_when_address_processing_turned_off + name = 'new' + email = 'new@registrar.test' + phone = '+1.2' + + request_xml = <<-XML + + + + + + + #{name} + + 123 Example + Tallinn + FFF + 123456 + EE + + + #{phone} + #{email} + + + + + 123 + + + + + XML + + assert_difference 'Contact.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end + + assert_epp_response :completed_without_address + contact = Contact.find_by(name: name) + assert_equal name, contact.name + assert_equal email, contact.email + assert_equal phone, contact.phone + assert_not_empty contact.code + assert_nil contact.city + assert_nil contact.street + assert_nil contact.zip + assert_nil contact.country_code + assert_nil contact.state + end + + def test_saves_address_when_address_processing_turned_on + Setting.address_processing = true + + name = 'new' + email = 'new@registrar.test' + phone = '+1.2' + street = '123 Example' + city = 'Tallinn' + state = 'Harjumaa' + zip = '123456' + country_code = 'EE' + + request_xml = <<-XML + + + + + + + #{name} + + #{street} + #{city} + #{state} + #{zip} + #{country_code} + + + #{phone} + #{email} + + + + + 123 + + + + + XML + + assert_difference 'Contact.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + end + + assert_epp_response :completed_successfully + contact = Contact.find_by(name: name) + assert_equal name, contact.name + assert_equal email, contact.email + assert_equal phone, contact.phone + assert_not_empty contact.code + assert_equal city, contact.city + assert_equal street, contact.street + assert_equal zip, contact.zip + assert_equal country_code, contact.country_code + assert_equal state, contact.state + end end diff --git a/test/integration/epp/contact/update/base_test.rb b/test/integration/epp/contact/update/base_test.rb index 3d332711f..98c0e4462 100644 --- a/test/integration/epp/contact/update/base_test.rb +++ b/test/integration/epp/contact/update/base_test.rb @@ -232,6 +232,99 @@ class EppContactUpdateBaseTest < EppTestCase assert_epp_response :completed_successfully end + def test_updates_address_when_address_processing_turned_on + @contact.update_columns(code: @contact.code.upcase) + Setting.address_processing = true + + street = '123 Example' + city = 'Tallinn' + state = 'Harjumaa' + zip = '123456' + country_code = 'EE' + + request_xml = <<-XML + + + + + + #{@contact.code} + + + + #{street} + #{city} + #{state} + #{zip} + #{country_code} + + + + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + + assert_epp_response :completed_successfully + @contact.reload + + assert_equal city, @contact.city + assert_equal street, @contact.street + assert_equal zip, @contact.zip + assert_equal country_code, @contact.country_code + assert_equal state, @contact.state + end + + def test_does_not_update_address_when_address_processing_turned_off + @contact.update_columns(code: @contact.code.upcase) + + street = '123 Example' + city = 'Tallinn' + state = 'Harjumaa' + zip = '123456' + country_code = 'EE' + + request_xml = <<-XML + + + + + + #{@contact.code} + + + + #{street} + #{city} + #{state} + #{zip} + #{country_code} + + + + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + + assert_epp_response :completed_without_address + @contact.reload + + assert_nil @contact.city + assert_nil @contact.street + assert_nil @contact.zip + assert_nil @contact.country_code + assert_nil @contact.state + end + private def make_contact_free_of_domains_where_it_acts_as_a_registrant(contact) From 414519d17fa76363b1077cdaaa8dfa65f10056a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 10 Aug 2020 16:13:35 +0300 Subject: [PATCH 29/30] Improve addressing tests --- app/models/epp/response/result/code.rb | 1 + test/models/contact_test.rb | 1 + test/models/epp/response/result/code_test.rb | 2 ++ 3 files changed, 4 insertions(+) diff --git a/app/models/epp/response/result/code.rb b/app/models/epp/response/result/code.rb index e2af0823d..1be4a3f7c 100644 --- a/app/models/epp/response/result/code.rb +++ b/app/models/epp/response/result/code.rb @@ -36,6 +36,7 @@ module Epp DEFAULT_DESCRIPTIONS = { 1000 => 'Command completed successfully', 1001 => 'Command completed successfully; action pending', + 1100 => 'Command completed successfully; Postal address data discarded', 1300 => 'Command completed successfully; no messages', 1301 => 'Command completed successfully; ack to dequeue', 1500 => 'Command completed successfully; ending session', diff --git a/test/models/contact_test.rb b/test/models/contact_test.rb index 48b98a0d2..000333d57 100644 --- a/test/models/contact_test.rb +++ b/test/models/contact_test.rb @@ -240,6 +240,7 @@ class ContactTest < ActiveSupport::TestCase end def test_normalizes_country_code + Setting.address_processing = true contact = Contact.new(country_code: 'us') contact.validate assert_equal 'US', contact.country_code diff --git a/test/models/epp/response/result/code_test.rb b/test/models/epp/response/result/code_test.rb index 3c75303f1..f16013180 100644 --- a/test/models/epp/response/result/code_test.rb +++ b/test/models/epp/response/result/code_test.rb @@ -28,6 +28,7 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase codes = { completed_successfully: 1000, completed_successfully_action_pending: 1001, + completed_without_address: 1100, completed_successfully_no_messages: 1300, completed_successfully_ack_to_dequeue: 1301, completed_successfully_ending_session: 1500, @@ -58,6 +59,7 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase descriptions = { 1000 => 'Command completed successfully', 1001 => 'Command completed successfully; action pending', + 1100 => 'Command completed successfully; Postal address data discarded', 1300 => 'Command completed successfully; no messages', 1301 => 'Command completed successfully; ack to dequeue', 1500 => 'Command completed successfully; ending session', From 075b4900a05f75a84660a374361d6764c64ff505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Tue, 11 Aug 2020 13:37:30 +0300 Subject: [PATCH 30/30] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6a9ff66a..3ba471dc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +11.08.2020 +* FIxed postal address saving bug with disabled address processing [#1650](https://github.com/internetee/registry/issues/1650) + 07.08.2020 * Restored creator and updator strings to contacts and related object records [#1636](https://github.com/internetee/registry/issues/1636) * Security gem updates: sdoc to 1.1 and json to 2.3.1 [#1657](https://github.com/internetee/registry/pull/1657)