diff options
author | Manoj MJ <mmj@gitlab.com> | 2019-06-19 06:04:33 +0000 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2019-06-19 06:04:33 +0000 |
commit | 83163fab43ba6d8262f6adbc8359acbeadf80f46 (patch) | |
tree | 375bd038132381db47baa206e9a0cd8843934d45 /spec/lib/gitlab/external_authorization | |
parent | 51267258d1c39835c995eaaf29b7df678334ded1 (diff) | |
download | gitlab-ce-83163fab43ba6d8262f6adbc8359acbeadf80f46.tar.gz |
Adds identity information while making external authorization requests
Issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/61201#
Diffstat (limited to 'spec/lib/gitlab/external_authorization')
-rw-r--r-- | spec/lib/gitlab/external_authorization/client_spec.rb | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/spec/lib/gitlab/external_authorization/client_spec.rb b/spec/lib/gitlab/external_authorization/client_spec.rb index fa18c1e56e8..a87f50b4586 100644 --- a/spec/lib/gitlab/external_authorization/client_spec.rb +++ b/spec/lib/gitlab/external_authorization/client_spec.rb @@ -19,7 +19,8 @@ describe Gitlab::ExternalAuthorization::Client do it 'adds the correct params for the user to the body of the request' do expected_body = { user_identifier: 'dummy_user@example.com', - project_classification_label: 'dummy_label' + project_classification_label: 'dummy_label', + identities: [] }.to_json expect(Excon).to receive(:post) .with(dummy_url, hash_including(body: expected_body)) @@ -81,10 +82,11 @@ describe Gitlab::ExternalAuthorization::Client do provider: 'ldapprovider') end - it 'includes the ldap dn for ldap users' do + it 'includes the ldap dn and identities for ldap users' do expected_body = { user_identifier: 'dummy_user@example.com', project_classification_label: 'dummy_label', + identities: [{ provider: 'ldapprovider', extern_uid: 'external id' }], user_ldap_dn: 'external id' }.to_json expect(Excon).to receive(:post) @@ -93,5 +95,28 @@ describe Gitlab::ExternalAuthorization::Client do client.request_access end end + + describe 'for non-ldap users with identities' do + before do + %w(twitter facebook).each do |provider| + create(:identity, provider: provider, extern_uid: "#{provider}_external_id", user: user) + end + end + + it 'includes all the identities' do + expected_body = { + user_identifier: 'dummy_user@example.com', + project_classification_label: 'dummy_label', + identities: [ + { provider: 'twitter', extern_uid: 'twitter_external_id' }, + { provider: 'facebook', extern_uid: 'facebook_external_id' } + ] + }.to_json + expect(Excon).to receive(:post) + .with(dummy_url, hash_including(body: expected_body)) + + client.request_access + end + end end end |