Commit 44a22763 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'fe-fix-ee-diff-profile-key-views' into 'master'

Resolve EE differences in app/views/profiles/keys

Closes #6227 and #10506

See merge request gitlab-org/gitlab-ee!13575
parents fcda4f5a a7387bf1
......@@ -59,6 +59,11 @@ class Key < ApplicationRecord
"key-#{id}"
end
# EE overrides this
def can_delete?
true
end
# rubocop: disable CodeReuse/ServiceClass
def update_last_used_at
Keys::LastUsedService.new(self).execute
......
......@@ -18,7 +18,7 @@
.float-right
%span.key-created-at
= s_('Profiles|Created %{time_ago}'.html_safe) % { time_ago:time_ago_with_tooltip(key.created_at)}
- unless key.is_a? LDAPKey
- if key.can_delete?
= link_to path_to_key(key, is_admin), data: { confirm: _('Are you sure?')}, method: :delete, class: "btn btn-transparent prepend-left-10" do
%span.sr-only _('Remove')
= icon('trash')
......@@ -24,5 +24,5 @@
= @key.key
.col-md-12
.float-right
- unless @key.is_a? LDAPKey
- if @key.can_delete?
= link_to _('Remove'), path_to_key(@key, is_admin), data: {confirm: _('Are you sure?')}, method: :delete, class: "btn btn-remove delete-key qa-delete-key-button"
# frozen_string_literal: true
class LDAPKey < Key
def can_delete?
false
end
end
......@@ -83,4 +83,35 @@ describe "Admin::Users" do
end
end
end
describe 'show user keys for SSH and LDAP' do
let!(:key1) do
create(:ldap_key, user: user, title: "LDAP Key1")
end
let!(:key2) do
create(:key, user: user, title: "ssh-rsa Key2", key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4FIEBXGi4bPU8kzxMefudPIJ08/gNprdNTaO9BR/ndy3+58s2HCTw2xCHcsuBmq+TsAqgEidVq4skpqoTMB+Uot5Uzp9z4764rc48dZiI661izoREoKnuRQSsRqUTHg5wrLzwxlQbl1MVfRWQpqiz/5KjBC7yLEb9AbusjnWBk8wvC1bQPQ1uLAauEA7d836tgaIsym9BrLsMVnR4P1boWD3Xp1B1T/ImJwAGHvRmP/ycIqmKdSpMdJXwxcb40efWVj0Ibbe7ii9eeoLdHACqevUZi6fwfbymdow+FeqlkPoHyGg3Cu4vD/D8+8cRc7mE/zGCWcQ15Var83Tczour Key2")
end
it 'only shows the delete button for regular keys' do
visit admin_users_path
click_link user.name
click_link 'SSH keys'
# Check that the regular Key shows the delete icon and the LDAPKey does not
# SSH key should be the first in the list
within('ul.content-list li.key-list-item:nth-of-type(1)') do
expect(page).to have_content(key2.title)
expect(page).to have_css('a[data-method=delete]', text: 'Remove')
end
# Next, LDAP key
within('ul.content-list li.key-list-item:nth-of-type(2)') do
expect(page).to have_content(key1.title)
expect(page).not_to have_css('a[data-method=delete]')
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