Convert spec to test

#694
This commit is contained in:
Artur Beljajev 2018-02-19 02:21:47 +02:00
parent 36f65a267c
commit 1ba274764d
3 changed files with 32 additions and 45 deletions

View file

@ -1,45 +0,0 @@
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).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">
<command>
<transfer op="request">
<domain:transfer xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>test.com</domain:name>
<domain:authInfo>
<domain:pw>98oiewslkfkd</domain:pw>
</domain:authInfo>
</domain:transfer>
</transfer>
</command>
</epp>
XML
}
before :example do
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 }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response).to have_code_of(1000)
end
end
context 'when domain is discarded' do
let!(:domain) { create(:domain_discarded, name: 'test.com') }
it 'returns epp code of 2105' do
post '/epp/command/transfer', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response).to have_code_of(2105)
end
end
end

View file

@ -37,6 +37,15 @@ non_transferable:
statuses:
- serverTransferProhibited
discarded:
name: discarded.test
transfer_code: any
valid_to: 2010-07-05
registrar: bestnames
registrant: john
statuses:
- deleteCandidate
invalid:
name: invalid.test
transfer_code: any

View file

@ -53,6 +53,29 @@ class EppDomainTransferRequestTest < ActionDispatch::IntegrationTest
end
end
def test_discarded_domain
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<transfer op="request">
<domain:transfer xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>discarded.test</domain:name>
<domain:authInfo>
<domain:pw>any</domain:pw>
</domain:authInfo>
</domain:transfer>
</transfer>
</command>
</epp>
XML
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_equal registrars(:bestnames), @domain.registrar
assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
end
def test_wrong_transfer_code
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>