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
af3ba90a
Commit
af3ba90a
authored
Aug 29, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add group ldap_sync endpoint
parent
1152adc9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
0 deletions
+83
-0
lib/api/groups.rb
lib/api/groups.rb
+11
-0
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+72
-0
No files found.
lib/api/groups.rb
View file @
af3ba90a
...
...
@@ -200,6 +200,17 @@ module API
render_api_error!
(
"Failed to transfer project
#{
project
.
errors
.
messages
}
"
,
400
)
end
end
desc
'Sync a group with LDAP.'
post
":id/ldap_sync"
do
group
=
find_group!
(
params
[
:id
])
authorize!
:admin_group
,
group
status
202
if
group
.
pending_ldap_sync
LdapGroupSyncWorker
.
perform_async
(
group
.
id
)
end
end
end
end
end
spec/requests/api/groups_spec.rb
View file @
af3ba90a
...
...
@@ -670,4 +670,76 @@ describe API::Groups do
end
end
end
describe
'POST /groups/:id/ldap_sync'
do
context
'when authenticated as the group owner'
do
context
'when the group is ready to sync'
do
it
'returns 202 Accepted'
do
post
api
(
"/groups/
#{
group1
.
id
}
/ldap_sync"
,
user1
)
expect
(
response
).
to
have_http_status
(
202
)
end
it
'queues a sync job'
do
Sidekiq
::
Testing
.
fake!
do
expect
{
post
api
(
"/groups/
#{
group1
.
id
}
/ldap_sync"
,
user1
)
}.
to
change
(
LdapGroupSyncWorker
.
jobs
,
:size
).
by
(
1
)
end
end
it
'sets the ldap_sync state to pending'
do
post
api
(
"/groups/
#{
group1
.
id
}
/ldap_sync"
,
user1
)
expect
(
group1
.
reload
.
ldap_sync_pending?
).
to
be_truthy
end
end
context
'when the group is already pending a sync'
do
before
do
group1
.
pending_ldap_sync!
end
it
'returns 202 Accepted'
do
post
api
(
"/groups/
#{
group1
.
id
}
/ldap_sync"
,
user1
)
expect
(
response
).
to
have_http_status
(
202
)
end
it
'does not queue a sync job'
do
Sidekiq
::
Testing
.
fake!
do
expect
{
post
api
(
"/groups/
#{
group1
.
id
}
/ldap_sync"
,
user1
)
}.
not_to
change
(
LdapGroupSyncWorker
.
jobs
,
:size
)
end
end
it
'does not change the ldap_sync state'
do
expect
do
post
api
(
"/groups/
#{
group1
.
id
}
/ldap_sync"
,
user1
)
end
.
not_to
change
{
group1
.
reload
.
ldap_sync_status
}
end
end
it
'returns 404 for a non existing group'
do
post
api
(
'/groups/1328/ldap_sync'
,
user1
)
expect
(
response
).
to
have_http_status
(
404
)
end
end
context
'when authenticated as the admin'
do
it
'returns 202 Accepted'
do
post
api
(
"/groups/
#{
group1
.
id
}
/ldap_sync"
,
admin
)
expect
(
response
).
to
have_http_status
(
202
)
end
end
context
'when authenticated as an user that can see the group'
do
it
'does not updates the group'
do
post
api
(
"/groups/
#{
group1
.
id
}
/ldap_sync"
,
user2
)
expect
(
response
).
to
have_http_status
(
403
)
end
end
context
'when authenticated as an user that cannot see the group'
do
it
'returns 404 when trying to update the group'
do
post
api
(
"/groups/
#{
group2
.
id
}
/ldap_sync"
,
user1
)
expect
(
response
).
to
have_http_status
(
404
)
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