Commit 3c83847b authored by Vitaly Slobodin's avatar Vitaly Slobodin

Merge branch '333242-show-gpg-key-on-gitlab-profile-page' into 'master'

Add link to public GPG keys on user profile

See merge request gitlab-org/gitlab!68678
parents a52ff217 da1ad884
......@@ -26,6 +26,13 @@
= link_to new_abuse_report_path(user_id: @user.id, ref_url: request.referer), class: link_classes + 'btn gl-button btn-default btn-icon',
title: s_('UserProfile|Report abuse'), data: { toggle: 'tooltip', placement: 'bottom', container: 'body' } do
= sprite_icon('error')
- verified_gpg_keys = @user.gpg_keys.select(&:verified?)
- if verified_gpg_keys.any?
= link_to user_gpg_keys_path,
class: link_classes + 'btn btn-default btn-md gl-button btn-icon has-tooltip',
title: n_('View public GPG key', 'View public GPG keys', verified_gpg_keys.length),
data: { toggle: 'tooltip', placement: 'bottom', container: 'body' } do
= sprite_icon('key', css_class: 'gl-button-icon gl-icon')
- if can?(current_user, :read_user_profile, @user)
= link_to user_path(@user, rss_url_options), class: link_classes + 'btn gl-button btn-default btn-icon has-tooltip',
title: s_('UserProfile|Subscribe'), data: { toggle: 'tooltip', placement: 'bottom', container: 'body' } do
......
......@@ -64,7 +64,7 @@ constraints(::Constraints::UserUrlConstrainer.new) do
get ':username.keys' => 'users#ssh_keys', constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }
# Get all GPG keys of user
get ':username.gpg' => 'users#gpg_keys', constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }
get ':username.gpg' => 'users#gpg_keys', as: 'user_gpg_keys', constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }
scope(path: ':username',
as: :user,
......
......@@ -19,6 +19,11 @@ NOTE:
The term GPG is used for all OpenPGP/PGP/GPG related material and
implementations.
To view a user's public GPG key, you can:
- Go to `https://gitlab.example.com/<username>.gpg`.
- Select **View public GPG keys** (**{key}**) in the top right of the user's profile.
GPG verified tags are not supported yet.
See the [further reading](#further-reading) section for more details on GPG.
......
......@@ -36989,6 +36989,11 @@ msgstr ""
msgid "View project labels"
msgstr ""
msgid "View public GPG key"
msgid_plural "View public GPG keys"
msgstr[0] ""
msgstr[1] ""
msgid "View replaced file @ "
msgstr ""
......
......@@ -429,4 +429,27 @@ RSpec.describe 'User page' do
end
end
end
context 'GPG keys' do
context 'when user has verified GPG keys' do
let_it_be(:user) { create(:user, email: GpgHelpers::User1.emails.first) }
let_it_be(:gpg_key) { create(:gpg_key, user: user, key: GpgHelpers::User1.public_key) }
let_it_be(:gpg_key2) { create(:gpg_key, user: user, key: GpgHelpers::User1.public_key2) }
it 'shows link to public GPG keys' do
subject
expect(page).to have_link('View public GPG keys', href: user_gpg_keys_path(user))
end
end
context 'when user does not have verified GPG keys' do
it 'does not show link to public GPG keys' do
subject
expect(page).not_to have_link('View public GPG key', href: user_gpg_keys_path(user))
expect(page).not_to have_link('View public GPG keys', href: user_gpg_keys_path(user))
end
end
end
end
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