Skip to content
代码片段 群组 项目
提交 845e2cf2 编辑于 作者: Doug Stull's avatar Doug Stull
浏览文件

Merge branch 'eduardosanz/add-scim-identities' into 'master'

Display SCIM identities in the identity table

See merge request gitlab-org/gitlab!91922
No related branches found
No related tags found
无相关合并请求
...@@ -22,6 +22,14 @@ def saml_group_cell_testid(identity) ...@@ -22,6 +22,14 @@ def saml_group_cell_testid(identity)
def saml_group_link(identity) def saml_group_link(identity)
'-' '-'
end end
def identity_cells_to_render?(identities, _user)
identities.present?
end
def scim_identities_collection(_user)
[]
end
end end
end end
......
...@@ -11,8 +11,10 @@ ...@@ -11,8 +11,10 @@
%th{ class: 'gl-border-t-0!' }= _('Group') %th{ class: 'gl-border-t-0!' }= _('Group')
%th{ class: 'gl-border-t-0!' }= _('Identifier') %th{ class: 'gl-border-t-0!' }= _('Identifier')
%th{ class: 'gl-border-t-0!' }= _('Actions') %th{ class: 'gl-border-t-0!' }= _('Actions')
= render @identities - if identity_cells_to_render?(@identities, @user)
- if @identities.blank? = render_if_exists partial: 'admin/identities/scim_identity', collection: scim_identities_collection(@user)
= render @identities
- else
%tbody %tbody
%tr %tr
%td{ colspan: '5' } %td{ colspan: '5' }
......
...@@ -31,6 +31,15 @@ def saml_group_link(identity) ...@@ -31,6 +31,15 @@ def saml_group_link(identity)
link_to identity.saml_provider.group.path, identity.saml_provider.group link_to identity.saml_provider.group.path, identity.saml_provider.group
end 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 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 @@ ...@@ -3,18 +3,23 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Admin::IdentitiesHelper do RSpec.describe Admin::IdentitiesHelper do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:saml_provider) { create(:saml_provider, group: group) } let_it_be(:saml_provider) { create(:saml_provider, group: group) }
let_it_be(:saml_identity) do let_it_be(:saml_identity) do
create(:identity, provider: 'group_saml', saml_provider_id: saml_provider.id, user: user, create(:identity, provider: 'group_saml', saml_provider_id: saml_provider.id, extern_uid: 'saml-uid')
extern_uid: 'saml-uid')
end end
let_it_be(:ldap_identity) do let_it_be(:ldap_identity) do
create(:identity, user: user, extern_uid: 'without-saml-uid') create(:identity, extern_uid: 'without-saml-uid')
end 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 describe '#provider_id_cell_testid' do
context 'without SAML provider ID' do context 'without SAML provider ID' do
it 'shows blank provider id for data-testid' do it 'shows blank provider id for data-testid' do
...@@ -70,4 +75,24 @@ ...@@ -70,4 +75,24 @@
end end
end 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 end
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:saml_provider) { create(:saml_provider, group: 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 let_it_be(:saml_identity) do
create(:identity, provider: 'group_saml', saml_provider_id: saml_provider.id, user: saml_user, create(:identity, provider: 'group_saml', saml_provider_id: saml_provider.id, user: saml_user,
extern_uid: 'saml-uid') extern_uid: 'saml-uid')
...@@ -18,9 +18,55 @@ ...@@ -18,9 +18,55 @@
view.lookup_context.prefixes = ['admin/identities'] view.lookup_context.prefixes = ['admin/identities']
end 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 context 'with SAML identities' do
before do before do
assign(:identities, saml_user.identities) assign(:identities, saml_identity)
end end
it 'shows exactly 5 columns' do it 'shows exactly 5 columns' do
......
...@@ -35,4 +35,24 @@ ...@@ -35,4 +35,24 @@
expect(helper.saml_group_link(identity)).to eq '-' expect(helper.saml_group_link(identity)).to eq '-'
end end
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 end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册