mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
Merge remote-tracking branch 'origin/master' into 1739-ns-bulk-change-test-and-whois-update
This commit is contained in:
commit
c1aa286e90
192 changed files with 5154 additions and 1343 deletions
104
test/models/bounced_mail_address_test.rb
Normal file
104
test/models/bounced_mail_address_test.rb
Normal file
|
@ -0,0 +1,104 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BouncedMailAddressTest < ActiveSupport::TestCase
|
||||
include ActionMailer::TestHelper
|
||||
|
||||
def setup
|
||||
@bounced_mail = BouncedMailAddress.new
|
||||
@bounced_mail.email = 'recipient@registry.test'
|
||||
@bounced_mail.message_id = '010f0174a0c7d348-ea6e2fc1-0854-4073-b71f-5cecf9b0d0b2-000000'
|
||||
@bounced_mail.bounce_type = 'Permanent'
|
||||
@bounced_mail.bounce_subtype = 'General'
|
||||
@bounced_mail.action = 'failed'
|
||||
@bounced_mail.status = '5.1.1'
|
||||
@bounced_mail.diagnostic = 'smtp; 550 5.1.1 user unknown'
|
||||
end
|
||||
|
||||
def test_email_is_required
|
||||
assert @bounced_mail.valid?
|
||||
@bounced_mail.email = nil
|
||||
assert @bounced_mail.invalid?
|
||||
end
|
||||
|
||||
def test_message_id_is_required
|
||||
assert @bounced_mail.valid?
|
||||
@bounced_mail.message_id = nil
|
||||
assert @bounced_mail.invalid?
|
||||
end
|
||||
|
||||
def test_bounce_type_is_required
|
||||
assert @bounced_mail.valid?
|
||||
@bounced_mail.bounce_type = nil
|
||||
assert @bounced_mail.invalid?
|
||||
end
|
||||
|
||||
def test_bounce_subtype_is_required
|
||||
assert @bounced_mail.valid?
|
||||
@bounced_mail.bounce_subtype = nil
|
||||
assert @bounced_mail.invalid?
|
||||
end
|
||||
|
||||
def test_action_is_required
|
||||
assert @bounced_mail.valid?
|
||||
@bounced_mail.action = nil
|
||||
assert @bounced_mail.invalid?
|
||||
end
|
||||
|
||||
def test_status_is_required
|
||||
assert @bounced_mail.valid?
|
||||
@bounced_mail.status = nil
|
||||
assert @bounced_mail.invalid?
|
||||
end
|
||||
|
||||
def test_diagnostic_is_not_required
|
||||
assert @bounced_mail.valid?
|
||||
@bounced_mail.diagnostic = nil
|
||||
assert @bounced_mail.valid?
|
||||
end
|
||||
|
||||
def test_bounce_reason_is_determined_dynamically
|
||||
assert @bounced_mail.valid?
|
||||
assert_equal 'failed (5.1.1 smtp; 550 5.1.1 user unknown)', @bounced_mail.bounce_reason
|
||||
end
|
||||
|
||||
def test_creates_objects_from_sns_json
|
||||
BouncedMailAddress.record(sns_bounce_payload)
|
||||
|
||||
bounced_mail = BouncedMailAddress.last
|
||||
assert_equal domains(:shop).registrant.email, bounced_mail.email
|
||||
assert_equal 'failed', bounced_mail.action
|
||||
assert_equal '5.1.1', bounced_mail.status
|
||||
assert_equal 'smtp; 550 5.1.1 user unknown', bounced_mail.diagnostic
|
||||
end
|
||||
|
||||
def sns_bounce_payload
|
||||
{
|
||||
"notificationType": "Bounce",
|
||||
"mail": {
|
||||
"source": "noreply@registry.test",
|
||||
"sourceIp": "195.43.86.5",
|
||||
"messageId": "010f0174a0c7d348-ea6e2fc1-0854-4073-b71f-5cecf9b0d0b2-000000",
|
||||
"sourceArn": "arn:aws:ses:us-east-2:65026820000:identity/noreply@registry.test",
|
||||
"timestamp": "2020-09-18T10:34:44.000Z",
|
||||
"destination": [ "#{domains(:shop).registrant.email}" ],
|
||||
"sendingAccountId": "650268220000"
|
||||
},
|
||||
"bounce": {
|
||||
"timestamp": "2020-09-18T10:34:44.911Z",
|
||||
"bounceType": "Permanent",
|
||||
"feedbackId": "010f0174a0c7d4f9-27d59756-6111-4d5f-xxxx-26bee0d55fa2-000000",
|
||||
"remoteMtaIp": "127.0.01",
|
||||
"reportingMTA": "dsn; xxx.amazonses.com",
|
||||
"bounceSubType": "General",
|
||||
"bouncedRecipients": [
|
||||
{
|
||||
"action": "failed",
|
||||
"status": "5.1.1",
|
||||
"emailAddress": "#{domains(:shop).registrant.email}",
|
||||
"diagnosticCode": "smtp; 550 5.1.1 user unknown"
|
||||
}
|
||||
]
|
||||
}
|
||||
}.as_json
|
||||
end
|
||||
end
|
|
@ -1,18 +1,20 @@
|
|||
require 'test_helper'
|
||||
|
||||
class NewDomainForceDeleteTest < ActiveSupport::TestCase
|
||||
class ForceDeleteTest < ActionMailer::TestCase
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
Setting.redemption_grace_period = 30
|
||||
ActionMailer::Base.deliveries.clear
|
||||
end
|
||||
|
||||
def test_schedules_force_delete_fast_track
|
||||
assert_not @domain.force_delete_scheduled?
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
@domain.schedule_force_delete(type: :fast_track)
|
||||
@domain.schedule_force_delete(type: :fast_track, notify_by_email: true)
|
||||
@domain.reload
|
||||
|
||||
assert_emails 1
|
||||
assert @domain.force_delete_scheduled?
|
||||
assert_equal Date.parse('2010-08-20'), @domain.force_delete_date.to_date
|
||||
assert_equal Date.parse('2010-07-06'), @domain.force_delete_start.to_date
|
||||
|
@ -111,9 +113,12 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
|
|||
|
||||
def test_force_delete_cannot_be_scheduled_when_a_domain_is_discarded
|
||||
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
assert_raises StandardError do
|
||||
@domain.schedule_force_delete(type: :fast_track)
|
||||
end
|
||||
result = Domains::ForceDelete::SetForceDelete.run(domain: @domain, type: :fast_track)
|
||||
|
||||
assert_not result.valid?
|
||||
assert_not @domain.force_delete_scheduled?
|
||||
message = ["Force delete procedure cannot be scheduled while a domain is discarded"]
|
||||
assert_equal message, result.errors.messages[:domain]
|
||||
end
|
||||
|
||||
def test_cancels_force_delete
|
||||
|
@ -201,9 +206,10 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
|
|||
@domain.schedule_force_delete(type: :soft)
|
||||
|
||||
travel_to Time.zone.parse('2010-08-21')
|
||||
DomainCron.start_client_hold
|
||||
Domains::ClientHold::SetClientHold.run!
|
||||
@domain.reload
|
||||
|
||||
assert_emails 1
|
||||
assert_equal(@domain.purge_date.to_date, @domain.force_delete_date.to_date)
|
||||
assert_equal(@domain.outzone_date.to_date, @domain.force_delete_start.to_date +
|
||||
Setting.expire_warning_period.days)
|
||||
|
@ -221,8 +227,10 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
|
|||
@domain.schedule_force_delete(type: :soft)
|
||||
|
||||
travel_to Time.zone.parse('2010-08-21')
|
||||
DomainCron.start_client_hold
|
||||
Domains::ClientHold::SetClientHold.run!
|
||||
@domain.reload
|
||||
|
||||
assert_emails 1
|
||||
assert_includes(@domain.statuses, asserted_status)
|
||||
end
|
||||
|
||||
|
@ -236,7 +244,7 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
|
|||
@domain.schedule_force_delete(type: :soft)
|
||||
|
||||
travel_to Time.zone.parse('2010-07-06')
|
||||
DomainCron.start_client_hold
|
||||
Domains::ClientHold::SetClientHold.run!
|
||||
@domain.reload
|
||||
|
||||
assert_not_includes(@domain.statuses, asserted_status)
|
||||
|
@ -251,7 +259,7 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
|
|||
|
||||
@domain.schedule_force_delete(type: :fast_track)
|
||||
travel_to Time.zone.parse('2010-07-25')
|
||||
DomainCron.start_client_hold
|
||||
Domains::ClientHold::SetClientHold.run!
|
||||
@domain.reload
|
||||
|
||||
assert_includes(@domain.statuses, asserted_status)
|
||||
|
@ -267,7 +275,7 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
|
|||
|
||||
@domain.schedule_force_delete(type: :fast_track)
|
||||
travel_to Time.zone.parse('2010-07-06')
|
||||
DomainCron.start_client_hold
|
||||
Domains::ClientHold::SetClientHold.run!
|
||||
@domain.reload
|
||||
|
||||
assert_not_includes(@domain.statuses, asserted_status)
|
||||
|
|
|
@ -19,7 +19,9 @@ class DomainCronTest < ActiveSupport::TestCase
|
|||
registrant_verification_token: 'test',
|
||||
statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
||||
|
||||
DomainCron.clean_expired_pendings
|
||||
perform_enqueued_jobs do
|
||||
DomainCron.clean_expired_pendings
|
||||
end
|
||||
|
||||
assert_emails 1
|
||||
end
|
||||
|
@ -84,7 +86,9 @@ class DomainCronTest < ActiveSupport::TestCase
|
|||
assert @domain.pending_update?
|
||||
@domain.reload
|
||||
|
||||
DomainCron.clean_expired_pendings
|
||||
perform_enqueued_jobs do
|
||||
DomainCron.clean_expired_pendings
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.pending_update?
|
||||
|
|
|
@ -414,7 +414,7 @@ class DomainTest < ActiveSupport::TestCase
|
|||
force_delete_date: nil)
|
||||
@domain.update(template_name: 'legal_person')
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
@domain.schedule_force_delete(type: :fast_track)
|
||||
Domains::ForceDelete::SetForceDelete.run!(domain: @domain, type: :fast_track)
|
||||
assert(@domain.force_delete_scheduled?)
|
||||
other_registrant = Registrant.find_by(code: 'jane-001')
|
||||
@domain.pending_json['new_registrant_id'] = other_registrant.id
|
||||
|
|
|
@ -70,6 +70,6 @@ class Whois::RecordTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def registration_deadline
|
||||
Time.zone.now + 10.days
|
||||
@registration_deadline ||= Time.zone.now + 10.days
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue