diff options
Diffstat (limited to 'spec/mailers/emails/profile_spec.rb')
-rw-r--r-- | spec/mailers/emails/profile_spec.rb | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/spec/mailers/emails/profile_spec.rb b/spec/mailers/emails/profile_spec.rb index fce55256922..767eddb7f98 100644 --- a/spec/mailers/emails/profile_spec.rb +++ b/spec/mailers/emails/profile_spec.rb @@ -246,6 +246,35 @@ RSpec.describe Emails::Profile do end end + describe 'user personal access token has been revoked' do + let_it_be(:user) { create(:user) } + let_it_be(:token) { create(:personal_access_token, user: user) } + + context 'when valid' do + subject { Notify.access_token_revoked_email(user, token.name) } + + it_behaves_like 'an email sent from GitLab' + it_behaves_like 'it should not have Gmail Actions links' + it_behaves_like 'a user cannot unsubscribe through footer link' + + it 'is sent to the user' do + is_expected.to deliver_to user.email + end + + it 'has the correct subject' do + is_expected.to have_subject /^A personal access token has been revoked$/i + end + + it 'provides the names of the token' do + is_expected.to have_body_text /#{token.name}/ + end + + it 'includes the email reason' do + is_expected.to have_body_text %r{You're receiving this email because of your account on <a .*>localhost<\/a>} + end + end + end + describe 'SSH key notification' do let_it_be_with_reload(:user) { create(:user) } let_it_be(:fingerprints) { ["aa:bb:cc:dd:ee:zz"] } @@ -375,7 +404,7 @@ RSpec.describe Emails::Profile do end it 'includes a link to the change password documentation' do - is_expected.to have_body_text 'https://docs.gitlab.com/ee/user/profile/#changing-your-password' + is_expected.to have_body_text 'https://docs.gitlab.com/ee/user/profile/user_passwords.html#change-your-password' end it 'mentions two factor authentication when two factor is not enabled' do @@ -396,6 +425,39 @@ RSpec.describe Emails::Profile do end end + describe 'user attempted sign in with wrong 2FA OTP email' do + let_it_be(:user) { create(:user) } + let_it_be(:ip) { '169.0.0.1' } + let_it_be(:current_time) { Time.current } + let_it_be(:email) { Notify.two_factor_otp_attempt_failed_email(user, ip, current_time) } + + subject { email } + + it_behaves_like 'an email sent from GitLab' + it_behaves_like 'it should not have Gmail Actions links' + it_behaves_like 'a user cannot unsubscribe through footer link' + + it 'is sent to the user' do + is_expected.to deliver_to user.email + end + + it 'has the correct subject' do + is_expected.to have_subject "Attempted sign in to #{Gitlab.config.gitlab.host} using a wrong two-factor authentication code" + end + + it 'mentions the IP address' do + is_expected.to have_body_text ip + end + + it 'mentioned the time' do + is_expected.to have_body_text current_time.strftime('%Y-%m-%d %H:%M:%S %Z') + end + + it 'includes a link to the change password documentation' do + is_expected.to have_body_text 'https://docs.gitlab.com/ee/user/profile/user_passwords.html#change-your-password' + end + end + describe 'disabled two-factor authentication email' do let_it_be(:user) { create(:user) } |