diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-05-31 00:40:31 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-05-31 00:41:07 +0300 |
commit | 04bb8fe9942f8558124f00e8cdfb50ef7059bf9e (patch) | |
tree | 2acd5291f542104427f6d61281eaff889e10ec71 /spec | |
parent | 8039b9c3c6caedc19e0e44d086a007e8975134b7 (diff) |
Return nil when looking up config for unknown LDAP provider
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/o_auth/provider_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/lib/gitlab/o_auth/provider_spec.rb b/spec/lib/gitlab/o_auth/provider_spec.rb new file mode 100644 index 00000000000..1e2a1f8c039 --- /dev/null +++ b/spec/lib/gitlab/o_auth/provider_spec.rb @@ -0,0 +1,42 @@ +require 'spec_helper' + +describe Gitlab::OAuth::Provider, lib: true do + describe '#config_for' do + context 'for an LDAP provider' do + context 'when the provider exists' do + it 'returns the config' do + expect(described_class.config_for('ldapmain')).to be_a(Hash) + end + end + + context 'when the provider does not exist' do + it 'returns nil' do + expect(described_class.config_for('ldapfoo')).to be_nil + end + end + end + + context 'for an OmniAuth provider' do + before do + provider = OpenStruct.new( + name: 'google', + app_id: 'asd123', + app_secret: 'asd123' + ) + allow(Gitlab.config.omniauth).to receive(:providers).and_return([provider]) + end + + context 'when the provider exists' do + it 'returns the config' do + expect(described_class.config_for('google')).to be_a(OpenStruct) + end + end + + context 'when the provider does not exist' do + it 'returns nil' do + expect(described_class.config_for('foo')).to be_nil + end + end + end + end +end |