Improve tests

#694
This commit is contained in:
Artur Beljajev 2018-02-19 00:56:17 +02:00
parent b16f931e9c
commit fec617aa7d
3 changed files with 38 additions and 46 deletions

View file

@ -1,6 +1,29 @@
require 'test_helper'
class EppDomainTransferBaseTest < ActionDispatch::IntegrationTest
def test_does_not_transfer_if_transfer_code_is_wrong
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="query">
<domain:transfer xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>shop.test</domain:name>
<domain:authInfo>
<domain:pw>wrong</domain:pw>
</domain:authInfo>
</domain:transfer>
</transfer>
</command>
</epp>
XML
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
domains(:shop).reload
assert_equal registrars(:bestnames), domains(:shop).registrar
assert_equal '2201', Nokogiri::XML(response.body).at_css('result')[:code]
end
def test_non_existent_domain
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>

View file

@ -1,7 +1,7 @@
require 'test_helper'
class EppDomainTransferQueryTest < ActionDispatch::IntegrationTest
def test_domain_transfer_details
def test_returns_domain_transfer_details
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -28,27 +28,6 @@ class EppDomainTransferQueryTest < ActionDispatch::IntegrationTest
assert_equal 'bestnames', xml_doc.xpath('//domain:acID', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end
def test_wrong_transfer_code
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="query">
<domain:transfer xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>shop.test</domain:name>
<domain:authInfo>
<domain:pw>wrong</domain:pw>
</domain:authInfo>
</domain:transfer>
</transfer>
</command>
</epp>
XML
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_equal '2201', Nokogiri::XML(response.body).at_css('result')[:code]
end
def test_no_domain_transfer
domains(:shop).domain_transfers.delete_all

View file

@ -6,15 +6,16 @@ class EppDomainTransferRequestTest < ActionDispatch::IntegrationTest
Setting.transfer_wait_time = 0
end
def test_transfers_domain_at_once_if_auto_approval_is_enabled
def test_transfers_domain_at_once
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
end
def test_approves_automatically
def test_approves_automatically_if_auto_approval_is_enabled
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
assert @domain.domain_transfers.last.approved?
assert_equal 'serverApproved', Nokogiri::XML(response.body).xpath('//domain:trStatus', 'domain' =>
'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end
def test_changes_registrar
@ -40,32 +41,16 @@ class EppDomainTransferRequestTest < ActionDispatch::IntegrationTest
end
end
def test_creates_copy_of_registrant_admin_and_tech_contacts
def test_duplicates_registrant_admin_and_tech_contacts
assert_difference 'Contact.count', 3 do
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
end
end
def test_wrong_transfer_code
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>shop.test</domain:name>
<domain:authInfo>
<domain:pw>wrong</domain:pw>
</domain:authInfo>
</domain:transfer>
</transfer>
</command>
</epp>
XML
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
refute_equal registrars(:goodnames), @domain.registrar
assert_equal '2201', Nokogiri::XML(response.body).at_css('result')[:code]
def test_saves_legal_document
assert_difference -> { @domain.legal_documents(true).size } do
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
end
end
private
@ -83,6 +68,11 @@ class EppDomainTransferRequestTest < ActionDispatch::IntegrationTest
</domain:authInfo>
</domain:transfer>
</transfer>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">test</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML