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