mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 22:54:47 +02:00
Merge branch 'master' into registry-727
This commit is contained in:
commit
1e5face668
99 changed files with 1134 additions and 566 deletions
12
test/fixtures/contacts.yml
vendored
12
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
|
||||
|
@ -34,5 +45,6 @@ acme_ltd:
|
|||
invalid:
|
||||
name: any
|
||||
code: any
|
||||
email: invalid@invalid.test
|
||||
auth_info: any
|
||||
registrar: bestnames
|
||||
|
|
15
test/fixtures/domain_contacts.yml
vendored
15
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
|
||||
|
@ -12,3 +17,13 @@ library_john:
|
|||
domain: library
|
||||
contact: john
|
||||
type: AdminDomainContact
|
||||
|
||||
invalid_invalid_admin:
|
||||
domain: invalid
|
||||
contact: invalid
|
||||
type: AdminDomainContact
|
||||
|
||||
invalid_invalid_tech:
|
||||
domain: invalid
|
||||
contact: invalid
|
||||
type: TechDomainContact
|
||||
|
|
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
|
7
test/fixtures/domains.yml
vendored
7
test/fixtures/domains.yml
vendored
|
@ -27,3 +27,10 @@ library:
|
|||
valid_to: 2010-07-05
|
||||
period: 1
|
||||
period_unit: m
|
||||
|
||||
invalid:
|
||||
name: invalid.test
|
||||
transfer_code: any
|
||||
valid_to: 2010-07-05
|
||||
registrar: bestnames
|
||||
registrant: invalid
|
||||
|
|
10
test/fixtures/epp_sessions.yml
vendored
10
test/fixtures/epp_sessions.yml
vendored
|
@ -1,9 +1,7 @@
|
|||
api_bestnames:
|
||||
session_id: 1
|
||||
registrar: bestnames
|
||||
data: <%= Base64.encode64(Marshal.dump({api_user_id: ActiveRecord::Fixtures.identify(:api_bestnames)})) %>
|
||||
session_id: api_bestnames
|
||||
user: api_bestnames
|
||||
|
||||
api_goodnames:
|
||||
session_id: 2
|
||||
registrar: goodnames
|
||||
data: <%= Base64.encode64(Marshal.dump({api_user_id: ActiveRecord::Fixtures.identify(:api_goodnames)})) %>
|
||||
session_id: api_goodnames
|
||||
user: api_goodnames
|
||||
|
|
4
test/fixtures/messages.yml
vendored
Normal file
4
test/fixtures/messages.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
greeting:
|
||||
body: Welcome!
|
||||
queued: true
|
||||
registrar: bestnames
|
|
@ -1,13 +1,57 @@
|
|||
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)
|
||||
Setting.transfer_wait_time = 0 # Auto-approval
|
||||
end
|
||||
|
||||
def test_returns_domain_transfers
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response 204
|
||||
assert_equal registrars(:goodnames), domains(:shop).registrar
|
||||
assert_empty response.body
|
||||
assert_response 200
|
||||
assert_equal ({ data: [{
|
||||
type: 'domain_transfer'
|
||||
}] }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_creates_new_domain_transfer
|
||||
assert_difference -> { @domain.transfers.size } do
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
end
|
||||
end
|
||||
|
||||
def test_approves_automatically_if_auto_approval_is_enabled
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert @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_duplicates_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
|
||||
|
@ -24,13 +68,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
|
||||
|
|
|
@ -3,7 +3,6 @@ require 'test_helper'
|
|||
class EppDomainCreateTransferCodeTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
login_as users(:api_bestnames)
|
||||
end
|
||||
|
||||
def test_generates_default
|
||||
|
@ -27,9 +26,10 @@ class EppDomainCreateTransferCodeTest < ActionDispatch::IntegrationTest
|
|||
</epp>
|
||||
XML
|
||||
|
||||
session_id = epp_sessions(:api_bestnames).session_id
|
||||
post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => "session=#{session_id}" }
|
||||
post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
refute_empty Domain.find_by(name: 'brandnew.test').transfer_code
|
||||
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
end
|
||||
|
||||
def test_honors_custom
|
||||
|
@ -56,8 +56,9 @@ class EppDomainCreateTransferCodeTest < ActionDispatch::IntegrationTest
|
|||
</epp>
|
||||
XML
|
||||
|
||||
session_id = epp_sessions(:api_bestnames).session_id
|
||||
post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => "session=#{session_id}" }
|
||||
post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_equal '1058ad73', Domain.find_by(name: 'brandnew.test').transfer_code
|
||||
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
end
|
||||
end
|
||||
|
|
28
test/integration/epp/domain/domain_delete_test.rb
Normal file
28
test/integration/epp/domain/domain_delete_test.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainDeleteTest < ActionDispatch::IntegrationTest
|
||||
def test_bypasses_domain_and_registrant_and_contacts_validation
|
||||
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>
|
||||
<delete>
|
||||
<domain:delete xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>invalid.test</domain:name>
|
||||
</domain:delete>
|
||||
</delete>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">dGVzdCBmYWlsCg==</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/delete', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_includes Domain.find_by(name: 'invalid.test').statuses, DomainStatus::PENDING_DELETE_CONFIRMATION
|
||||
assert_equal '1001', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
end
|
||||
end
|
|
@ -1,20 +1,16 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainTransferTransferCodeTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as users(:api_goodnames)
|
||||
end
|
||||
|
||||
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>
|
||||
|
@ -22,9 +18,7 @@ class EppDomainTransferTransferCodeTest < ActionDispatch::IntegrationTest
|
|||
</epp>
|
||||
XML
|
||||
|
||||
session_id = epp_sessions(:api_goodnames).session_id
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => "session=#{session_id}" }
|
||||
refute_equal registrars(:goodnames), domains(:shop).registrar
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="2201"]')
|
||||
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
|
|
@ -1,53 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainTransferTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as users(:api_goodnames)
|
||||
end
|
||||
|
||||
def test_successfully_transfers_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:authInfo>
|
||||
<domain:pw>65078d5</domain:pw>
|
||||
</domain:authInfo>
|
||||
</domain:transfer>
|
||||
</transfer>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
session_id = epp_sessions(:api_goodnames).session_id
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => "session=#{session_id}" }
|
||||
assert_equal registrars(:goodnames), domains(:shop).registrar
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="1000"]')
|
||||
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
|
||||
|
||||
session_id = epp_sessions(:api_goodnames).session_id
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => "session=#{session_id}" }
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="2303"]')
|
||||
end
|
||||
end
|
61
test/integration/epp/domain/transfer/query_test.rb
Normal file
61
test/integration/epp/domain/transfer/query_test.rb
Normal file
|
@ -0,0 +1,61 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainTransferQueryTest < ActionDispatch::IntegrationTest
|
||||
def test_returns_domain_transfer_details
|
||||
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).transfers.delete_all
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_equal '2303', 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="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
|
||||
end
|
||||
end
|
137
test/integration/epp/domain/transfer/request_test.rb
Normal file
137
test/integration/epp/domain/transfer/request_test.rb
Normal file
|
@ -0,0 +1,137 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainTransferRequestTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
Setting.transfer_wait_time = 0
|
||||
end
|
||||
|
||||
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_creates_new_domain_transfer
|
||||
assert_difference -> { @domain.transfers.size } do
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
end
|
||||
end
|
||||
|
||||
def test_approves_automatically_if_auto_approval_is_enabled
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
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
|
||||
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_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_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
|
||||
|
||||
def test_non_transferable_domain
|
||||
@domain.update!(statuses: [DomainStatus::SERVER_TRANSFER_PROHIBITED])
|
||||
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
domains(:shop).reload
|
||||
|
||||
assert_equal registrars(:bestnames), domains(:shop).registrar
|
||||
assert_equal '2304', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
end
|
||||
|
||||
def test_discarded_domain
|
||||
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
@domain.reload
|
||||
|
||||
assert_equal registrars(:bestnames), @domain.registrar
|
||||
assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
end
|
||||
|
||||
def test_same_registrar
|
||||
assert_no_difference -> { @domain.transfers.size } do
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
|
||||
assert_equal '2002', 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"?>
|
||||
<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' }
|
||||
@domain.reload
|
||||
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>
|
||||
<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
|
||||
end
|
||||
end
|
|
@ -1,10 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainUpdateTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
login_as users(:api_bestnames)
|
||||
end
|
||||
|
||||
def test_overwrites_existing
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
@ -24,8 +20,9 @@ class EppDomainUpdateTest < ActionDispatch::IntegrationTest
|
|||
</epp>
|
||||
XML
|
||||
|
||||
session_id = epp_sessions(:api_bestnames).session_id
|
||||
post '/epp/command/update', { frame: request_xml }, { 'HTTP_COOKIE' => "session=#{session_id}" }
|
||||
post '/epp/command/update', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_equal 'f0ff7d17b0', domains(:shop).transfer_code
|
||||
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
end
|
||||
end
|
||||
|
|
64
test/integration/epp/login/credentials_test.rb
Normal file
64
test/integration/epp/login/credentials_test.rb
Normal file
|
@ -0,0 +1,64 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppLoginCredentialsTest < ActionDispatch::IntegrationTest
|
||||
def test_correct_credentials
|
||||
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>
|
||||
<login>
|
||||
<clID>test_bestnames</clID>
|
||||
<pw>testtest</pw>
|
||||
<options>
|
||||
<version>1.0</version>
|
||||
<lang>en</lang>
|
||||
</options>
|
||||
<svcs>
|
||||
<objURI>https://epp.tld.ee/schema/domain-eis-1.0.xsd</objURI>
|
||||
<objURI>https://epp.tld.ee/schema/contact-ee-1.1.xsd</objURI>
|
||||
<objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
|
||||
<objURI>urn:ietf:params:xml:ns:keyrelay-1.0</objURI>
|
||||
</svcs>
|
||||
</login>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' }
|
||||
assert EppSession.find_by(session_id: 'new_session_id')
|
||||
assert_equal users(:api_bestnames), EppSession.find_by(session_id: 'new_session_id').user
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="1000"]')
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
end
|
||||
|
||||
def test_already_logged_in
|
||||
assert true # Handled by mod_epp
|
||||
end
|
||||
|
||||
def test_wrong_credentials
|
||||
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>
|
||||
<login>
|
||||
<clID>non-existent</clID>
|
||||
<pw>valid-but-wrong</pw>
|
||||
<options>
|
||||
<version>1.0</version>
|
||||
<lang>en</lang>
|
||||
</options>
|
||||
<svcs>
|
||||
<objURI>https://epp.tld.ee/schema/domain-eis-1.0.xsd</objURI>
|
||||
<objURI>https://epp.tld.ee/schema/contact-ee-1.1.xsd</objURI>
|
||||
<objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
|
||||
<objURI>urn:ietf:params:xml:ns:keyrelay-1.0</objURI>
|
||||
</svcs>
|
||||
</login>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=any_random_string' }
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="2501"]')
|
||||
end
|
||||
end
|
63
test/integration/epp/login/session_limit_test.rb
Normal file
63
test/integration/epp/login/session_limit_test.rb
Normal file
|
@ -0,0 +1,63 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppLoginSessionLimitTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
EppSession.delete_all
|
||||
end
|
||||
|
||||
def test_not_reached
|
||||
(EppSession.limit_per_registrar - 1).times do
|
||||
EppSession.create!(session_id: SecureRandom.hex,
|
||||
user: users(:api_bestnames),
|
||||
updated_at: Time.zone.parse('2010-07-05'))
|
||||
end
|
||||
|
||||
assert_difference 'EppSession.count' do
|
||||
post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' }
|
||||
end
|
||||
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="1000"]')
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
end
|
||||
|
||||
def test_reached
|
||||
EppSession.limit_per_registrar.times do
|
||||
EppSession.create!(session_id: SecureRandom.hex,
|
||||
user: users(:api_bestnames),
|
||||
updated_at: Time.zone.parse('2010-07-05'))
|
||||
end
|
||||
|
||||
assert_no_difference 'EppSession.count' do
|
||||
post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' }
|
||||
end
|
||||
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="2501"]')
|
||||
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>
|
||||
<login>
|
||||
<clID>test_bestnames</clID>
|
||||
<pw>testtest</pw>
|
||||
<options>
|
||||
<version>1.0</version>
|
||||
<lang>en</lang>
|
||||
</options>
|
||||
<svcs>
|
||||
<objURI>https://epp.tld.ee/schema/domain-eis-1.0.xsd</objURI>
|
||||
<objURI>https://epp.tld.ee/schema/contact-ee-1.1.xsd</objURI>
|
||||
<objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
|
||||
<objURI>urn:ietf:params:xml:ns:keyrelay-1.0</objURI>
|
||||
</svcs>
|
||||
</login>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
end
|
||||
end
|
37
test/integration/epp/logout_test.rb
Normal file
37
test/integration/epp/logout_test.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppLogoutTest < ActionDispatch::IntegrationTest
|
||||
def test_success_response
|
||||
post '/epp/session/logout', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="1500"]')
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
end
|
||||
|
||||
def test_ends_current_session
|
||||
post '/epp/session/logout', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_nil EppSession.find_by(session_id: 'api_bestnames')
|
||||
end
|
||||
|
||||
def test_keeps_other_sessions_intact
|
||||
post '/epp/session/logout', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert EppSession.find_by(session_id: 'api_goodnames')
|
||||
end
|
||||
|
||||
def test_anonymous_user
|
||||
post '/epp/session/logout', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=non-existent' }
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="2201"]')
|
||||
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>
|
||||
<logout/>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
end
|
||||
end
|
30
test/integration/epp/poll_test.rb
Normal file
30
test/integration/epp/poll_test.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppPollTest < ActionDispatch::IntegrationTest
|
||||
def test_messages
|
||||
post '/epp/command/poll', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_equal '1301', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('msgQ').size
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
end
|
||||
|
||||
def test_no_messages
|
||||
registrars(:bestnames).messages.delete_all(:delete_all)
|
||||
post '/epp/command/poll', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_equal '1300', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
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>
|
||||
<poll op="req"/>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
end
|
||||
end
|
|
@ -9,6 +9,7 @@ class RegistrarDomainsTest < ActionDispatch::IntegrationTest
|
|||
Domain,Transfer code,Registrant name,Registrant code,Date of expiry
|
||||
library.test,45118f5,Acme Ltd,acme-ltd-001,2010-07-05
|
||||
shop.test,65078d5,John,john-001,2010-07-05
|
||||
invalid.test,any,any,any,2010-07-05
|
||||
airport.test,55438j5,John,john-001,2010-07-05
|
||||
CSV
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ class ContactTest < ActiveSupport::TestCase
|
|||
@contact = contacts(:john)
|
||||
end
|
||||
|
||||
def test_validates
|
||||
def test_valid_fixture_is_valid
|
||||
assert @contact.valid?
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,11 @@ class DomainTest < ActiveSupport::TestCase
|
|||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
def test_validates
|
||||
def test_valid_fixture_is_valid
|
||||
assert @domain.valid?
|
||||
end
|
||||
|
||||
def test_invalid_fixture_is_invalid
|
||||
assert domains(:invalid).invalid?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DomainTransferTest < ActiveSupport::TestCase
|
||||
class DomainTransferableTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
@new_registrar = registrars(:goodnames)
|
||||
|
@ -45,22 +45,4 @@ class DomainTransferTest < ActiveSupport::TestCase
|
|||
@domain.transfer(@new_registrar)
|
||||
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_creates_message
|
||||
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
|
||||
end
|
32
test/models/domain_transfer_test.rb
Normal file
32
test/models/domain_transfer_test.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DomainTransferTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@domain_transfer = domain_transfers(:shop)
|
||||
end
|
||||
|
||||
def test_approval
|
||||
@domain_transfer.approve
|
||||
@domain_transfer.reload
|
||||
assert @domain_transfer.approved?
|
||||
end
|
||||
|
||||
def test_notifies_old_registrar_on_approval
|
||||
old_registrar = @domain_transfer.old_registrar
|
||||
|
||||
assert_difference -> { old_registrar.messages.count } do
|
||||
@domain_transfer.approve
|
||||
end
|
||||
|
||||
body = 'Transfer of domain shop.test has been approved.' \
|
||||
' It was associated with registrant john-001' \
|
||||
' and contacts jane-001, william-001.'
|
||||
id = @domain_transfer.id
|
||||
class_name = @domain_transfer.class.name
|
||||
|
||||
message = old_registrar.messages.last
|
||||
assert_equal body, message.body
|
||||
assert_equal id, message.attached_obj_id
|
||||
assert_equal class_name, message.attached_obj_type
|
||||
end
|
||||
end
|
63
test/models/epp_session_test.rb
Normal file
63
test/models/epp_session_test.rb
Normal file
|
@ -0,0 +1,63 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppSessionTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@epp_session = epp_sessions(:api_bestnames)
|
||||
end
|
||||
|
||||
def test_valid
|
||||
assert @epp_session.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_session_id
|
||||
@epp_session.session_id = nil
|
||||
@epp_session.validate
|
||||
assert @epp_session.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_user
|
||||
@epp_session.user = nil
|
||||
@epp_session.validate
|
||||
assert @epp_session.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_if_persisted_record_with_the_same_session_id_exists
|
||||
epp_session = EppSession.new(session_id: @epp_session.session_id, user: @epp_session.user)
|
||||
epp_session.validate
|
||||
assert epp_session.invalid?
|
||||
end
|
||||
|
||||
# Having session_id constraints at the database level is crucial
|
||||
|
||||
def test_database_session_id_unique_constraint
|
||||
epp_session = EppSession.new(session_id: @epp_session.session_id, user: @epp_session.user)
|
||||
|
||||
assert_raises ActiveRecord::RecordNotUnique do
|
||||
epp_session.save(validate: false)
|
||||
end
|
||||
end
|
||||
|
||||
def test_database_session_id_not_null_constraint
|
||||
@epp_session.session_id = nil
|
||||
assert_raises ActiveRecord::StatementInvalid do
|
||||
@epp_session.save(validate: false)
|
||||
end
|
||||
end
|
||||
|
||||
def test_limit_per_registrar
|
||||
assert_equal 4, EppSession.limit_per_registrar
|
||||
end
|
||||
|
||||
def test_limit_is_per_registrar
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
EppSession.delete_all
|
||||
|
||||
EppSession.limit_per_registrar.times do
|
||||
EppSession.create!(session_id: SecureRandom.hex,
|
||||
user: users(:api_goodnames),
|
||||
updated_at: Time.zone.parse('2010-07-05'))
|
||||
end
|
||||
|
||||
refute EppSession.limit_reached?(registrars(:bestnames))
|
||||
end
|
||||
end
|
21
test/models/message_test.rb
Normal file
21
test/models/message_test.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require 'test_helper'
|
||||
|
||||
class MessageTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@message = messages(:greeting)
|
||||
end
|
||||
|
||||
def test_valid
|
||||
assert @message.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_body
|
||||
@message.body = nil
|
||||
assert @message.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_registrar
|
||||
@message.registrar = nil
|
||||
assert @message.invalid?
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue