mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 22:54:47 +02:00
parent
e84a1dc0de
commit
4ab6821d8a
9 changed files with 236 additions and 78 deletions
11
test/fixtures/contacts.yml
vendored
11
test/fixtures/contacts.yml
vendored
|
@ -9,6 +9,17 @@ john:
|
|||
code: john-001
|
||||
auth_info: cacb5b
|
||||
|
||||
william:
|
||||
name: William
|
||||
email: william@inbox.test
|
||||
phone: '+555.555'
|
||||
ident: 1234
|
||||
ident_type: priv
|
||||
ident_country_code: US
|
||||
registrar: bestnames
|
||||
code: william-001
|
||||
auth_info: 6573d0
|
||||
|
||||
jane:
|
||||
name: Jane
|
||||
email: jane@mail.test
|
||||
|
|
5
test/fixtures/domain_contacts.yml
vendored
5
test/fixtures/domain_contacts.yml
vendored
|
@ -3,6 +3,11 @@ shop_jane:
|
|||
contact: jane
|
||||
type: AdminDomainContact
|
||||
|
||||
shop_william:
|
||||
domain: shop
|
||||
contact: william
|
||||
type: TechDomainContact
|
||||
|
||||
airport_john:
|
||||
domain: airport
|
||||
contact: john
|
||||
|
|
7
test/fixtures/domain_transfers.yml
vendored
Normal file
7
test/fixtures/domain_transfers.yml
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
shop:
|
||||
status: serverApproved
|
||||
transfer_requested_at: 2010-07-05
|
||||
transferred_at: 2010-07-05
|
||||
domain: shop
|
||||
old_registrar: bestnames
|
||||
new_registrar: goodnames
|
|
@ -1,11 +1,12 @@
|
|||
require 'test_helper'
|
||||
|
||||
class APIDomainTransfersTest < ActionDispatch::IntegrationTest
|
||||
def test_transfers_domain
|
||||
request_params = { format: :json,
|
||||
data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } }
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
def test_returns_domain_transfers
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_equal registrars(:goodnames), domains(:shop).registrar
|
||||
assert_response 200
|
||||
assert_equal ({ data: [{
|
||||
type: 'domain_transfer'
|
||||
|
@ -13,6 +14,39 @@ class APIDomainTransfersTest < ActionDispatch::IntegrationTest
|
|||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_approves_automatically
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert @domain.domain_transfers.last.approved?
|
||||
end
|
||||
|
||||
def test_changes_registrar
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
@domain.reload
|
||||
assert_equal registrars(:goodnames), @domain.registrar
|
||||
end
|
||||
|
||||
def test_regenerates_transfer_code
|
||||
@old_transfer_code = @domain.transfer_code
|
||||
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
@domain.reload
|
||||
refute_equal @domain.transfer_code, @old_transfer_code
|
||||
end
|
||||
|
||||
def test_notifies_old_registrar
|
||||
@old_registrar = @domain.registrar
|
||||
|
||||
assert_difference -> { @old_registrar.messages.count } do
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
end
|
||||
end
|
||||
|
||||
def test_creates_copy_of_registrant_admin_and_tech_contacts
|
||||
assert_difference 'Contact.count', 3 do
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
end
|
||||
end
|
||||
|
||||
def test_fails_if_domain_does_not_exist
|
||||
request_params = { format: :json,
|
||||
data: { domainTransfers: [{ domainName: 'non-existent.test', transferCode: 'any' }] } }
|
||||
|
@ -27,13 +61,18 @@ class APIDomainTransfersTest < ActionDispatch::IntegrationTest
|
|||
data: { domainTransfers: [{ domainName: 'shop.test', transferCode: 'wrong' }] } }
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response 400
|
||||
refute_equal registrars(:goodnames), domains(:shop).registrar
|
||||
refute_equal registrars(:goodnames), @domain.registrar
|
||||
assert_equal ({ errors: [{ title: 'shop.test transfer code is wrong' }] }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def request_params
|
||||
{ format: :json,
|
||||
data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } }
|
||||
end
|
||||
|
||||
def http_auth_key
|
||||
ActionController::HttpAuthentication::Basic.encode_credentials('test_goodnames', 'testtest')
|
||||
end
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainTransferTransferCodeTest < ActionDispatch::IntegrationTest
|
||||
def test_wrong
|
||||
class EppDomainTransferBaseTest < ActionDispatch::IntegrationTest
|
||||
def test_non_existent_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>shop.test</domain:name>
|
||||
<domain:name>non-existent.test</domain:name>
|
||||
<domain:authInfo>
|
||||
<domain:pw>wrong</domain:pw>
|
||||
<domain:pw>any</domain:pw>
|
||||
</domain:authInfo>
|
||||
</domain:transfer>
|
||||
</transfer>
|
||||
|
@ -19,7 +19,6 @@ class EppDomainTransferTransferCodeTest < ActionDispatch::IntegrationTest
|
|||
XML
|
||||
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
refute_equal registrars(:goodnames), domains(:shop).registrar
|
||||
assert_equal '2201', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_equal '2303', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
end
|
||||
end
|
|
@ -1,49 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainTransferTest < ActionDispatch::IntegrationTest
|
||||
def test_transfers_domain_at_once_if_auto_confirm_is_enabled
|
||||
Setting.transfer_wait_time = 0
|
||||
|
||||
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>65078d5</domain:pw>
|
||||
</domain:authInfo>
|
||||
</domain:transfer>
|
||||
</transfer>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
assert_equal registrars(:goodnames), domains(:shop).registrar
|
||||
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
end
|
||||
|
||||
def test_non_existent_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>non-existent.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_goodnames' }
|
||||
assert_equal '2303', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
end
|
||||
end
|
74
test/integration/epp/domain/transfer/query_test.rb
Normal file
74
test/integration/epp/domain/transfer/query_test.rb
Normal file
|
@ -0,0 +1,74 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainTransferQueryTest < ActionDispatch::IntegrationTest
|
||||
def test_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">
|
||||
<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>65078d5</domain:pw>
|
||||
</domain:authInfo>
|
||||
</domain:transfer>
|
||||
</transfer>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
xml_doc = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', xml_doc.at_css('result')[:code]
|
||||
assert_equal 1, xml_doc.css('result').size
|
||||
assert_equal 'shop.test', xml_doc.xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
assert_equal 'serverApproved', xml_doc.xpath('//domain:trStatus', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
assert_equal 'goodnames', xml_doc.xpath('//domain:reID', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
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
|
||||
|
||||
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>65078d5</domain:pw>
|
||||
</domain:authInfo>
|
||||
</domain:transfer>
|
||||
</transfer>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_equal '2303', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
end
|
||||
end
|
90
test/integration/epp/domain/transfer/request_test.rb
Normal file
90
test/integration/epp/domain/transfer/request_test.rb
Normal file
|
@ -0,0 +1,90 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainTransferRequestTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
Setting.transfer_wait_time = 0
|
||||
end
|
||||
|
||||
def test_transfers_domain_at_once_if_auto_approval_is_enabled
|
||||
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
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
assert @domain.domain_transfers.last.approved?
|
||||
end
|
||||
|
||||
def test_changes_registrar
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
@domain.reload
|
||||
assert_equal registrars(:goodnames), @domain.registrar
|
||||
end
|
||||
|
||||
def test_regenerates_transfer_code
|
||||
@old_transfer_code = @domain.transfer_code
|
||||
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
|
||||
@domain.reload
|
||||
refute_equal @domain.transfer_code, @old_transfer_code
|
||||
end
|
||||
|
||||
def test_notifies_old_registrar
|
||||
@old_registrar = @domain.registrar
|
||||
|
||||
assert_difference -> { @old_registrar.messages.count } do
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
end
|
||||
end
|
||||
|
||||
def test_creates_copy_of_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]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def 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>65078d5</domain:pw>
|
||||
</domain:authInfo>
|
||||
</domain:transfer>
|
||||
</transfer>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
end
|
||||
end
|
|
@ -46,24 +46,6 @@ class DomainTransferTest < ActiveSupport::TestCase
|
|||
refute_same old_transfer_code, @domain.transfer_code
|
||||
end
|
||||
|
||||
def test_creates_domain_transfer
|
||||
assert_difference 'DomainTransfer.count' do
|
||||
@domain.transfer(@new_registrar)
|
||||
end
|
||||
end
|
||||
|
||||
def test_notifies_old_registrar
|
||||
assert_difference 'Message.count' do
|
||||
@domain.transfer(@new_registrar)
|
||||
end
|
||||
end
|
||||
|
||||
def test_copies_contacts
|
||||
assert_difference 'Contact.count', 2 do
|
||||
@domain.transfer(@new_registrar)
|
||||
end
|
||||
end
|
||||
|
||||
def test_bypasses_domain_validation
|
||||
domain = domains(:invalid)
|
||||
domain.transfer(@new_registrar)
|
Loading…
Add table
Add a link
Reference in a new issue