mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 13:44:47 +02:00
Merge branch 'master' into refactor-messages
# Conflicts: # db/structure.sql
This commit is contained in:
commit
aff5b68a2f
29 changed files with 297 additions and 93 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
51
test/integration/tasks/discard_domain_test.rb
Normal file
51
test/integration/tasks/discard_domain_test.rb
Normal 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
|
|
@ -1,14 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DomainDeletableTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
def test_discard
|
||||
refute @domain.discarded?
|
||||
@domain.discard
|
||||
@domain.reload
|
||||
assert @domain.discarded?
|
||||
end
|
||||
end
|
63
test/models/domain/discardable_test.rb
Normal file
63
test/models/domain/discardable_test.rb
Normal file
|
@ -0,0 +1,63 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DomainDiscardableTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
@domain = domains(:shop)
|
||||
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
||||
end
|
||||
|
||||
teardown do
|
||||
travel_back
|
||||
end
|
||||
|
||||
def test_discarding_a_domain_persists_the_state
|
||||
@domain.discard
|
||||
@domain.reload
|
||||
assert @domain.discarded?
|
||||
end
|
||||
|
||||
def test_discarding_a_domain_schedules_deletion_at_random_time
|
||||
@domain.discard
|
||||
other_domain = domains(:airport)
|
||||
other_domain.delete_at = Time.zone.parse('2010-07-04')
|
||||
other_domain.discard
|
||||
|
||||
background_job = QueJob.find_by("args->>0 = '#{@domain.id}'", job_class: DomainDeleteJob.name)
|
||||
other_background_job = QueJob.find_by("args->>0 = '#{other_domain.id}'",
|
||||
job_class: DomainDeleteJob.name)
|
||||
assert_not_equal background_job.run_at, other_background_job.run_at
|
||||
end
|
||||
|
||||
def test_discarding_a_domain_bypasses_validation
|
||||
domain = domains(:invalid)
|
||||
domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
||||
domain.discard
|
||||
domain.reload
|
||||
assert domain.discarded?
|
||||
end
|
||||
|
||||
def test_domain_cannot_be_discarded_repeatedly
|
||||
@domain.discard
|
||||
|
||||
exception = assert_raises do
|
||||
@domain.discard
|
||||
end
|
||||
assert_equal 'Domain is already discarded', exception.message
|
||||
end
|
||||
|
||||
def test_keeping_a_domain_bypasses_validation
|
||||
domain = domains(:invalid)
|
||||
domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
||||
domain.discard
|
||||
domain.keep
|
||||
domain.reload
|
||||
assert_not domain.discarded?
|
||||
end
|
||||
|
||||
def test_keeping_a_domain_cancels_domain_deletion
|
||||
@domain.discard
|
||||
@domain.keep
|
||||
assert_nil QueJob.find_by("args->>0 = '#{@domain.id}'", job_class: DomainDeleteJob.name)
|
||||
end
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DomainForceDeleteTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
|
@ -74,7 +74,7 @@ class DomainForceDeleteTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_force_delete_cannot_be_scheduled_when_a_domain_is_discarded
|
||||
@domain.discard
|
||||
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
assert_raises StandardError do
|
||||
@domain.schedule_force_delete
|
||||
end
|
||||
|
|
|
@ -21,8 +21,8 @@ class ContactVersionsTest < ApplicationSystemTestCase
|
|||
VALUES (75, 'test_registrar', 'test123', 'test@test.com', 'EE', 'TEST123',
|
||||
'test123', 'en');
|
||||
|
||||
INSERT INTO contacts (id, code, auth_info, registrar_id)
|
||||
VALUES (75, 'test_code', '8b4d462aa04194ca78840a', 75);
|
||||
INSERT INTO contacts (id, code, email, auth_info, registrar_id)
|
||||
VALUES (75, 'test_code', 'test@inbox.test', '8b4d462aa04194ca78840a', 75);
|
||||
|
||||
INSERT INTO log_contacts (item_type, item_id, event, whodunnit, object,
|
||||
object_changes, created_at, session, children, ident_updated_at, uuid)
|
||||
|
|
|
@ -21,8 +21,8 @@ class DomainVersionsTest < ApplicationSystemTestCase
|
|||
VALUES (54, 'test_registrar', 'test123', 'test@test.com', 'EE', 'TEST123',
|
||||
'test123', 'en');
|
||||
|
||||
INSERT INTO contacts (id, code, auth_info, registrar_id)
|
||||
VALUES (54, 'test_code', '8b4d462aa04194ca78840a', 54);
|
||||
INSERT INTO contacts (id, code, email, auth_info, registrar_id)
|
||||
VALUES (54, 'test_code', 'test@inbox.test', '8b4d462aa04194ca78840a', 54);
|
||||
|
||||
INSERT INTO domains (id, registrar_id, valid_to, registrant_id,
|
||||
transfer_code)
|
||||
|
|
|
@ -7,9 +7,14 @@ class AdminAreaDomainDetailsTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
def test_discarded_domain_has_corresponding_label
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
||||
|
||||
visit admin_domain_url(@domain)
|
||||
assert_no_css 'span.label.label-warning', text: 'deleteCandidate'
|
||||
|
||||
@domain.discard
|
||||
|
||||
visit admin_domain_url(@domain)
|
||||
assert_css 'span.label.label-warning', text: 'deleteCandidate'
|
||||
end
|
||||
|
|
|
@ -56,7 +56,7 @@ class AdminAreaDomainForceDeleteTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
def test_force_delete_procedure_cannot_be_scheduled_on_a_discarded_domain
|
||||
@domain.discard
|
||||
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
|
||||
visit edit_admin_domain_url(@domain)
|
||||
assert_no_button 'Schedule force delete'
|
||||
|
|
|
@ -3,11 +3,29 @@ require 'test_helper'
|
|||
class AdminDomainsTestTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
teardown do
|
||||
travel_back
|
||||
end
|
||||
|
||||
def test_shows_details
|
||||
domain = domains(:shop)
|
||||
visit admin_domain_path(domain)
|
||||
assert_field nil, with: domain.transfer_code
|
||||
visit admin_domain_path(@domain)
|
||||
assert_field nil, with: @domain.transfer_code
|
||||
end
|
||||
|
||||
def test_keep_a_domain
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
@domain.delete_at = Time.zone.parse('2010-07-05 10:00')
|
||||
@domain.discard
|
||||
|
||||
visit edit_admin_domain_url(@domain)
|
||||
click_link_or_button 'Remove deleteCandidate status'
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.discarded?
|
||||
assert_text 'deleteCandidate status has been removed'
|
||||
assert_no_link 'Remove deleteCandidate status'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue