diff options
author | Clement Ho <clemmakesapps@gmail.com> | 2018-03-01 22:33:29 +0000 |
---|---|---|
committer | Clement Ho <clemmakesapps@gmail.com> | 2018-03-01 22:33:29 +0000 |
commit | b112a33b98c657b1d2838c14d598a291a14565e0 (patch) | |
tree | a37cc22491baf419a15b81918ee07c2fd0d8f2da /spec/lib/gitlab/auth/saml/auth_hash_spec.rb | |
parent | 4441ca4ba7bf6c4a68574d018d2bf48e45326654 (diff) | |
parent | 5c4eace67f188da436b3b380a0125d053b29422a (diff) | |
download | gitlab-ce-b112a33b98c657b1d2838c14d598a291a14565e0.tar.gz |
Merge branch 'master' into 'sentiment-analysis'sentiment-analysis
# Conflicts:
# app/assets/javascripts/notes/components/comment_form.vue
Diffstat (limited to 'spec/lib/gitlab/auth/saml/auth_hash_spec.rb')
-rw-r--r-- | spec/lib/gitlab/auth/saml/auth_hash_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/lib/gitlab/auth/saml/auth_hash_spec.rb b/spec/lib/gitlab/auth/saml/auth_hash_spec.rb new file mode 100644 index 00000000000..bb950e6bbf8 --- /dev/null +++ b/spec/lib/gitlab/auth/saml/auth_hash_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +describe Gitlab::Auth::Saml::AuthHash do + include LoginHelpers + + let(:raw_info_attr) { { 'groups' => %w(Developers Freelancers) } } + subject(:saml_auth_hash) { described_class.new(omniauth_auth_hash) } + + let(:info_hash) do + { + name: 'John', + email: 'john@mail.com' + } + end + + let(:omniauth_auth_hash) do + OmniAuth::AuthHash.new(uid: 'my-uid', + provider: 'saml', + info: info_hash, + extra: { raw_info: OneLogin::RubySaml::Attributes.new(raw_info_attr) } ) + end + + before do + stub_saml_group_config(%w(Developers Freelancers Designers)) + end + + describe '#groups' do + it 'returns array of groups' do + expect(saml_auth_hash.groups).to eq(%w(Developers Freelancers)) + end + + context 'raw info hash attributes empty' do + let(:raw_info_attr) { {} } + + it 'returns an empty array' do + expect(saml_auth_hash.groups).to be_a(Array) + end + end + end +end |