Skip to content

Commit

Permalink
Merge pull request #2643 from internetee/2641-auction-restart-race-co…
Browse files Browse the repository at this point in the history
…ndition-on-registration-deadline

added deadline registration condition during domain registration from…
  • Loading branch information
vohmar authored Jan 26, 2024
2 parents d3d8db2 + b5b5902 commit a7c66be
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/interactions/actions/domain_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def validate_domain_integrity
return unless Domain.release_to_auction

dn = DNS::DomainName.new(domain.name)
if dn.at_auction?
if dn.at_auction? || dn.is_deadline_is_reached?
domain.add_epp_error('2306', nil, nil, 'Parameter value policy error: domain is at auction')
elsif dn.awaiting_payment?
domain.add_epp_error('2003', nil, nil, 'Required parameter missing; reserved>pw element' \
Expand Down
4 changes: 4 additions & 0 deletions app/models/dns/domain_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def auctionable?
!not_auctionable?
end

def is_deadline_is_reached?
pending_auction && pending_auction.payment_received? && pending_auction&.registration_deadline && Time.zone.now > pending_auction.registration_deadline
end

def to_s
name
end
Expand Down
38 changes: 37 additions & 1 deletion test/integration/epp/domain/create/auction_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_registers_domain_with_correct_registration_code_after_another_auction_w

def test_registers_domain_with_correct_registration_code_when_payment_is_received
@auction.update!(status: Auction.statuses[:payment_received],
registration_code: 'auction001')
registration_code: 'auction001', registration_deadline: 1.day.from_now)

request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Expand Down Expand Up @@ -247,4 +247,40 @@ def test_domain_cannot_be_registered_when_at_auction
assert_correct_against_schema response_xml
assert_epp_response :parameter_value_policy_error
end

def test_domain_cannot_be_registred_when_deadline_is_reached
@auction.update!(status: Auction.statuses[:payment_received],
registration_code: 'auction001', registration_deadline: 1.second.ago)

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_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

0 comments on commit a7c66be

Please sign in to comment.