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
8744b88d
Commit
8744b88d
authored
Oct 01, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LDAP groups api
parent
5cd06603
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
0 deletions
+54
-0
lib/api/ldap.rb
lib/api/ldap.rb
+18
-0
spec/requests/api/ldap_spec.rb
spec/requests/api/ldap_spec.rb
+36
-0
No files found.
lib/api/ldap.rb
0 → 100644
View file @
8744b88d
module
API
# groups API
class
Ldap
<
Grape
::
API
before
{
authenticate!
}
resource
:ldap
do
# 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
@groups
=
Gitlab
::
LDAP
::
Adapter
.
new
.
groups
(
"
#{
params
[
:search
]
}
*"
,
20
)
present
@groups
,
with:
Entities
::
LdapGroup
end
end
end
end
spec/requests/api/ldap_spec.rb
0 → 100644
View file @
8744b88d
require
'spec_helper'
describe
API
::
API
do
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
before
do
groups
=
[
OpenStruct
.
new
(
cn:
'developers'
),
OpenStruct
.
new
(
cn:
'students'
)
]
Gitlab
::
LDAP
::
Adapter
.
any_instance
.
stub
(
groups:
groups
)
end
describe
"GET /ldap/groups"
do
context
"when unauthenticated"
do
it
"should return authentication error"
do
get
api
(
"/ldap/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/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