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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
276147c1
Commit
276147c1
authored
Jan 25, 2019
by
Patrick Bajao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Respond with 403 when non-member requests for private MRs
parent
35d4344e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
lib/api/commits.rb
lib/api/commits.rb
+2
-0
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+13
-2
No files found.
lib/api/commits.rb
View file @
276147c1
...
@@ -318,6 +318,8 @@ module API
...
@@ -318,6 +318,8 @@ module API
use
:pagination
use
:pagination
end
end
get
':id/repository/commits/:sha/merge_requests'
,
requirements:
API
::
COMMIT_ENDPOINT_REQUIREMENTS
do
get
':id/repository/commits/:sha/merge_requests'
,
requirements:
API
::
COMMIT_ENDPOINT_REQUIREMENTS
do
authorize!
:read_merge_request
,
user_project
commit
=
user_project
.
commit
(
params
[
:sha
])
commit
=
user_project
.
commit
(
params
[
:sha
])
not_found!
'Commit'
unless
commit
not_found!
'Commit'
unless
commit
...
...
spec/requests/api/commits_spec.rb
View file @
276147c1
...
@@ -1430,8 +1430,8 @@ describe API::Commits do
...
@@ -1430,8 +1430,8 @@ describe API::Commits do
end
end
describe
'GET /projects/:id/repository/commits/:sha/merge_requests'
do
describe
'GET /projects/:id/repository/commits/:sha/merge_requests'
do
let
!
(
:project
)
{
create
(
:project
,
:repository
,
:private
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
:private
)
}
let
!
(
:merged_mr
)
{
create
(
:merge_request
,
source_project:
project
,
source_branch:
'master'
,
target_branch:
'feature'
)
}
let
(
:merged_mr
)
{
create
(
:merge_request
,
source_project:
project
,
source_branch:
'master'
,
target_branch:
'feature'
)
}
let
(
:commit
)
{
merged_mr
.
merge_request_diff
.
commits
.
last
}
let
(
:commit
)
{
merged_mr
.
merge_request_diff
.
commits
.
last
}
it
'returns the correct merge request'
do
it
'returns the correct merge request'
do
...
@@ -1456,5 +1456,16 @@ describe API::Commits do
...
@@ -1456,5 +1456,16 @@ describe API::Commits do
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
context
'public project'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
:public
,
:merge_requests_private
)
}
let
(
:non_member
)
{
create
(
:user
)
}
it
'responds 403 when only members are allowed to read merge requests'
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
id
}
/merge_requests"
,
non_member
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
end
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