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
8fcbe210
Commit
8fcbe210
authored
Nov 22, 2017
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ProtectedBranch API includes user_id/group_id in access levels
Closes
https://gitlab.com/gitlab-org/gitlab-ee/issues/4152
parent
b0a4675a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
4 deletions
+48
-4
changelogs/unreleased-ee/jej-protected-branch-api-includes-user-ids.yml
...eleased-ee/jej-protected-branch-api-includes-user-ids.yml
+5
-0
doc/api/protected_branches.md
doc/api/protected_branches.md
+16
-4
lib/api/entities.rb
lib/api/entities.rb
+6
-0
spec/requests/api/protected_branches_spec.rb
spec/requests/api/protected_branches_spec.rb
+21
-0
No files found.
changelogs/unreleased-ee/jej-protected-branch-api-includes-user-ids.yml
0 → 100644
View file @
8fcbe210
---
title
:
EE Protected Branches API access levels include user_id/group_id where relevant
merge_request
:
3535
author
:
type
:
changed
doc/api/protected_branches.md
View file @
8fcbe210
...
@@ -36,13 +36,17 @@ Example response:
...
@@ -36,13 +36,17 @@ Example response:
"push_access_levels"
:
[
"push_access_levels"
:
[
{
{
"access_level"
:
40
,
"access_level"
:
40
,
"user_id"
:
null
,
"group_id"
:
null
,
"access_level_description"
:
"Masters"
"access_level_description"
:
"Masters"
}
}
],
],
"merge_access_levels"
:
[
"merge_access_levels"
:
[
{
{
"access_level"
:
40
,
"access_level"
:
null
,
"access_level_description"
:
"Masters"
"user_id"
:
null
,
"group_id"
:
1234
,
"access_level_description"
:
"Example Merge Group"
}
}
]
]
},
},
...
@@ -75,13 +79,17 @@ Example response:
...
@@ -75,13 +79,17 @@ Example response:
"push_access_levels"
:
[
"push_access_levels"
:
[
{
{
"access_level"
:
40
,
"access_level"
:
40
,
"user_id"
:
null
,
"group_id"
:
null
,
"access_level_description"
:
"Masters"
"access_level_description"
:
"Masters"
}
}
],
],
"merge_access_levels"
:
[
"merge_access_levels"
:
[
{
{
"access_level"
:
40
,
"access_level"
:
null
,
"access_level_description"
:
"Masters"
"user_id"
:
null
,
"group_id"
:
1234
,
"access_level_description"
:
"Example Merge Group"
}
}
]
]
}
}
...
@@ -115,12 +123,16 @@ Example response:
...
@@ -115,12 +123,16 @@ Example response:
"push_access_levels"
:
[
"push_access_levels"
:
[
{
{
"access_level"
:
30
,
"access_level"
:
30
,
"user_id"
:
null
,
"group_id"
:
null
,
"access_level_description"
:
"Developers + Masters"
"access_level_description"
:
"Developers + Masters"
}
}
],
],
"merge_access_levels"
:
[
"merge_access_levels"
:
[
{
{
"access_level"
:
30
,
"access_level"
:
30
,
"user_id"
:
null
,
"group_id"
:
null
,
"access_level_description"
:
"Developers + Masters"
"access_level_description"
:
"Developers + Masters"
}
}
]
]
...
...
lib/api/entities.rb
View file @
8fcbe210
...
@@ -337,6 +337,12 @@ module API
...
@@ -337,6 +337,12 @@ module API
class
ProtectedRefAccess
<
Grape
::
Entity
class
ProtectedRefAccess
<
Grape
::
Entity
expose
:access_level
expose
:access_level
## EE-only
expose
:user_id
expose
:group_id
## EE-only
expose
:access_level_description
do
|
protected_ref_access
|
expose
:access_level_description
do
|
protected_ref_access
|
protected_ref_access
.
humanize
protected_ref_access
.
humanize
end
end
...
...
spec/requests/api/protected_branches_spec.rb
View file @
8fcbe210
...
@@ -66,6 +66,27 @@ describe API::ProtectedBranches do
...
@@ -66,6 +66,27 @@ describe API::ProtectedBranches do
let
(
:message
)
{
'404 Not found'
}
let
(
:message
)
{
'404 Not found'
}
end
end
end
end
context
'with per user/group access levels'
do
let
(
:push_user
)
{
create
(
:user
)
}
let
(
:merge_group
)
{
create
(
:group
)
}
before
do
protected_branch
.
push_access_levels
.
create!
(
user:
push_user
)
protected_branch
.
merge_access_levels
.
create!
(
group:
merge_group
)
end
it
'returns access level details'
do
get
api
(
route
,
user
)
push_user_ids
=
json_response
[
'push_access_levels'
].
map
{
|
level
|
level
[
'user_id'
]}
merge_group_ids
=
json_response
[
'merge_access_levels'
].
map
{
|
level
|
level
[
'group_id'
]}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
push_user_ids
).
to
include
(
push_user
.
id
)
expect
(
merge_group_ids
).
to
include
(
merge_group
.
id
)
end
end
end
end
context
'when authenticated as a master'
do
context
'when authenticated as a master'
do
...
...
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