Merge branch 'master' into refactor-messages

# Conflicts:
#	db/structure.sql
This commit is contained in:
Artur Beljajev 2018-08-28 14:26:56 +03:00
commit aff5b68a2f
29 changed files with 297 additions and 93 deletions

View file

@ -1,6 +1,10 @@
require 'test_helper'
class EppDomainDeleteTest < ApplicationIntegrationTest
def setup
@domain = domains(:shop)
end
def test_bypasses_domain_and_registrant_and_contacts_validation
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
@ -27,7 +31,9 @@ class EppDomainDeleteTest < ApplicationIntegrationTest
end
def test_discarded_domain_cannot_be_deleted
domains(:shop).discard
travel_to Time.zone.parse('2010-07-05 10:30')
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
@domain.discard
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
@ -51,5 +57,6 @@ class EppDomainDeleteTest < ApplicationIntegrationTest
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end
assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
travel_back
end
end

View file

@ -1,6 +1,10 @@
require 'test_helper'
class EppDomainUpdateTest < ApplicationIntegrationTest
def setup
@domain = domains(:shop)
end
def test_update_domain
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
@ -21,13 +25,16 @@ class EppDomainUpdateTest < ApplicationIntegrationTest
XML
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
assert_equal 'f0ff7d17b0', domains(:shop).transfer_code
@domain.reload
assert_equal 'f0ff7d17b0', @domain.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_discarded_domain_cannot_be_updated
domains(:shop).discard
travel_to Time.zone.parse('2010-07-05 10:30')
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
@domain.discard
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
@ -44,5 +51,6 @@ class EppDomainUpdateTest < ApplicationIntegrationTest
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
travel_back
end
end

View file

@ -1,12 +1,17 @@
require 'test_helper'
class EppDomainTransferRequestTest < ApplicationIntegrationTest
setup do
def setup
@domain = domains(:shop)
@new_registrar = registrars(:goodnames)
@original_transfer_wait_time = Setting.transfer_wait_time
Setting.transfer_wait_time = 0
end
def teardown
Setting.transfer_wait_time = @original_transfer_wait_time
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]
@ -75,14 +80,17 @@ class EppDomainTransferRequestTest < ApplicationIntegrationTest
assert_equal '2304', Nokogiri::XML(response.body).at_css('result')[:code]
end
def test_discarded_domain
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
def test_discarded_domain_cannot_be_transferred
travel_to Time.zone.parse('2010-07-05 10:30')
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
@domain.discard
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]
travel_back
end
def test_same_registrar

View file

@ -0,0 +1,51 @@
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