-
-
Notifications
You must be signed in to change notification settings - Fork 926
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
686a9c1
commit e972c08
Showing
1 changed file
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,6 @@ class MailerTest < ActionMailer::TestCase | |
create(:rubygem, owners: [user], downloads: MIN_DOWNLOADS_FOR_MFA_REQUIRED_POLICY) | ||
|
||
@io_output, _error = capture_io { Rake::Task["mfa_policy:reminder_enable_mfa"].execute } | ||
|
||
Delayed::Worker.new.work_off | ||
|
||
refute_empty ActionMailer::Base.deliveries | ||
|
@@ -41,6 +40,44 @@ class MailerTest < ActionMailer::TestCase | |
assert_match "Thank you for making the RubyGems ecosystem more secure", email.text_part.body.to_s | ||
assert_match "Sending 1 MFA reminder email", @io_output | ||
end | ||
|
||
should "send mail to users with with more than 180M+ downloads and have weak MFA" do | ||
user = create(:user, mfa_level: "ui_only") | ||
create(:rubygem, owners: [user], downloads: MIN_DOWNLOADS_FOR_MFA_REQUIRED_POLICY) | ||
|
||
@io_output, _error = capture_io { Rake::Task["mfa_policy:reminder_enable_mfa"].execute } | ||
Delayed::Worker.new.work_off | ||
|
||
refute_empty ActionMailer::Base.deliveries | ||
email = ActionMailer::Base.deliveries.last | ||
assert_equal [user.email], email.to | ||
assert_equal ["[email protected]"], email.from | ||
assert_equal "[Action Required] Enable multi-factor authentication on your RubyGems account by August 15", email.subject | ||
assert_match "Recently, we've announced our security-focused ambitions to the community.", email.text_part.body.to_s | ||
assert_match "Sending 1 MFA reminder email", @io_output | ||
end | ||
|
||
should "not send mail to users with with more than 180M+ downloads and have strong MFA" do | ||
user = create(:user, mfa_level: "ui_and_api") | ||
create(:rubygem, owners: [user], downloads: MIN_DOWNLOADS_FOR_MFA_REQUIRED_POLICY) | ||
|
||
@io_output, _error = capture_io { Rake::Task["mfa_policy:reminder_enable_mfa"].execute } | ||
Delayed::Worker.new.work_off | ||
|
||
assert_empty ActionMailer::Base.deliveries | ||
assert_match "Sending 0 MFA announcement email", @io_output | ||
end | ||
|
||
should "not send mail to users with with less than 180M downloads" do | ||
user = create(:user) | ||
create(:rubygem, owners: [user], downloads: MIN_DOWNLOADS_FOR_MFA_REQUIRED_POLICY - 1) | ||
|
||
@io_output, _error = capture_io { Rake::Task["mfa_policy:reminder_enable_mfa"].execute } | ||
Delayed::Worker.new.work_off | ||
|
||
assert_empty ActionMailer::Base.deliveries | ||
assert_match "Sending 0 MFA announcement email", @io_output | ||
end | ||
end | ||
|
||
teardown do | ||
|