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
be1b386c
Commit
be1b386c
authored
Dec 03, 2021
by
Igor Drozdov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix permissions for label promotion via API
Changelog: fixed
parent
e30d909d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
lib/api/helpers/label_helpers.rb
lib/api/helpers/label_helpers.rb
+5
-1
spec/requests/api/labels_spec.rb
spec/requests/api/labels_spec.rb
+16
-0
No files found.
lib/api/helpers/label_helpers.rb
View file @
be1b386c
...
...
@@ -105,7 +105,11 @@ module API
end
def
promote_label
(
parent
)
authorize!
:admin_label
,
parent
unless
parent
.
group
render_api_error!
(
'Failed to promote project label to group label'
,
400
)
end
authorize!
:admin_label
,
parent
.
group
label
=
find_label
(
parent
,
params
[
:name
],
include_ancestor_groups:
false
)
...
...
spec/requests/api/labels_spec.rb
View file @
be1b386c
...
...
@@ -589,6 +589,15 @@ RSpec.describe API::Labels do
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
it
'returns 403 if reporter promotes label'
do
reporter
=
create
(
:user
)
project
.
add_reporter
(
reporter
)
put
api
(
"/projects/
#{
project
.
id
}
/labels/promote"
,
reporter
),
params:
{
name:
label1
.
name
}
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
it
'returns 404 if label does not exist'
do
put
api
(
"/projects/
#{
project
.
id
}
/labels/promote"
,
user
),
params:
{
name:
'unknown'
}
...
...
@@ -601,6 +610,13 @@ RSpec.describe API::Labels do
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'error'
]).
to
eq
(
'name is missing'
)
end
it
'returns 400 if project does not have a group'
do
project
=
create
(
:project
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
put
api
(
"/projects/
#{
project
.
id
}
/labels/promote"
,
user
),
params:
{
name:
label1
.
name
}
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
end
describe
"POST /projects/:id/labels/:label_id/subscribe"
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