Fix EPP login in specs

#700
This commit is contained in:
Artur Beljajev 2018-02-07 08:46:55 +02:00
parent ad1f5e6144
commit 278ae07ac6
28 changed files with 141 additions and 84 deletions

View file

@ -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

View file

@ -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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -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

View file

@ -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) { '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
@ -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

View file

@ -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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -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

View file

@ -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) { '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
@ -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

View file

@ -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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -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

View file

@ -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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -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

View file

@ -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) { '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -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

View file

@ -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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -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

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -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