mirror of
https://github.com/internetee/registry.git
synced 2025-06-09 22:24:47 +02:00
parent
640faaadb9
commit
42e8f86dae
51 changed files with 1619 additions and 53 deletions
26
test/integration/api/v1/auctions/details_test.rb
Normal file
26
test/integration/api/v1/auctions/details_test.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ApiV1AuctionDetailsTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@auction = auctions(:one)
|
||||
ENV['auction_api_allowed_ips'] = '127.0.0.1'
|
||||
end
|
||||
|
||||
teardown do
|
||||
ENV['auction_api_allowed_ips'] = ''
|
||||
end
|
||||
|
||||
def test_returns_auction_details
|
||||
assert_equal '1b3ee442-e8fe-4922-9492-8fcb9dccc69c', @auction.uuid
|
||||
assert_equal 'auction.test', @auction.domain
|
||||
assert_equal Auction.statuses[:no_bids], @auction.status
|
||||
|
||||
get api_v1_auction_path(@auction.uuid), nil, 'Content-Type' => Mime::JSON.to_s
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ 'id' => '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
|
||||
'domain' => 'auction.test',
|
||||
'status' => Auction.statuses[:no_bids] }), ActiveSupport::JSON
|
||||
.decode(response.body)
|
||||
end
|
||||
end
|
30
test/integration/api/v1/auctions/list_test.rb
Normal file
30
test/integration/api/v1/auctions/list_test.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ApiV1AuctionListTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@auction = auctions(:one)
|
||||
end
|
||||
|
||||
def test_returns_started_auctions_without_authentication
|
||||
@auction.update!(uuid: '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
|
||||
domain: 'auction.test',
|
||||
status: Auction.statuses[:started])
|
||||
|
||||
get api_v1_auctions_path, nil, 'Content-Type' => Mime::JSON.to_s
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ([{ 'id' => '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
|
||||
'domain' => 'auction.test',
|
||||
'status' => Auction.statuses[:started] }]), ActiveSupport::JSON
|
||||
.decode(response.body)
|
||||
end
|
||||
|
||||
def test_does_not_return_finished_auctions
|
||||
@auction.update!(domain: 'auction.test', status: Auction.statuses[:awaiting_payment])
|
||||
|
||||
get api_v1_auctions_path, nil, 'Content-Type' => Mime::JSON.to_s
|
||||
|
||||
assert_response :ok
|
||||
assert_empty ActiveSupport::JSON.decode(response.body)
|
||||
end
|
||||
end
|
100
test/integration/api/v1/auctions/update_test.rb
Normal file
100
test/integration/api/v1/auctions/update_test.rb
Normal file
|
@ -0,0 +1,100 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
|
||||
fixtures :auctions, 'whois/records'
|
||||
|
||||
setup do
|
||||
@auction = auctions(:one)
|
||||
|
||||
@original_auction_api_allowed_ips_setting = ENV['auction_api_allowed_ips']
|
||||
ENV['auction_api_allowed_ips'] = '127.0.0.1'
|
||||
end
|
||||
|
||||
teardown do
|
||||
ENV['auction_api_allowed_ips'] = @original_auction_api_allowed_ips_setting
|
||||
end
|
||||
|
||||
def test_returns_auction_details
|
||||
assert_equal '1b3ee442-e8fe-4922-9492-8fcb9dccc69c', @auction.uuid
|
||||
assert_equal 'auction.test', @auction.domain
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:awaiting_payment] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ 'id' => '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
|
||||
'domain' => 'auction.test',
|
||||
'status' => Auction.statuses[:awaiting_payment] }), ActiveSupport::JSON
|
||||
.decode(response.body)
|
||||
end
|
||||
|
||||
def test_marks_as_awaiting_payment
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:awaiting_payment] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
@auction.reload
|
||||
assert @auction.awaiting_payment?
|
||||
end
|
||||
|
||||
def test_marks_as_no_bids
|
||||
assert_equal 'auction.test', @auction.domain
|
||||
whois_records(:one).update!(name: 'auction.test')
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:no_bids] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
@auction.reload
|
||||
assert @auction.no_bids?
|
||||
end
|
||||
|
||||
def test_marks_as_payment_received
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
@auction.reload
|
||||
assert @auction.payment_received?
|
||||
end
|
||||
|
||||
def test_marks_as_payment_not_received
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_not_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
@auction.reload
|
||||
assert @auction.payment_not_received?
|
||||
end
|
||||
|
||||
def test_reveals_registration_code_when_payment_is_received
|
||||
@auction.update!(registration_code: 'auction-001',
|
||||
status: Auction.statuses[:awaiting_payment])
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
|
||||
response_json = ActiveSupport::JSON.decode(response.body)
|
||||
assert_not_nil response_json['registration_code']
|
||||
end
|
||||
|
||||
def test_conceals_registration_code_when_payment_is_not_received
|
||||
@auction.update!(status: Auction.statuses[:awaiting_payment])
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_not_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
|
||||
response_json = ActiveSupport::JSON.decode(response.body)
|
||||
assert_nil response_json['registration_code']
|
||||
end
|
||||
|
||||
def test_restarts_an_auction_when_the_payment_is_not_received
|
||||
@auction.update!(domain: 'auction.test', status: Auction.statuses[:awaiting_payment])
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_not_received] }
|
||||
.to_json, 'Content-Type' => Mime::JSON.to_s
|
||||
|
||||
assert DNS::DomainName.new('auction.test').at_auction?
|
||||
end
|
||||
|
||||
def test_inaccessible_when_ip_address_is_not_allowed
|
||||
ENV['auction_api_allowed_ips'] = ''
|
||||
|
||||
patch api_v1_auction_path(@auction.uuid), { status: 'any' }.to_json,
|
||||
'Content-Type' => Mime::JSON.to_s
|
||||
|
||||
assert_response :unauthorized
|
||||
end
|
||||
end
|
87
test/integration/epp/domain/check/auction_test.rb
Normal file
87
test/integration/epp/domain/check/auction_test.rb
Normal file
|
@ -0,0 +1,87 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainCheckAuctionTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
@auction = auctions(:one)
|
||||
Domain.release_to_auction = true
|
||||
end
|
||||
|
||||
teardown do
|
||||
Domain.release_to_auction = false
|
||||
end
|
||||
|
||||
def test_domain_is_unavailable_when_at_auction
|
||||
@auction.update!(status: Auction.statuses[:started])
|
||||
|
||||
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>
|
||||
<check>
|
||||
<domain:check xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>auction.test</domain:name>
|
||||
</domain:check>
|
||||
</check>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
|
||||
assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
end
|
||||
|
||||
def test_domain_is_unavailable_when_awaiting_payment
|
||||
@auction.update!(status: Auction.statuses[:awaiting_payment])
|
||||
|
||||
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>
|
||||
<check>
|
||||
<domain:check xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>auction.test</domain:name>
|
||||
</domain:check>
|
||||
</check>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
|
||||
assert_equal 'Awaiting payment', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
end
|
||||
|
||||
def test_domain_is_available_when_payment_received
|
||||
@auction.update!(status: Auction.statuses[:payment_received])
|
||||
|
||||
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>
|
||||
<check>
|
||||
<domain:check xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>auction.test</domain:name>
|
||||
</domain:check>
|
||||
</check>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
|
||||
assert_nil response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')
|
||||
end
|
||||
end
|
248
test/integration/epp/domain/create/auction_test.rb
Normal file
248
test/integration/epp/domain/create/auction_test.rb
Normal file
|
@ -0,0 +1,248 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainCreateAuctionTest < ApplicationIntegrationTest
|
||||
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="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>not-at-auction.test</domain:name>
|
||||
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_difference 'Domain.count' do
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
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="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>auction.test</domain:name>
|
||||
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<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/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
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="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>auction.test</domain:name>
|
||||
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<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/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
|
||||
@auction.reload
|
||||
assert @auction.domain_registered?
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
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="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>auction.test</domain:name>
|
||||
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_no_difference 'Domain.count' do
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '2003', response_xml.at_css('result')[:code]
|
||||
assert_equal 'Required parameter missing; reserved>pw element is required',
|
||||
response_xml.at_css('result msg').text
|
||||
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="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>auction.test</domain:name>
|
||||
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<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/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '2202', response_xml.at_css('result')[:code]
|
||||
assert_equal 'Invalid authorization information; invalid reserved>pw value',
|
||||
response_xml.at_css('result msg').text
|
||||
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="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>auction.test</domain:name>
|
||||
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<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/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '2003', response_xml.at_css('result')[:code]
|
||||
assert_equal 'Required parameter missing; reserved>pw element required for reserved domains',
|
||||
response_xml.at_css('result msg').text
|
||||
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="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>auction.test</domain:name>
|
||||
</domain:create>
|
||||
</create>
|
||||
<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
|
||||
|
||||
assert_no_difference 'Domain.count' do
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '2306', response_xml.at_css('result')[:code]
|
||||
assert_equal 'Parameter value policy error: domain is at auction',
|
||||
response_xml.at_css('result msg').text
|
||||
end
|
||||
end
|
87
test/integration/epp/domain/info/auction_test.rb
Normal file
87
test/integration/epp/domain/info/auction_test.rb
Normal file
|
@ -0,0 +1,87 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainInfoAuctionTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
@auction = auctions(:one)
|
||||
Domain.release_to_auction = true
|
||||
end
|
||||
|
||||
teardown do
|
||||
Domain.release_to_auction = false
|
||||
end
|
||||
|
||||
def test_domain_is_unavailable_when_at_auction
|
||||
@auction.update!(status: Auction.statuses[:started])
|
||||
|
||||
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>
|
||||
<info>
|
||||
<domain:info xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>auction.test</domain:name>
|
||||
</domain:info>
|
||||
</info>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_equal 'auction.test', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
assert_equal 'At auction', response_xml.at_xpath('//domain:status', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['s']
|
||||
end
|
||||
|
||||
def test_domain_is_reserved_when_awaiting_payment
|
||||
@auction.update!(status: Auction.statuses[:awaiting_payment])
|
||||
|
||||
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>
|
||||
<info>
|
||||
<domain:info xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>auction.test</domain:name>
|
||||
</domain:info>
|
||||
</info>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_equal 'auction.test', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
assert_equal 'Awaiting payment', response_xml.at_xpath('//domain:status', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['s']
|
||||
end
|
||||
|
||||
def test_domain_is_reserved_when_payment_received
|
||||
@auction.update!(status: Auction.statuses[:payment_received])
|
||||
|
||||
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>
|
||||
<info>
|
||||
<domain:info xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>auction.test</domain:name>
|
||||
</domain:info>
|
||||
</info>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_equal 'auction.test', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
assert_equal 'Reserved', response_xml.at_xpath('//domain:status', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['s']
|
||||
end
|
||||
end
|
|
@ -1,51 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DiscardDomainTaskTest < TaskTestCase
|
||||
setup do
|
||||
travel_to Time.zone.parse('2010-07-05 08:00')
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
def test_discard_domains_with_past_delete_at
|
||||
@domain.update!(delete_at: Time.zone.parse('2010-07-05 07:59'))
|
||||
Rake::Task['domain:discard'].execute
|
||||
@domain.reload
|
||||
assert @domain.discarded?
|
||||
end
|
||||
|
||||
def test_ignore_domains_with_delete_at_in_the_future_or_now
|
||||
@domain.update!(delete_at: Time.zone.parse('2010-07-05 08:00'))
|
||||
Rake::Task['domain:discard'].execute
|
||||
@domain.reload
|
||||
refute @domain.discarded?
|
||||
end
|
||||
|
||||
def test_ignore_already_discarded_domains
|
||||
@domain.update!(delete_at: Time.zone.parse('2010-07-05 07:59'))
|
||||
@domain.discard
|
||||
|
||||
job_count = lambda do
|
||||
QueJob.where("args->>0 = '#{@domain.id}'", job_class: DomainDeleteJob.name).count
|
||||
end
|
||||
|
||||
assert_no_difference job_count, 'A domain should not be discarded again' do
|
||||
Rake::Task['domain:discard'].execute
|
||||
end
|
||||
end
|
||||
|
||||
def test_ignore_domains_with_server_delete_prohibited_status
|
||||
@domain.update!(delete_at: Time.zone.parse('2010-07-05 07:59'),
|
||||
statuses: [DomainStatus::SERVER_DELETE_PROHIBITED])
|
||||
Rake::Task['domain:discard'].execute
|
||||
@domain.reload
|
||||
refute @domain.discarded?
|
||||
end
|
||||
|
||||
def test_show_results
|
||||
@domain.update!(delete_at: Time.zone.parse('2010-07-05 07:59'))
|
||||
$stdout = StringIO.new
|
||||
|
||||
Rake::Task['domain:discard'].execute
|
||||
assert_equal "shop.test is discarded\nDiscarded total: 1\n", $stdout.string
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue