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