BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
04bb8fe9
Commit
04bb8fe9
authored
May 30, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return nil when looking up config for unknown LDAP provider
parent
8039b9c3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
1 deletion
+51
-1
dm-oauth-config-for.yml
changelogs/unreleased/dm-oauth-config-for.yml
+4
-0
provider.rb
lib/gitlab/o_auth/provider.rb
+5
-1
provider_spec.rb
spec/lib/gitlab/o_auth/provider_spec.rb
+42
-0
No files found.
changelogs/unreleased/dm-oauth-config-for.yml
0 → 100644
View file @
04bb8fe9
---
title
:
Return nil when looking up config for unknown LDAP provider
merge_request
:
author
:
lib/gitlab/o_auth/provider.rb
View file @
04bb8fe9
...
...
@@ -22,7 +22,11 @@ module Gitlab
def
self
.
config_for
(
name
)
name
=
name
.
to_s
if
ldap_provider?
(
name
)
Gitlab
::
LDAP
::
Config
.
new
(
name
).
options
if
Gitlab
::
LDAP
::
Config
.
valid_provider?
(
name
)
Gitlab
::
LDAP
::
Config
.
new
(
name
).
options
else
nil
end
else
Gitlab
.
config
.
omniauth
.
providers
.
find
{
|
provider
|
provider
.
name
==
name
}
end
...
...
spec/lib/gitlab/o_auth/provider_spec.rb
0 → 100644
View file @
04bb8fe9
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment