Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
6226d19c
Commit
6226d19c
authored
May 18, 2018
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minimize CE/EE difference in Gitlab::Auth::LDAP::Config
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
8b287679
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
3 deletions
+51
-3
lib/gitlab/auth/ldap/config.rb
lib/gitlab/auth/ldap/config.rb
+16
-2
spec/lib/gitlab/auth/ldap/config_spec.rb
spec/lib/gitlab/auth/ldap/config_spec.rb
+35
-1
No files found.
lib/gitlab/auth/ldap/config.rb
View file @
6226d19c
...
...
@@ -11,6 +11,8 @@ module Gitlab
attr_accessor
:provider
,
:options
InvalidProvider
=
Class
.
new
(
StandardError
)
def
self
.
enabled?
Gitlab
.
config
.
ldap
.
enabled
end
...
...
@@ -22,6 +24,10 @@ module Gitlab
def
self
.
available_servers
return
[]
unless
enabled?
_available_servers
end
def
self
.
_available_servers
Array
.
wrap
(
servers
.
first
)
end
...
...
@@ -34,7 +40,7 @@ module Gitlab
end
def
self
.
invalid_provider
(
provider
)
raise
"Unknown provider (
#{
provider
}
). Available providers:
#{
providers
}
"
raise
InvalidProvider
.
new
(
"Unknown provider (
#{
provider
}
). Available providers:
#{
providers
}
"
)
end
def
initialize
(
provider
)
...
...
@@ -84,13 +90,17 @@ module Gitlab
end
def
base
options
[
'base'
]
@base
||=
Person
.
normalize_dn
(
options
[
'base'
])
end
def
uid
options
[
'uid'
]
end
def
label
options
[
'label'
]
end
def
sync_ssh_keys?
sync_ssh_keys
.
present?
end
...
...
@@ -132,6 +142,10 @@ module Gitlab
options
[
'timeout'
].
to_i
end
def
external_groups
options
[
'external_groups'
]
||
[]
end
def
has_auth?
options
[
'password'
]
||
options
[
'bind_dn'
]
end
...
...
spec/lib/gitlab/auth/ldap/config_spec.rb
View file @
6226d19c
...
...
@@ -23,7 +23,7 @@ describe Gitlab::Auth::LDAP::Config do
end
it
'raises an error if a unknown provider is used'
do
expect
{
described_class
.
new
'unknown'
}.
to
raise_error
(
RuntimeErro
r
)
expect
{
described_class
.
new
'unknown'
}.
to
raise_error
(
described_class
::
InvalidProvide
r
)
end
end
...
...
@@ -370,4 +370,38 @@ describe Gitlab::Auth::LDAP::Config do
})
end
end
describe
'#base'
do
context
'when the configured base is not normalized'
do
it
'returns the normalized base'
do
stub_ldap_config
(
options:
{
'base'
=>
'DC=example, DC= com'
})
expect
(
config
.
base
).
to
eq
(
'dc=example,dc=com'
)
end
end
context
'when the configured base is normalized'
do
it
'returns the base unaltered'
do
stub_ldap_config
(
options:
{
'base'
=>
'dc=example,dc=com'
})
expect
(
config
.
base
).
to
eq
(
'dc=example,dc=com'
)
end
end
context
'when the configured base is malformed'
do
it
'returns the base unaltered'
do
stub_ldap_config
(
options:
{
'base'
=>
'invalid,dc=example,dc=com'
})
expect
(
config
.
base
).
to
eq
(
'invalid,dc=example,dc=com'
)
end
end
context
'when the configured base is blank'
do
it
'returns the base unaltered'
do
stub_ldap_config
(
options:
{
'base'
=>
''
})
expect
(
config
.
base
).
to
eq
(
''
)
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