2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-01-19 16:12:03 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe Admin::IdentitiesController do
|
2016-01-19 16:12:03 +05:30
|
|
|
let(:admin) { create(:admin) }
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(admin)
|
|
|
|
end
|
2016-01-19 16:12:03 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
describe 'GET #index' do
|
|
|
|
context 'when the user has no identities' do
|
|
|
|
it 'shows no identities' do
|
|
|
|
get :index, params: { user_id: admin.username }
|
|
|
|
|
|
|
|
expect(assigns(:user)).to eq(admin)
|
|
|
|
expect(assigns(:identities)).to be_blank
|
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the user has identities' do
|
|
|
|
let(:ldap_user) { create(:omniauth_user, provider: 'ldapmain', extern_uid: 'ldap-uid') }
|
|
|
|
|
|
|
|
it 'shows identities' do
|
|
|
|
get :index, params: { user_id: ldap_user.username }
|
|
|
|
|
|
|
|
expect(assigns(:user)).to eq(ldap_user)
|
|
|
|
expect(assigns(:identities)).to eq(ldap_user.identities)
|
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-01-19 16:12:03 +05:30
|
|
|
describe 'UPDATE identity' do
|
|
|
|
let(:user) { create(:omniauth_user, provider: 'ldapmain', extern_uid: 'uid=myuser,ou=people,dc=example,dc=com') }
|
|
|
|
|
|
|
|
it 'repairs ldap blocks' do
|
2020-01-01 13:55:28 +05:30
|
|
|
expect_next_instance_of(::Users::RepairLdapBlockedService) do |instance|
|
2019-12-26 22:10:19 +05:30
|
|
|
expect(instance).to receive(:execute)
|
|
|
|
end
|
2016-01-19 16:12:03 +05:30
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
put :update, params: { user_id: user.username, id: user.ldap_identity.id, identity: { provider: 'twitter' } }
|
2016-01-19 16:12:03 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'DELETE identity' do
|
|
|
|
let(:user) { create(:omniauth_user, provider: 'ldapmain', extern_uid: 'uid=myuser,ou=people,dc=example,dc=com') }
|
|
|
|
|
|
|
|
it 'repairs ldap blocks' do
|
2020-01-01 13:55:28 +05:30
|
|
|
expect_next_instance_of(::Users::RepairLdapBlockedService) do |instance|
|
2019-12-26 22:10:19 +05:30
|
|
|
expect(instance).to receive(:execute)
|
|
|
|
end
|
2016-01-19 16:12:03 +05:30
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
delete :destroy, params: { user_id: user.username, id: user.ldap_identity.id }
|
2016-01-19 16:12:03 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|