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
Boxiang Sun
gitlab-ce
Commits
74581261
Commit
74581261
authored
Sep 21, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: Return 404 when trying to fork to unaccessible namespace
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
2fea80d5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
lib/api/projects.rb
lib/api/projects.rb
+3
-1
spec/requests/api/fork_spec.rb
spec/requests/api/fork_spec.rb
+2
-2
No files found.
lib/api/projects.rb
View file @
74581261
...
...
@@ -207,7 +207,9 @@ module API
if
namespace_id
.
present?
namespace
=
Namespace
.
find_by
(
id:
namespace_id
)
||
Namespace
.
find_by_path_or_name
(
namespace_id
)
not_found!
(
'Target Namespace'
)
unless
namespace
unless
namespace
&&
can?
(
current_user
,
:create_projects
,
namespace
)
not_found!
(
'Target Namespace'
)
end
attrs
[
:namespace
]
=
namespace
end
...
...
spec/requests/api/fork_spec.rb
View file @
74581261
...
...
@@ -94,7 +94,7 @@ describe API::API, api: true do
it
'fails if trying to fork to another user when not admin'
do
post
api
(
"/projects/fork/
#{
project
.
id
}
"
,
user2
),
namespace:
admin
.
namespace
.
id
expect
(
response
).
to
have_http_status
(
40
9
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
it
'fails if trying to fork to non-existent namespace'
do
...
...
@@ -114,7 +114,7 @@ describe API::API, api: true do
it
'fails to fork to not owned group'
do
post
api
(
"/projects/fork/
#{
project
.
id
}
"
,
user2
),
namespace:
group
.
name
expect
(
response
).
to
have_http_status
(
40
9
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
it
'forks to not owned group when admin'
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