From 56b66cf3b72591b1ce9a5506ee3ce8fed9cf6211 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 14 Feb 2017 05:16:54 +0200 Subject: [PATCH 1/6] Include EPP helpers in all request specs #269 --- spec/rails_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 875162cae..5fb8344fa 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -32,7 +32,7 @@ RSpec.configure do |config| config.include Requests::SessionHelpers, type: :request config.include Features::SessionHelpers, type: :feature config.include AbstractController::Translation, type: :feature - config.include Requests::EPPHelpers, epp: true + config.include Requests::EPPHelpers config.include Requests::EPPHelpers, epp: true From 7995525d9d4c9e7bc290a9f848b3d0d45e724ebd Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 19 Feb 2017 13:20:03 +0200 Subject: [PATCH 2/6] Include EPP helpers in all request specs --- spec/rails_helper.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 5fb8344fa..d5b0da950 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -34,8 +34,6 @@ RSpec.configure do |config| config.include AbstractController::Translation, type: :feature config.include Requests::EPPHelpers - config.include Requests::EPPHelpers, epp: true - config.define_derived_metadata(file_path: %r[/spec/features/]) do |metadata| metadata[:db] = true if metadata[:db].nil? end From 71228726f1c8617f9d58650e874071fdf5af4f72 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 6 Feb 2017 23:22:31 +0200 Subject: [PATCH 3/6] Add valid legal document helper to request specs #269 --- spec/support/requests/epp_helpers.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/support/requests/epp_helpers.rb b/spec/support/requests/epp_helpers.rb index 1372ae779..beb8ca2c2 100644 --- a/spec/support/requests/epp_helpers.rb +++ b/spec/support/requests/epp_helpers.rb @@ -3,5 +3,9 @@ module Requests def have_code_of(*args) Matchers::EPP::Code.new(*args) end + + def valid_legal_document + Base64.encode64('a' * 5000) + end end end From a09ae8279c107928d1ac92a5ef4e02ece07060dd Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 5 Feb 2017 23:33:06 +0200 Subject: [PATCH 4/6] Add admin sign in helper to request specs --- spec/support/requests/session_helpers.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/support/requests/session_helpers.rb b/spec/support/requests/session_helpers.rb index 3f75da577..9d8c69dc3 100644 --- a/spec/support/requests/session_helpers.rb +++ b/spec/support/requests/session_helpers.rb @@ -28,5 +28,9 @@ module Requests post '/epp/session/login', frame: login_xml end + + def sign_in_to_admin_area(user: FactoryGirl.create(:admin_user)) + post admin_sessions_path, admin_user: { username: user.username, password: user.password } + end end end From 8275f0ccd68c245d7d8da116fd116f8104ba4050 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 27 Feb 2017 13:30:31 +0200 Subject: [PATCH 5/6] Add EPP domain:update verified spec #359 --- .../update/registrant_change/verified_spec.rb | 196 ++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 spec/requests/epp/domain/update/registrant_change/verified_spec.rb diff --git a/spec/requests/epp/domain/update/registrant_change/verified_spec.rb b/spec/requests/epp/domain/update/registrant_change/verified_spec.rb new file mode 100644 index 000000000..996fffccf --- /dev/null +++ b/spec/requests/epp/domain/update/registrant_change/verified_spec.rb @@ -0,0 +1,196 @@ +require 'rails_helper' + +RSpec.describe 'EPP domain:update' do + let(:request) { post '/epp/command/update', frame: request_xml } + let!(:registrant) { create(:registrant, code: 'old-code') } + let!(:domain) { create(:domain, name: 'test.com', registrant: registrant) } + let!(:new_registrant) { create(:registrant, code: 'new-code') } + + before :example do + sign_in_to_epp_area + end + + context 'when registrant change confirmation is enabled' do + before :example do + Setting.request_confrimation_on_registrant_change_enabled = true + end + + context 'when verified' do + let(:request_xml) { <<-XML + + + + + + test.com + + new-code + + + + + + #{valid_legal_document} + + + + + XML + } + + specify do + request + expect(response).to have_code_of(1000) + end + + it 'changes registrant' do + expect { request; domain.reload }.to change { domain.registrant_code }.from('old-code').to('new-code') + end + + it 'does not send confirmation email' do + expect { request }.to_not change { ActionMailer::Base.deliveries.count } + end + + it 'does not set PENDING_UPDATE status to domain' do + request + domain.reload + expect(domain.statuses).to_not include(DomainStatus::PENDING_UPDATE) + end + end + + context 'when not verified' do + let(:request_xml) { <<-XML + + + + + + test.com + + new-code + + + + + + #{valid_legal_document} + + + + + XML + } + + specify do + request + expect(response).to have_code_of(1001) + end + + it 'does not change registrant' do + expect { request; domain.reload }.to_not change { domain.registrant_code } + end + + it 'sends confirmation and notice emails' do + expect { request }.to change { ActionMailer::Base.deliveries.count }.by(2) + end + + it 'sets PENDING_UPDATE status to domain' do + request + domain.reload + expect(domain.statuses).to include(DomainStatus::PENDING_UPDATE) + end + end + end + + context 'when registrant change confirmation is disabled' do + before :example do + Setting.request_confrimation_on_registrant_change_enabled = false + end + + context 'when verified' do + let(:request_xml) { <<-XML + + + + + + test.com + + new-code + + + + + + #{valid_legal_document} + + + + + XML + } + + specify do + request + expect(response).to have_code_of(1000) + end + + it 'changes registrant' do + expect { request; domain.reload }.to change { domain.registrant_code }.from('old-code').to('new-code') + end + + it 'does not send confirmation email' do + expect { request }.to_not change { ActionMailer::Base.deliveries.count } + end + + it 'does not set PENDING_UPDATE status to domain' do + request + domain.reload + expect(domain.statuses).to_not include(DomainStatus::PENDING_UPDATE) + end + end + + context 'when not verified' do + let(:request_xml) { <<-XML + + + + + + test.com + + new-code + + + + + + #{valid_legal_document} + + + + + XML + } + + specify do + request + expect(response).to have_code_of(1000) + end + + it 'changes registrant' do + expect { request; domain.reload }.to change { domain.registrant_code }.from('old-code').to('new-code') + end + + it 'does not send confirmation email' do + expect { request }.to_not change { ActionMailer::Base.deliveries.count } + end + + it 'does not set PENDING_UPDATE status to domain' do + request + domain.reload + expect(domain.statuses).to_not include(DomainStatus::PENDING_UPDATE) + end + end + end +end From a25cf51e2493b6cd918c8504a7593ad01bb39949 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 28 Feb 2017 04:51:43 +0200 Subject: [PATCH 6/6] Fix rspec config --- spec/rails_helper.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index d5b0da950..110e8df27 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -31,8 +31,9 @@ RSpec.configure do |config| config.include ActiveSupport::Testing::TimeHelpers config.include Requests::SessionHelpers, type: :request config.include Features::SessionHelpers, type: :feature + config.include AbstractController::Translation, type: :request config.include AbstractController::Translation, type: :feature - config.include Requests::EPPHelpers + config.include Requests::EPPHelpers, type: :request config.define_derived_metadata(file_path: %r[/spec/features/]) do |metadata| metadata[:db] = true if metadata[:db].nil? @@ -58,10 +59,6 @@ RSpec.configure do |config| metadata[:type] = :request end - config.define_derived_metadata(file_path: %r[/spec/requests/epp/]) do |metadata| - metadata[:epp] = true if metadata[:epp].nil? - end - config.use_transactional_fixtures = false config.infer_spec_type_from_file_location!