mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
250 lines
9.6 KiB
Ruby
250 lines
9.6 KiB
Ruby
require 'test_helper'
|
|
|
|
class EppDomainCreateAuctionTest < EppTestCase
|
|
setup do
|
|
@auction = auctions(:one)
|
|
Domain.release_to_auction = true
|
|
end
|
|
|
|
teardown do
|
|
Domain.release_to_auction = false
|
|
end
|
|
|
|
def test_registers_domain_without_registration_code_when_not_at_auction
|
|
request_xml = <<-XML
|
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
|
|
<command>
|
|
<create>
|
|
<domain:create xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}">
|
|
<domain:name>not-at-auction.test</domain:name>
|
|
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
|
</domain:create>
|
|
</create>
|
|
<extension>
|
|
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis', for_version: '1.0')}">
|
|
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
|
</eis:extdata>
|
|
</extension>
|
|
</command>
|
|
</epp>
|
|
XML
|
|
|
|
assert_difference 'Domain.count' do
|
|
post epp_create_path, params: { frame: request_xml },
|
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
|
end
|
|
assert_epp_response :completed_successfully
|
|
response_xml = Nokogiri::XML(response.body)
|
|
assert_correct_against_schema response_xml
|
|
end
|
|
|
|
def test_registers_domain_with_correct_registration_code_after_another_auction_when_payment_is_received
|
|
@auction.update!(status: Auction.statuses[:domain_registered], registration_code: 'some')
|
|
|
|
another_auction = @auction.dup
|
|
another_auction.uuid = nil
|
|
another_auction.status = Auction.statuses[:payment_received]
|
|
another_auction.registration_code = 'auction002'
|
|
another_auction.save!
|
|
|
|
request_xml = <<-XML
|
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
|
|
<command>
|
|
<create>
|
|
<domain:create xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}">
|
|
<domain:name>auction.test</domain:name>
|
|
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
|
</domain:create>
|
|
</create>
|
|
<extension>
|
|
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis', for_version: '1.0')}">
|
|
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
|
<eis:reserved>
|
|
<eis:pw>auction002</eis:pw>
|
|
</eis:reserved>
|
|
</eis:extdata>
|
|
</extension>
|
|
</command>
|
|
</epp>
|
|
XML
|
|
|
|
assert_difference 'Domain.count' do
|
|
post epp_create_path, params: { frame: request_xml },
|
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
|
end
|
|
assert_epp_response :completed_successfully
|
|
response_xml = Nokogiri::XML(response.body)
|
|
assert_correct_against_schema response_xml
|
|
end
|
|
|
|
def test_registers_domain_with_correct_registration_code_when_payment_is_received
|
|
@auction.update!(status: Auction.statuses[:payment_received],
|
|
registration_code: 'auction001')
|
|
|
|
request_xml = <<-XML
|
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
|
|
<command>
|
|
<create>
|
|
<domain:create xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}">
|
|
<domain:name>auction.test</domain:name>
|
|
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
|
</domain:create>
|
|
</create>
|
|
<extension>
|
|
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis', for_version: '1.0')}">
|
|
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
|
<eis:reserved>
|
|
<eis:pw>auction001</eis:pw>
|
|
</eis:reserved>
|
|
</eis:extdata>
|
|
</extension>
|
|
</command>
|
|
</epp>
|
|
XML
|
|
|
|
assert_difference 'Domain.count' do
|
|
post epp_create_path, params: { frame: request_xml },
|
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
|
end
|
|
|
|
@auction.reload
|
|
assert @auction.domain_registered?
|
|
assert_epp_response :completed_successfully
|
|
response_xml = Nokogiri::XML(response.body)
|
|
assert_correct_against_schema response_xml
|
|
end
|
|
|
|
def test_domain_cannot_be_registered_without_registration_code
|
|
@auction.update!(status: Auction.statuses[:payment_received],
|
|
registration_code: 'auction001')
|
|
|
|
request_xml = <<-XML
|
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
|
|
<command>
|
|
<create>
|
|
<domain:create xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}">
|
|
<domain:name>auction.test</domain:name>
|
|
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
|
</domain:create>
|
|
</create>
|
|
<extension>
|
|
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis', for_version: '1.0')}">
|
|
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
|
</eis:extdata>
|
|
</extension>
|
|
</command>
|
|
</epp>
|
|
XML
|
|
|
|
assert_no_difference 'Domain.count' do
|
|
post epp_create_path, params: { frame: request_xml },
|
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
|
end
|
|
response_xml = Nokogiri::XML(response.body)
|
|
assert_correct_against_schema response_xml
|
|
assert_epp_response :required_parameter_missing
|
|
end
|
|
|
|
def test_domain_cannot_be_registered_with_wrong_registration_code
|
|
@auction.update!(status: Auction.statuses[:payment_received],
|
|
registration_code: 'auction001')
|
|
|
|
request_xml = <<-XML
|
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
|
|
<command>
|
|
<create>
|
|
<domain:create xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}">
|
|
<domain:name>auction.test</domain:name>
|
|
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
|
</domain:create>
|
|
</create>
|
|
<extension>
|
|
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis', for_version: '1.0')}">
|
|
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
|
<eis:reserved>
|
|
<eis:pw>wrong</eis:pw>
|
|
</eis:reserved>
|
|
</eis:extdata>
|
|
</extension>
|
|
</command>
|
|
</epp>
|
|
XML
|
|
|
|
assert_no_difference 'Domain.count' do
|
|
post epp_create_path, params: { frame: request_xml },
|
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
|
end
|
|
response_xml = Nokogiri::XML(response.body)
|
|
assert_correct_against_schema response_xml
|
|
assert_epp_response :invalid_authorization_information
|
|
end
|
|
|
|
def test_domain_cannot_be_registered_when_payment_is_not_received
|
|
@auction.update!(status: Auction.statuses[:awaiting_payment])
|
|
|
|
request_xml = <<-XML
|
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
|
|
<command>
|
|
<create>
|
|
<domain:create xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}">
|
|
<domain:name>auction.test</domain:name>
|
|
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
|
</domain:create>
|
|
</create>
|
|
<extension>
|
|
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis', for_version: '1.0')}">
|
|
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
|
<eis:reserved>
|
|
<eis:pw>test</eis:pw>
|
|
</eis:reserved>
|
|
</eis:extdata>
|
|
</extension>
|
|
</command>
|
|
</epp>
|
|
XML
|
|
|
|
assert_no_difference 'Domain.count' do
|
|
post epp_create_path, params: { frame: request_xml },
|
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
|
end
|
|
response_xml = Nokogiri::XML(response.body)
|
|
assert_correct_against_schema response_xml
|
|
assert_epp_response :required_parameter_missing
|
|
end
|
|
|
|
def test_domain_cannot_be_registered_when_at_auction
|
|
@auction.update!(status: Auction.statuses[:started])
|
|
|
|
request_xml = <<-XML
|
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
|
|
<command>
|
|
<create>
|
|
<domain:create xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}">
|
|
<domain:name>auction.test</domain:name>
|
|
</domain:create>
|
|
</create>
|
|
<extension>
|
|
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis', for_version: '1.0')}">
|
|
<eis:legalDocument type="pdf">test</eis:legalDocument>
|
|
</eis:extdata>
|
|
</extension>
|
|
</command>
|
|
</epp>
|
|
XML
|
|
|
|
assert_no_difference 'Domain.count' do
|
|
post epp_create_path, params: { frame: request_xml },
|
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
|
end
|
|
response_xml = Nokogiri::XML(response.body)
|
|
assert_correct_against_schema response_xml
|
|
assert_epp_response :parameter_value_policy_error
|
|
end
|
|
end
|