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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
3702eb54
Commit
3702eb54
authored
Oct 10, 2014
by
Jan-Willem van der Meer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new endpoint for specific ldap group listing
parent
f06a60e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
4 deletions
+36
-4
lib/api/ldap.rb
lib/api/ldap.rb
+17
-3
spec/requests/api/ldap_spec.rb
spec/requests/api/ldap_spec.rb
+19
-1
No files found.
lib/api/ldap.rb
View file @
3702eb54
...
...
@@ -4,16 +4,30 @@ module API
before
{
authenticate!
}
resource
:ldap
do
helpers
do
def
get_group_list
(
provider
,
search
)
Gitlab
::
LDAP
::
Adapter
.
new
(
provider
).
groups
(
"
#{
search
}
*"
,
20
)
end
end
# Get a LDAP groups list. Limit size to 20 of them.
# Filter results by name using search param
#
# Example Request:
# GET /ldap/groups
get
'groups'
do
# NOTE: this should be deprecated in favour of /ldap/PROVIDER_NAME/groups
# for now we just select the first LDAP server
provider
=
Gitlab
::
LDAP
::
Config
.
servers
.
first
.
provider_name
@groups
=
Gitlab
::
LDAP
::
Adapter
.
new
(
provider
).
groups
(
"
#{
params
[
:search
]
}
*"
,
20
)
@groups
=
get_group_list
(
provider
,
params
[
:search
])
present
@groups
,
with:
Entities
::
LdapGroup
end
# Get a LDAP groups list by the requested provider. Lited size to 20 of them.
# Filter results by name using search param
#
# Example Request:
# GET /ldap/ldapmain/groups
get
':provider/groups'
do
@groups
=
get_group_list
(
params
[
:provider
],
params
[
:search
])
present
@groups
,
with:
Entities
::
LdapGroup
end
end
...
...
spec/requests/api/ldap_spec.rb
View file @
3702eb54
...
...
@@ -25,7 +25,6 @@ describe API::API do
context
"when authenticated as user"
do
it
"should return an array of ldap groups"
do
pending
(
'Needs refactoring'
)
get
api
(
"/ldap/groups"
,
user
)
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
...
...
@@ -34,4 +33,23 @@ describe API::API do
end
end
end
describe
"GET /ldap/ldapmain/groups"
do
context
"when unauthenticated"
do
it
"should return authentication error"
do
get
api
(
"/ldap/ldapmain/groups"
)
response
.
status
.
should
==
401
end
end
context
"when authenticated as user"
do
it
"should return an array of ldap groups"
do
get
api
(
"/ldap/ldapmain/groups"
,
user
)
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
length
.
should
==
2
json_response
.
first
[
'cn'
].
should
==
'developers'
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