Commit a66d7fa5 authored by Miguel Rincon's avatar Miguel Rincon

Merge branch '250354-credential-inventory-mailer' into 'master'

Add CredentialsInventoryMailer

See merge request gitlab-org/gitlab!45884
parents 5ec707ed 378536cc
# frozen_string_literal: true
class CredentialsInventoryMailer < ApplicationMailer
helper EmailsHelper
layout 'mailer'
def personal_access_token_revoked_email(token:, revoked_by:)
@revoked_by = revoked_by
@token = token
mail(
to: token.user.notification_email,
subject: _('Your Personal Access Token was revoked')
)
end
def ssh_key_deleted_email(key:, deleted_by:)
@deleted_by = deleted_by
@key = key
mail(
to: key.user.notification_email,
subject: _('Your SSH key was deleted')
)
end
end
%p
= _("The following Personal Access Token was revoked by an administrator, %{username}.") % { username: @revoked_by.username }
%ul
%li
= @token.name
%li
= _("Created on %{created_at}") % { created_at: @token.created_at.to_date.to_s(:medium) }
- if @token.last_used_at
%li
= _("Last used %{last_used_at} ago") % { last_used_at: time_ago_in_words(@token.last_used_at) }
%li
= _("Scopes: %{scope_list}") % { scope_list: @token.scopes.join(', ') }
%p
= html_escape(_("You can create a new %{link}.")) % { link: link_to(_('Personal Access Token'), profile_personal_access_tokens_url.html_safe) }
= _("The following Personal Access Token was revoked by an administrator, %{username}.") % { username: @revoked_by.username }
= @token.name
= _("Created on %{created_at}") % { created_at: @token.created_at.to_date.to_s(:medium) }
- if @token.last_used_at
= _("Last used %{last_used_at} ago") % { last_used_at: time_ago_in_words(@token.last_used_at) }
= _("Scopes: %{scope_list}") % { scope_list: @token.scopes.join(', ') }
= html_escape(_("You can create a new Personal Access Token by visiting %{link}")) % { link: profile_personal_access_tokens_url.html_safe }
%p
= _("The following SSH key was deleted by an administrator, %{username}.") % { username: @deleted_by.username }
%ul
%li
= @key.title
%li
= _("Created on %{created_at}") % { created_at: @key.created_at.to_date.to_s(:medium) }
- if @key.last_used_at
%li
= _("Last used %{last_used_at} ago") % { last_used_at: time_ago_in_words(@key.last_used_at) }
%p
= html_escape(_("You can create a new %{link}.")) % { link: link_to(_('SSH key'), profile_keys_url.html_safe) }
= _("The following SSH key was deleted by an administrator, %{username}.") % { username: @deleted_by.username }
= @key.title
= _("Created on %{created_at}") % { created_at: @key.created_at.to_date.to_s(:medium) }
- if @key.last_used_at
= _("Last used %{last_used_at} ago") % { last_used_at: time_ago_in_words(@key.last_used_at) }
= html_escape(_("You can create a new SSH key by visiting %{link}")) % { link: profile_keys_url.html_safe }
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe CredentialsInventoryMailer do
include EmailSpec::Matchers
let_it_be(:administrator) { create(:user, :admin, username: 'Revoker') }
describe '#personal_access_token_revoked_email' do
let_it_be(:token) { create(:personal_access_token, scopes: %w(api sudo), last_used_at: 3.weeks.ago) }
subject(:email) { described_class.personal_access_token_revoked_email(token: token, revoked_by: administrator) }
it { is_expected.to have_subject 'Your Personal Access Token was revoked' }
it { is_expected.to have_body_text 'The following Personal Access Token was revoked by an administrator, Revoker' }
it { is_expected.to have_body_text token.name }
it { is_expected.to have_body_text "Created on #{token.created_at.to_date.to_s(:medium)}" }
it { is_expected.to have_body_text 'Scopes: api, sudo'}
it { is_expected.to be_delivered_to [token.user.notification_email] }
it { is_expected.to have_body_text 'Last used 21 days ago' }
end
describe '#ssh_key_deleted_email' do
let_it_be(:ssh_key) { create(:personal_key, last_used_at: 3.weeks.ago) }
subject(:email) { described_class.ssh_key_deleted_email(key: ssh_key, deleted_by: administrator) }
it { is_expected.to have_subject 'Your SSH key was deleted' }
it { is_expected.to have_body_text 'The following SSH key was deleted by an administrator, Revoker' }
it { is_expected.to be_delivered_to [ssh_key.user.notification_email] }
it { is_expected.to have_body_text ssh_key.title }
it { is_expected.to have_body_text "Created on #{ssh_key.created_at.to_date.to_s(:medium)}" }
it { is_expected.to have_body_text 'Last used 21 days ago' }
end
end
......@@ -7791,6 +7791,9 @@ msgstr ""
msgid "Created on"
msgstr ""
msgid "Created on %{created_at}"
msgstr ""
msgid "Created on:"
msgstr ""
......@@ -15306,6 +15309,9 @@ msgstr ""
msgid "Last used"
msgstr ""
msgid "Last used %{last_used_at} ago"
msgstr ""
msgid "Last used on:"
msgstr ""
......@@ -22938,6 +22944,9 @@ msgstr ""
msgid "SSH host keys are not available on this system. Please use %{ssh_keyscan} command or contact your GitLab administrator for more information."
msgstr ""
msgid "SSH key"
msgstr ""
msgid "SSH keys allow you to establish a secure connection between your computer and GitLab."
msgstr ""
......@@ -23046,6 +23055,9 @@ msgstr ""
msgid "Scopes can't be blank"
msgstr ""
msgid "Scopes: %{scope_list}"
msgstr ""
msgid "Score"
msgstr ""
......@@ -26244,6 +26256,12 @@ msgstr ""
msgid "The following %{user} can also push to this branch: %{branch}"
msgstr ""
msgid "The following Personal Access Token was revoked by an administrator, %{username}."
msgstr ""
msgid "The following SSH key was deleted by an administrator, %{username}."
msgstr ""
msgid "The following items will NOT be exported:"
msgstr ""
......@@ -30138,6 +30156,15 @@ msgstr ""
msgid "You can always edit this later"
msgstr ""
msgid "You can create a new %{link}."
msgstr ""
msgid "You can create a new Personal Access Token by visiting %{link}"
msgstr ""
msgid "You can create a new SSH key by visiting %{link}"
msgstr ""
msgid "You can create a new one or check them in your %{pat_link_start}personal access tokens%{pat_link_end} settings"
msgstr ""
......@@ -30582,6 +30609,9 @@ msgstr ""
msgid "Your License"
msgstr ""
msgid "Your Personal Access Token was revoked"
msgstr ""
msgid "Your Personal Access Tokens will expire in %{days_to_expire} days or less"
msgstr ""
......@@ -30597,6 +30627,9 @@ msgstr ""
msgid "Your Public Email will be displayed on your public profile."
msgstr ""
msgid "Your SSH key was deleted"
msgstr ""
msgid "Your SSH keys (%{count})"
msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment