Skip to content
代码片段 群组 项目
提交 e9f032ed 编辑于 作者: Eduardo Sanz García's avatar Eduardo Sanz García 提交者: Doug Stull
浏览文件

Display SCIM identities in the identity table

For EE admin users, SCIM identities are now shown under `Admin >
Overview > Users > USER > identity tab`

Changelog: added
EE: true
上级 1a7ea2cb
No related branches found
No related tags found
无相关合并请求
......@@ -22,6 +22,14 @@ def saml_group_cell_testid(identity)
def saml_group_link(identity)
'-'
end
def identity_cells_to_render?(identities, _user)
identities.present?
end
def scim_identities_collection(_user)
[]
end
end
end
......
......@@ -11,8 +11,10 @@
%th{ class: 'gl-border-t-0!' }= _('Group')
%th{ class: 'gl-border-t-0!' }= _('Identifier')
%th{ class: 'gl-border-t-0!' }= _('Actions')
= render @identities
- if @identities.blank?
- if identity_cells_to_render?(@identities, @user)
= render_if_exists partial: 'admin/identities/scim_identity', collection: scim_identities_collection(@user)
= render @identities
- else
%tbody
%tr
%td{ colspan: '5' }
......
......@@ -31,6 +31,15 @@ def saml_group_link(identity)
link_to identity.saml_provider.group.path, identity.saml_provider.group
end
def identity_cells_to_render?(identities, user)
super || user.scim_identities.present?
end
override :scim_identities_collection
def scim_identities_collection(user)
user.scim_identities
end
end
end
end
%tr
%td
SCIM
%td{ data: { testid: 'provider_id_blank' } }
= '-'
%td
= link_to scim_identity.group.path, scim_identity.group
%td
= scim_identity.extern_uid
%td
......@@ -3,18 +3,23 @@
require 'spec_helper'
RSpec.describe Admin::IdentitiesHelper do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:saml_provider) { create(:saml_provider, group: group) }
let_it_be(:saml_identity) do
create(:identity, provider: 'group_saml', saml_provider_id: saml_provider.id, user: user,
extern_uid: 'saml-uid')
create(:identity, provider: 'group_saml', saml_provider_id: saml_provider.id, extern_uid: 'saml-uid')
end
let_it_be(:ldap_identity) do
create(:identity, user: user, extern_uid: 'without-saml-uid')
create(:identity, extern_uid: 'without-saml-uid')
end
let_it_be(:user_without_scim_identities) { create(:user) }
let_it_be(:scim_identity) do
create(:scim_identity, group: group, extern_uid: 'scim-uid')
end
let_it_be(:user_with_scim_identities) { scim_identity.user }
describe '#provider_id_cell_testid' do
context 'without SAML provider ID' do
it 'shows blank provider id for data-testid' do
......@@ -70,4 +75,24 @@
end
end
end
describe '#identity_cells_to_render?' do
context 'without SCIM identies' do
it 'returns false' do
expect(helper.identity_cells_to_render?([], user_without_scim_identities)).to eq false
end
end
context 'with SCIM identities' do
it 'returns true' do
expect(helper.identity_cells_to_render?([], user_with_scim_identities)).to eq true
end
end
end
describe '#scim_identities_collection' do
it 'returns SCIM identities' do
expect(helper.scim_identities_collection(user_with_scim_identities)).to match_array [scim_identity]
end
end
end
......@@ -7,7 +7,7 @@
let_it_be(:group) { create(:group) }
let_it_be(:saml_provider) { create(:saml_provider, group: group) }
let_it_be(:saml_user) { create(:user) }
let_it_be(:saml_user, refind: true) { create(:user) }
let_it_be(:saml_identity) do
create(:identity, provider: 'group_saml', saml_provider_id: saml_provider.id, user: saml_user,
extern_uid: 'saml-uid')
......@@ -18,9 +18,55 @@
view.lookup_context.prefixes = ['admin/identities']
end
context 'without SCIM or other identities' do
before do
assign(:identities, [])
end
it 'shows information text' do
render
expect(rendered).to include('<td colspan="5">').exactly(1)
expect(rendered).to include(_('This user has no identities'))
end
end
context 'with SCIM identities' do
before_all do
create(:scim_identity, group: group, extern_uid: 'scim-uid', user: saml_user)
assign(:identities, [])
end
it 'shows exactly 5 columns' do
render
expect(rendered).to include('</td>').exactly(5)
end
it 'shows identity without provider ID' do
render
# Provider
expect(rendered).to include('SCIM')
# Provider ID
expect(rendered).to include('data-testid="provider_id_blank"')
# Group
expect(rendered).to include("<a href=\"/#{group.path}\">#{group.path}</a>")
# Identifier
expect(rendered).to include('scim-uid')
end
it 'shows no edit or delete identity buttons' do
render
expect(rendered).not_to include("aria-label=\"#{_('Edit')}\"")
expect(rendered).not_to include("aria-label=\"#{_('Delete identity')}\"")
end
end
context 'with SAML identities' do
before do
assign(:identities, saml_user.identities)
assign(:identities, saml_identity)
end
it 'shows exactly 5 columns' do
......
......@@ -35,4 +35,24 @@
expect(helper.saml_group_link(identity)).to eq '-'
end
end
describe '#identity_cells_to_render?' do
context 'without identities' do
it 'returns false' do
expect(helper.identity_cells_to_render?([], user)).to eq false
end
end
context 'with identities' do
it 'returns true' do
expect(helper.identity_cells_to_render?(identity, user)).to eq true
end
end
end
describe '#scim_identities_collection' do
it 'returns empty array' do
expect(helper.scim_identities_collection(user)).to eq []
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册