diff --git a/spec/requests/epp/contact/create/ident_spec.rb b/spec/requests/epp/contact/create/ident_spec.rb index e112e2618..cdf457002 100644 --- a/spec/requests/epp/contact/create/ident_spec.rb +++ b/spec/requests/epp/contact/create/ident_spec.rb @@ -1,11 +1,14 @@ require 'rails_helper' RSpec.describe 'EPP contact:create' do - let(:request) { post '/epp/command/create', frame: request_xml } + let(:registrar) { create(:registrar) } + let(:user) { create(:api_user_epp, registrar: registrar) } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } before do Setting.address_processing = false - sign_in_to_epp_area + login_as user end context 'when all ident params are valid' do diff --git a/spec/requests/epp/contact/create/phone_spec.rb b/spec/requests/epp/contact/create/phone_spec.rb index dd205de87..3c7796659 100644 --- a/spec/requests/epp/contact/create/phone_spec.rb +++ b/spec/requests/epp/contact/create/phone_spec.rb @@ -2,7 +2,10 @@ require 'rails_helper' require_relative '../shared/phone' RSpec.describe 'EPP contact:create' do - let(:request) { post '/epp/command/create', frame: request_xml } + let(:registrar) { create(:registrar) } + let(:user) { create(:api_user_epp, registrar: registrar) } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let(:request_xml) { <<-XML @@ -27,7 +30,7 @@ RSpec.describe 'EPP contact:create' do } before do - sign_in_to_epp_area + login_as user allow(Contact).to receive(:address_processing?).and_return(false) end diff --git a/spec/requests/epp/contact/create_spec.rb b/spec/requests/epp/contact/create_spec.rb index 0f03fd6ac..8b4b14794 100644 --- a/spec/requests/epp/contact/create_spec.rb +++ b/spec/requests/epp/contact/create_spec.rb @@ -1,6 +1,9 @@ require 'rails_helper' RSpec.describe 'EPP contact:create' do + let(:registrar) { create(:registrar) } + let(:user) { create(:api_user_epp, registrar: registrar) } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } let(:request_xml_with_address) { ' @@ -36,7 +39,7 @@ RSpec.describe 'EPP contact:create' do subject(:address_saved) { Contact.last.attributes.slice(*Contact.address_attribute_names).compact.any? } before do - sign_in_to_epp_area + login_as user end context 'when address processing is enabled' do @@ -46,17 +49,17 @@ RSpec.describe 'EPP contact:create' do context 'with address' do it 'returns epp code of 1000' do - post '/epp/command/create', frame: request_xml_with_address + post '/epp/command/create', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_code).to eq('1000') end it 'returns epp description' do - post '/epp/command/create', frame: request_xml_with_address + post '/epp/command/create', { frame: request_xml_with_address}, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_description).to eq('Command completed successfully') end it 'saves address' do - post '/epp/command/create', frame: request_xml_with_address + post '/epp/command/create', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}" expect(address_saved).to be_truthy end end @@ -69,17 +72,17 @@ RSpec.describe 'EPP contact:create' do context 'with address' do it 'returns epp code of 1100' do - post '/epp/command/create', frame: request_xml_with_address + post '/epp/command/create', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_code).to eq('1100') end it 'returns epp description' do - post '/epp/command/create', frame: request_xml_with_address + post '/epp/command/create', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_description).to eq('Command completed successfully; Postal address data discarded') end it 'does not save address' do - post '/epp/command/create', frame: request_xml_with_address + post '/epp/command/create', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}" expect(address_saved).to be_falsey end end @@ -110,12 +113,12 @@ RSpec.describe 'EPP contact:create' do } it 'returns epp code of 1000' do - post '/epp/command/create', frame: request_xml_without_address + post '/epp/command/create', { frame: request_xml_without_address }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_code).to eq('1000') end it 'returns epp description' do - post '/epp/command/create', frame: request_xml_without_address + post '/epp/command/create', { frame: request_xml_without_address }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_description).to eq('Command completed successfully') end end diff --git a/spec/requests/epp/contact/delete/used_spec.rb b/spec/requests/epp/contact/delete/used_spec.rb index f6db6b65b..e37d30173 100644 --- a/spec/requests/epp/contact/delete/used_spec.rb +++ b/spec/requests/epp/contact/delete/used_spec.rb @@ -1,10 +1,11 @@ require 'rails_helper' RSpec.describe 'EPP contact:delete' do + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } let(:user) { create(:api_user, registrar: registrar) } let(:registrar) { create(:registrar) } let!(:registrant) { create(:registrant, registrar: registrar, code: 'TEST') } - let(:request) { post '/epp/command/delete', frame: request_xml } + let(:request) { post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let(:request_xml) { <<-XML @@ -20,7 +21,7 @@ RSpec.describe 'EPP contact:delete' do } before do - sign_in_to_epp_area(user: user) + login_as user end context 'when contact is used' do diff --git a/spec/requests/epp/contact/info_spec.rb b/spec/requests/epp/contact/info_spec.rb index d97a0373e..a16a235a8 100644 --- a/spec/requests/epp/contact/info_spec.rb +++ b/spec/requests/epp/contact/info_spec.rb @@ -1,6 +1,9 @@ require 'rails_helper' RSpec.describe 'EPP contact:update' do + let(:registrar) { create(:registrar) } + let(:user) { create(:api_user_epp, registrar: registrar) } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } let(:request_xml) { ' @@ -19,7 +22,7 @@ RSpec.describe 'EPP contact:update' do .count } before do - sign_in_to_epp_area + login_as user create(:contact, code: 'TEST') end @@ -29,12 +32,12 @@ RSpec.describe 'EPP contact:update' do end it 'returns epp code of 1000' do - post '/epp/command/info', frame: request_xml + post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_code).to eq('1000') end it 'returns address' do - post '/epp/command/info', frame: request_xml + post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(address_count).to_not be_zero end end @@ -45,12 +48,12 @@ RSpec.describe 'EPP contact:update' do end it 'returns epp code of 1000' do - post '/epp/command/info', frame: request_xml + post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_code).to eq('1000') end it 'does not return address' do - post '/epp/command/info', frame: request_xml + post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(address_count).to be_zero end end diff --git a/spec/requests/epp/contact/update/ident_spec.rb b/spec/requests/epp/contact/update/ident_spec.rb index c93ba6390..ec25d1c8c 100644 --- a/spec/requests/epp/contact/update/ident_spec.rb +++ b/spec/requests/epp/contact/update/ident_spec.rb @@ -3,8 +3,11 @@ require 'rails_helper' # https://github.com/internetee/registry/issues/576 RSpec.describe 'EPP contact:update' do + let(:registrar) { create(:registrar) } + let(:user) { create(:api_user_epp, registrar: registrar) } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } let(:ident) { contact.identifier } - let(:request) { post '/epp/command/update', frame: request_xml } + let(:request) { post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let(:request_xml) { <<-XML @@ -30,7 +33,7 @@ RSpec.describe 'EPP contact:update' do } before do - sign_in_to_epp_area + login_as user end context 'when contact ident is valid' do diff --git a/spec/requests/epp/contact/update/phone_spec.rb b/spec/requests/epp/contact/update/phone_spec.rb index 452b80c5c..696725ab4 100644 --- a/spec/requests/epp/contact/update/phone_spec.rb +++ b/spec/requests/epp/contact/update/phone_spec.rb @@ -2,8 +2,11 @@ require 'rails_helper' require_relative '../shared/phone' RSpec.describe 'EPP contact:update' do + let(:registrar) { create(:registrar) } + let(:user) { create(:api_user_epp, registrar: registrar) } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } let!(:contact) { create(:contact, code: 'TEST') } - let(:request) { post '/epp/command/update', frame: request_xml } + let(:request) { post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let(:request_xml) { <<-XML @@ -22,7 +25,7 @@ RSpec.describe 'EPP contact:update' do } before do - sign_in_to_epp_area + login_as user allow(Contact).to receive(:address_processing?).and_return(false) end diff --git a/spec/requests/epp/contact/update_spec.rb b/spec/requests/epp/contact/update_spec.rb index a8be4c85d..3d40e8699 100644 --- a/spec/requests/epp/contact/update_spec.rb +++ b/spec/requests/epp/contact/update_spec.rb @@ -1,6 +1,9 @@ require 'rails_helper' RSpec.describe 'EPP contact:update' do + let(:registrar) { create(:registrar) } + let(:user) { create(:api_user_epp, registrar: registrar) } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } let(:request_xml_with_address) { ' @@ -33,7 +36,7 @@ RSpec.describe 'EPP contact:update' do subject(:response_description) { response_xml.css('result msg').text } before do - sign_in_to_epp_area + login_as user create(:contact, code: 'TEST') end @@ -44,12 +47,12 @@ RSpec.describe 'EPP contact:update' do context 'with address' do it 'returns epp code of 1000' do - post '/epp/command/update', frame: request_xml_with_address + post '/epp/command/update', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_code).to eq('1000') end it 'returns epp description' do - post '/epp/command/update', frame: request_xml_with_address + post '/epp/command/update', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_description).to eq('Command completed successfully') end end @@ -62,12 +65,12 @@ RSpec.describe 'EPP contact:update' do context 'with address' do it 'returns epp code of 1100' do - post '/epp/command/update', frame: request_xml_with_address + post '/epp/command/update', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_code).to eq('1100') end it 'returns epp description' do - post '/epp/command/update', frame: request_xml_with_address + post '/epp/command/update', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_description).to eq('Command completed successfully; Postal address data discarded') end end @@ -92,12 +95,12 @@ RSpec.describe 'EPP contact:update' do } it 'returns epp code of 1000' do - post '/epp/command/update', frame: request_xml_without_address + post '/epp/command/update', { frame: request_xml_without_address }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_code).to eq('1000') end it 'returns epp description' do - post '/epp/command/update', frame: request_xml_without_address + post '/epp/command/update', { frame: request_xml_without_address }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_description).to eq('Command completed successfully') end end diff --git a/spec/requests/epp/domain/create/account_balance_spec.rb b/spec/requests/epp/domain/create/account_balance_spec.rb index 9c3905801..43edae1aa 100644 --- a/spec/requests/epp/domain/create/account_balance_spec.rb +++ b/spec/requests/epp/domain/create/account_balance_spec.rb @@ -1,7 +1,8 @@ require 'rails_helper' RSpec.describe 'EPP domain:create', settings: false do - let(:request) { post '/epp/command/create', frame: request_xml } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let!(:user) { create(:api_user_epp, registrar: registrar) } let!(:contact) { create(:contact, code: 'test') } let!(:zone) { create(:zone, origin: 'test') } @@ -36,7 +37,7 @@ RSpec.describe 'EPP domain:create', settings: false do before :example do travel_to Time.zone.parse('05.07.2010') Setting.days_to_renew_domain_before_expire = 0 - sign_in_to_epp_area(user: user) + login_as user end context 'when account balance is sufficient' do diff --git a/spec/requests/epp/domain/create/default_period_spec.rb b/spec/requests/epp/domain/create/default_period_spec.rb index 05a1ab73a..fd807bef0 100644 --- a/spec/requests/epp/domain/create/default_period_spec.rb +++ b/spec/requests/epp/domain/create/default_period_spec.rb @@ -1,7 +1,8 @@ require 'rails_helper' RSpec.describe 'EPP domain:create', settings: false do - let(:request) { post '/epp/command/create', frame: request_xml } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let!(:user) { create(:api_user_epp, registrar: registrar) } let!(:contact) { create(:contact, code: 'test') } let!(:zone) { create(:zone, origin: 'test') } @@ -37,7 +38,7 @@ RSpec.describe 'EPP domain:create', settings: false do before :example do travel_to Time.zone.parse('05.07.2010 10:30') Setting.days_to_renew_domain_before_expire = 0 - sign_in_to_epp_area(user: user) + login_as user end context 'when period is absent' do diff --git a/spec/requests/epp/domain/create/optional_nameserver_spec.rb b/spec/requests/epp/domain/create/optional_nameserver_spec.rb index bf1550268..83ab1df44 100644 --- a/spec/requests/epp/domain/create/optional_nameserver_spec.rb +++ b/spec/requests/epp/domain/create/optional_nameserver_spec.rb @@ -1,7 +1,8 @@ require 'rails_helper' RSpec.describe 'EPP domain:create', settings: false do - let(:request) { post '/epp/command/create', frame: request_xml } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let!(:registrar) { create(:registrar_with_unlimited_balance) } let!(:user) { create(:api_user_epp, registrar: registrar) } let!(:contact) { create(:contact, code: 'test') } @@ -17,7 +18,7 @@ RSpec.describe 'EPP domain:create', settings: false do before :example do travel_to Time.zone.parse('05.07.2010') - sign_in_to_epp_area(user: user) + login_as user end context 'when nameserver is optional' do diff --git a/spec/requests/epp/domain/create/period_spec.rb b/spec/requests/epp/domain/create/period_spec.rb index 355ef7557..f9550002e 100644 --- a/spec/requests/epp/domain/create/period_spec.rb +++ b/spec/requests/epp/domain/create/period_spec.rb @@ -1,7 +1,8 @@ require 'rails_helper' RSpec.describe 'EPP domain:create', settings: false do - let(:request) { post '/epp/command/create', frame: request_xml } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let!(:user) { create(:api_user_epp, registrar: registrar) } let!(:contact) { create(:contact, code: 'test') } let!(:zone) { create(:zone, origin: 'test') } @@ -10,7 +11,7 @@ RSpec.describe 'EPP domain:create', settings: false do before :example do travel_to Time.zone.parse('05.07.2010 10:30') Setting.days_to_renew_domain_before_expire = 0 - sign_in_to_epp_area(user: user) + login_as user end context 'when period is 3 months' do diff --git a/spec/requests/epp/domain/create/price_spec.rb b/spec/requests/epp/domain/create/price_spec.rb index 69439bb41..2b2aa789e 100644 --- a/spec/requests/epp/domain/create/price_spec.rb +++ b/spec/requests/epp/domain/create/price_spec.rb @@ -1,7 +1,8 @@ require 'rails_helper' RSpec.describe 'EPP domain:create', settings: false do - let(:request) { post '/epp/command/create', frame: request_xml } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let!(:user) { create(:api_user_epp, registrar: registrar) } let!(:contact) { create(:contact, code: 'test') } let!(:zone) { create(:zone, origin: 'test') } @@ -30,7 +31,7 @@ RSpec.describe 'EPP domain:create', settings: false do before :example do travel_to Time.zone.parse('05.07.2010') Setting.days_to_renew_domain_before_expire = 0 - sign_in_to_epp_area(user: user) + login_as user end context 'when price is present' do diff --git a/spec/requests/epp/domain/create/required_nameserver_spec.rb b/spec/requests/epp/domain/create/required_nameserver_spec.rb index 11b49aede..3c72c58a5 100644 --- a/spec/requests/epp/domain/create/required_nameserver_spec.rb +++ b/spec/requests/epp/domain/create/required_nameserver_spec.rb @@ -1,7 +1,8 @@ require 'rails_helper' RSpec.describe 'EPP domain:create', settings: false do - let(:request) { post '/epp/command/create', frame: request_xml } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let!(:registrar) { create(:registrar_with_unlimited_balance) } let!(:user) { create(:api_user_epp, registrar: registrar) } let!(:contact) { create(:contact, code: 'test') } @@ -17,7 +18,7 @@ RSpec.describe 'EPP domain:create', settings: false do before :example do travel_to Time.zone.parse('05.07.2010') - sign_in_to_epp_area(user: user) + login_as user end context 'when nameserver is required' do diff --git a/spec/requests/epp/domain/delete/discarded_spec.rb b/spec/requests/epp/domain/delete/discarded_spec.rb index 99ec59267..1cce794bc 100644 --- a/spec/requests/epp/domain/delete/discarded_spec.rb +++ b/spec/requests/epp/domain/delete/discarded_spec.rb @@ -1,6 +1,9 @@ require 'rails_helper' RSpec.describe 'EPP domain:delete' do + let(:registrar) { create(:registrar) } + let(:user) { create(:api_user_epp, registrar: registrar) } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } let(:request_xml) { <<-XML @@ -21,14 +24,14 @@ RSpec.describe 'EPP domain:delete' do } before :example do - sign_in_to_epp_area + login_as user end context 'when domain is not discarded' do let!(:domain) { create(:domain, name: 'test.com') } it 'returns epp code of 1001' do - post '/epp/command/delete', frame: request_xml + post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response).to have_code_of(1001) end end @@ -37,7 +40,7 @@ RSpec.describe 'EPP domain:delete' do let!(:domain) { create(:domain_discarded, name: 'test.com') } it 'returns epp code of 2105' do - post '/epp/command/delete', frame: request_xml + post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response).to have_code_of(2105) end end diff --git a/spec/requests/epp/domain/renew/account_balance_spec.rb b/spec/requests/epp/domain/renew/account_balance_spec.rb index 39f9eac02..128c60070 100644 --- a/spec/requests/epp/domain/renew/account_balance_spec.rb +++ b/spec/requests/epp/domain/renew/account_balance_spec.rb @@ -1,7 +1,8 @@ require 'rails_helper' RSpec.describe 'EPP domain:renew' do - let(:request) { post '/epp/command/renew', frame: request_xml } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let!(:user) { create(:api_user_epp, registrar: registrar) } let!(:zone) { create(:zone, origin: 'test') } let!(:price) { create(:price, @@ -16,7 +17,7 @@ RSpec.describe 'EPP domain:renew' do before :example do Setting.days_to_renew_domain_before_expire = 0 travel_to Time.zone.parse('05.07.2010') - sign_in_to_epp_area(user: user) + login_as user end context 'when account balance is sufficient' do diff --git a/spec/requests/epp/domain/renew/default_period_spec.rb b/spec/requests/epp/domain/renew/default_period_spec.rb index 70ab2d58d..2f09acbcc 100644 --- a/spec/requests/epp/domain/renew/default_period_spec.rb +++ b/spec/requests/epp/domain/renew/default_period_spec.rb @@ -1,7 +1,8 @@ require 'rails_helper' RSpec.describe 'EPP domain:renew', settings: false do - let(:request) { post '/epp/command/renew', frame: request_xml } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let!(:user) { create(:api_user_epp, registrar: registrar) } let!(:zone) { create(:zone, origin: 'test') } let!(:registrar) { create(:registrar_with_unlimited_balance) } @@ -37,7 +38,7 @@ RSpec.describe 'EPP domain:renew', settings: false do before :example do travel_to Time.zone.parse('05.07.2010') Setting.days_to_renew_domain_before_expire = 0 - sign_in_to_epp_area(user: user) + login_as user end context 'when period is absent' do diff --git a/spec/requests/epp/domain/renew/expire_time_spec.rb b/spec/requests/epp/domain/renew/expire_time_spec.rb index e656249ab..90cad850e 100644 --- a/spec/requests/epp/domain/renew/expire_time_spec.rb +++ b/spec/requests/epp/domain/renew/expire_time_spec.rb @@ -1,7 +1,8 @@ require 'rails_helper' RSpec.describe 'EPP domain:renew' do - let(:request) { post '/epp/command/renew', frame: request_xml } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let!(:user) { create(:api_user_epp, registrar: registrar) } let!(:registrar) { create(:registrar_with_unlimited_balance) } let!(:zone) { create(:zone, origin: 'test') } @@ -17,7 +18,7 @@ RSpec.describe 'EPP domain:renew' do before :example do Setting.days_to_renew_domain_before_expire = 0 travel_to Time.zone.parse('05.07.2010') - sign_in_to_epp_area(user: user) + login_as user end context 'when given expire time and current match' do diff --git a/spec/requests/epp/domain/renew/max_expire_time_spec.rb b/spec/requests/epp/domain/renew/max_expire_time_spec.rb index 2a9a0c52c..211af8685 100644 --- a/spec/requests/epp/domain/renew/max_expire_time_spec.rb +++ b/spec/requests/epp/domain/renew/max_expire_time_spec.rb @@ -1,6 +1,7 @@ require 'rails_helper' RSpec.describe 'EPP domain:renew' do + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } let(:user) { create(:api_user_epp, registrar: registrar) } let(:registrar) { create(:registrar_with_unlimited_balance) } let!(:zone) { create(:zone, origin: 'test') } @@ -19,7 +20,7 @@ RSpec.describe 'EPP domain:renew' do before :example do travel_to Time.zone.parse('05.07.2010') Setting.days_to_renew_domain_before_expire = 0 - sign_in_to_epp_area(user: user) + login_as user end context 'when domain can be renewed' do @@ -45,12 +46,12 @@ RSpec.describe 'EPP domain:renew' do } it 'returns epp code of 1000' do - post '/epp/command/renew', frame: request_xml + post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_code).to eq('1000') end it 'returns epp description' do - post '/epp/command/renew', frame: request_xml + post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_description).to eq('Command completed successfully') end end @@ -78,12 +79,12 @@ RSpec.describe 'EPP domain:renew' do } it 'returns epp code of 2105' do - post '/epp/command/renew', frame: request_xml + post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_code).to eq('2105') end it 'returns epp description' do - post '/epp/command/renew', frame: request_xml + post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_description).to eq('Object is not eligible for renewal; ' \ 'Expiration date must be before 2021-07-05') end diff --git a/spec/requests/epp/domain/renew/period_spec.rb b/spec/requests/epp/domain/renew/period_spec.rb index 3523927eb..6c5167d26 100644 --- a/spec/requests/epp/domain/renew/period_spec.rb +++ b/spec/requests/epp/domain/renew/period_spec.rb @@ -1,7 +1,8 @@ require 'rails_helper' RSpec.describe 'EPP domain:renew', settings: false do - let(:request) { post '/epp/command/renew', frame: request_xml } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let!(:user) { create(:api_user_epp, registrar: registrar) } let!(:zone) { create(:zone, origin: 'test') } let!(:registrar) { create(:registrar_with_unlimited_balance) } @@ -14,7 +15,7 @@ RSpec.describe 'EPP domain:renew', settings: false do before :example do travel_to Time.zone.parse('05.07.2010') Setting.days_to_renew_domain_before_expire = 0 - sign_in_to_epp_area(user: user) + login_as user end context 'when period is 3 months' do diff --git a/spec/requests/epp/domain/renew/price_spec.rb b/spec/requests/epp/domain/renew/price_spec.rb index 3b5139103..4a9c65ff3 100644 --- a/spec/requests/epp/domain/renew/price_spec.rb +++ b/spec/requests/epp/domain/renew/price_spec.rb @@ -1,7 +1,8 @@ require 'rails_helper' RSpec.describe 'EPP domain:renew', settings: false do - let(:request) { post '/epp/command/renew', frame: request_xml } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let!(:user) { create(:api_user_epp, registrar: registrar) } let!(:zone) { create(:zone, origin: 'test') } let!(:registrar) { create(:registrar_with_unlimited_balance) } @@ -29,7 +30,7 @@ RSpec.describe 'EPP domain:renew', settings: false do before :example do travel_to Time.zone.parse('05.07.2010') Setting.days_to_renew_domain_before_expire = 0 - sign_in_to_epp_area(user: user) + login_as user end context 'when price is present' do diff --git a/spec/requests/epp/domain/transfer/discarded_spec.rb b/spec/requests/epp/domain/transfer/discarded_spec.rb index 51f65c641..d279bf003 100644 --- a/spec/requests/epp/domain/transfer/discarded_spec.rb +++ b/spec/requests/epp/domain/transfer/discarded_spec.rb @@ -1,6 +1,9 @@ require 'rails_helper' RSpec.describe 'EPP domain:transfer' do + let(:registrar) { create(:registrar) } + let(:user) { create(:api_user_epp, registrar: registrar) } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } let(:request_xml) { <<-XML @@ -19,14 +22,14 @@ RSpec.describe 'EPP domain:transfer' do } before :example do - sign_in_to_epp_area + login_as user end context 'when domain is not discarded' do let!(:domain) { create(:domain, name: 'test.com') } it 'returns epp code of 1000' do - post '/epp/command/transfer', frame: request_xml + post '/epp/command/transfer', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response).to have_code_of(1000) end end @@ -35,7 +38,7 @@ RSpec.describe 'EPP domain:transfer' do let!(:domain) { create(:domain_discarded, name: 'test.com') } it 'returns epp code of 2105' do - post '/epp/command/transfer', frame: request_xml + post '/epp/command/transfer', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response).to have_code_of(2105) end end diff --git a/spec/requests/epp/domain/update/discarded_spec.rb b/spec/requests/epp/domain/update/discarded_spec.rb index 14ff1c743..29ae1f44c 100644 --- a/spec/requests/epp/domain/update/discarded_spec.rb +++ b/spec/requests/epp/domain/update/discarded_spec.rb @@ -1,6 +1,9 @@ require 'rails_helper' RSpec.describe 'EPP domain:update' do + let(:registrar) { create(:registrar) } + let(:user) { create(:api_user_epp, registrar: registrar) } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } let(:request_xml) { <<-XML @@ -16,14 +19,14 @@ RSpec.describe 'EPP domain:update' do } before :example do - sign_in_to_epp_area + login_as user end context 'when domain is not discarded' do let!(:domain) { create(:domain, name: 'test.com') } it 'returns epp code of 1000' do - post '/epp/command/update', frame: request_xml + post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response).to have_code_of(1000) end end @@ -32,7 +35,7 @@ RSpec.describe 'EPP domain:update' do let!(:domain) { create(:domain_discarded, name: 'test.com') } it 'returns epp code of 2105' do - post '/epp/command/update', frame: request_xml + post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response).to have_code_of(2105) end end diff --git a/spec/requests/epp/domain/update/nameserver_add_spec.rb b/spec/requests/epp/domain/update/nameserver_add_spec.rb index d6f886932..8a00d585d 100644 --- a/spec/requests/epp/domain/update/nameserver_add_spec.rb +++ b/spec/requests/epp/domain/update/nameserver_add_spec.rb @@ -1,13 +1,16 @@ require 'rails_helper' RSpec.describe 'EPP domain:update' do + let(:registrar) { create(:registrar) } + let(:user) { create(:api_user_epp, registrar: registrar) } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } let!(:domain) { create(:domain, name: 'test.com') } subject(:response_xml) { Nokogiri::XML(response.body) } subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] } subject(:response_description) { response_xml.css('result msg').text } before :example do - sign_in_to_epp_area + login_as user allow(Domain).to receive(:nameserver_required?).and_return(false) Setting.ns_min_count = 2 @@ -37,12 +40,12 @@ RSpec.describe 'EPP domain:update' do } it 'returns epp code of 2308' do - post '/epp/command/update', frame: request_xml + post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_code).to eq('2308'), "Expected EPP code of 2308, got #{response_code} (#{response_description})" end it 'returns epp description' do - post '/epp/command/update', frame: request_xml + post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" description = 'Data management policy violation;' \ " Nameserver count must be between #{Setting.ns_min_count}-#{Setting.ns_max_count}" \ @@ -78,12 +81,12 @@ RSpec.describe 'EPP domain:update' do } it 'returns epp code of 1000' do - post '/epp/command/update', frame: request_xml + post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_code).to eq('1000'), "Expected EPP code of 1000, got #{response_code} (#{response_description})" end it 'removes inactive status' do - post '/epp/command/update', frame: request_xml + post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" domain = Domain.find_by(name: 'test.com') expect(domain.statuses).to_not include(DomainStatus::INACTIVE) diff --git a/spec/requests/epp/domain/update/nameserver_remove_spec.rb b/spec/requests/epp/domain/update/nameserver_remove_spec.rb index 5ecc2f29a..3796d2e12 100644 --- a/spec/requests/epp/domain/update/nameserver_remove_spec.rb +++ b/spec/requests/epp/domain/update/nameserver_remove_spec.rb @@ -1,13 +1,15 @@ require 'rails_helper' RSpec.describe 'EPP domain:update' do + let(:registrar) { create(:registrar) } + let(:user) { create(:api_user_epp, registrar: registrar) } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } subject(:response_xml) { Nokogiri::XML(response.body) } subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] } subject(:response_description) { response_xml.css('result msg').text } before :example do - sign_in_to_epp_area - + login_as user allow(Domain).to receive(:nameserver_required?).and_return(false) end @@ -43,12 +45,12 @@ RSpec.describe 'EPP domain:update' do end it 'returns epp code of 2308' do - post '/epp/command/update', frame: request_xml + post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_code).to eq('2308'), "Expected EPP code of 2308, got #{response_code} (#{response_description})" end it 'returns epp description' do - post '/epp/command/update', frame: request_xml + post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" description = 'Data management policy violation;' \ " Nameserver count must be between #{Setting.ns_min_count}-#{Setting.ns_max_count}" \ @@ -91,13 +93,13 @@ RSpec.describe 'EPP domain:update' do end it 'returns epp code of 1000' do - post '/epp/command/update', frame: request_xml + post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" expect(response_code).to eq('1000'), "Expected EPP code of 1000, got #{response_code} (#{response_description})" end describe 'domain' do it 'has status of inactive' do - post '/epp/command/update', frame: request_xml + post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" domain = Domain.find_by(name: 'test.com') expect(domain.statuses).to include(DomainStatus::INACTIVE) end diff --git a/spec/requests/epp/domain/update/registrant_change/same_as_current_spec.rb b/spec/requests/epp/domain/update/registrant_change/same_as_current_spec.rb index d929423aa..1c0c8eb5b 100644 --- a/spec/requests/epp/domain/update/registrant_change/same_as_current_spec.rb +++ b/spec/requests/epp/domain/update/registrant_change/same_as_current_spec.rb @@ -1,11 +1,14 @@ require 'rails_helper' RSpec.describe 'EPP domain:update' do - let(:request) { post '/epp/command/update', frame: request_xml } + let(:registrar) { create(:registrar) } + let(:user) { create(:api_user_epp, registrar: registrar) } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let!(:domain) { create(:domain, name: 'test.com', registrant: registrant) } before :example do - sign_in_to_epp_area + login_as user end context 'when registrant change confirmation is enabled' do diff --git a/spec/requests/epp/domain/update/registrant_change/verified_spec.rb b/spec/requests/epp/domain/update/registrant_change/verified_spec.rb index 996fffccf..e94923644 100644 --- a/spec/requests/epp/domain/update/registrant_change/verified_spec.rb +++ b/spec/requests/epp/domain/update/registrant_change/verified_spec.rb @@ -1,13 +1,16 @@ require 'rails_helper' RSpec.describe 'EPP domain:update' do - let(:request) { post '/epp/command/update', frame: request_xml } + let(:registrar) { create(:registrar) } + let(:user) { create(:api_user_epp, registrar: registrar) } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } 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 + login_as user end context 'when registrant change confirmation is enabled' do diff --git a/spec/requests/epp/domain/update/status_spec.rb b/spec/requests/epp/domain/update/status_spec.rb index 1ef8d7900..df5506fb6 100644 --- a/spec/requests/epp/domain/update/status_spec.rb +++ b/spec/requests/epp/domain/update/status_spec.rb @@ -1,7 +1,10 @@ require 'rails_helper' RSpec.describe 'EPP domain:update' do - let(:request) { post '/epp/command/update', frame: request_xml } + let(:registrar) { create(:registrar) } + let(:user) { create(:api_user_epp, registrar: registrar) } + let(:session_id) { create(:epp_session, user: user, registrar: registrar).session_id } + let(:request) { post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" } let(:request_xml) { <<-XML @@ -17,7 +20,7 @@ RSpec.describe 'EPP domain:update' do } before :example do - sign_in_to_epp_area + login_as user end context 'when domain has both SERVER_DELETE_PROHIBITED and PENDING_UPDATE statuses' do