diff --git a/app/interactions/actions/domain_create.rb b/app/interactions/actions/domain_create.rb index 970d74b3b6..d39c470b74 100644 --- a/app/interactions/actions/domain_create.rb +++ b/app/interactions/actions/domain_create.rb @@ -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' \ diff --git a/app/models/dns/domain_name.rb b/app/models/dns/domain_name.rb index 6c68c37971..fab3c7cc17 100644 --- a/app/models/dns/domain_name.rb +++ b/app/models/dns/domain_name.rb @@ -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 diff --git a/test/integration/epp/domain/create/auction_test.rb b/test/integration/epp/domain/create/auction_test.rb index ebebfb9bfe..33e95b4a9f 100644 --- a/test/integration/epp/domain/create/auction_test.rb +++ b/test/integration/epp/domain/create/auction_test.rb @@ -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 @@ -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 + + + + + + auction.test + #{contacts(:john).code} + + + + + #{'test' * 2000} + + auction001 + + + + + + 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