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
41526de5
Commit
41526de5
authored
May 27, 2020
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split namespace check out of project check
For group wiki which only need namespace check.
parent
4786fe61
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
14 deletions
+19
-14
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+3
-2
lib/gitlab/git_access_snippet.rb
lib/gitlab/git_access_snippet.rb
+7
-1
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+9
-11
No files found.
lib/gitlab/git_access.rb
View file @
41526de5
...
@@ -24,6 +24,7 @@ module Gitlab
...
@@ -24,6 +24,7 @@ module Gitlab
deploy_key_upload:
'This deploy key does not have write access to this project.'
,
deploy_key_upload:
'This deploy key does not have write access to this project.'
,
no_repo:
'A repository for this project does not exist yet.'
,
no_repo:
'A repository for this project does not exist yet.'
,
project_not_found:
'The project you were looking for could not be found.'
,
project_not_found:
'The project you were looking for could not be found.'
,
namespace_not_found:
'The namespace you were looking for could not be found.'
,
command_not_allowed:
"The command you're trying to execute is not allowed."
,
command_not_allowed:
"The command you're trying to execute is not allowed."
,
upload_pack_disabled_over_http:
'Pulling over HTTP is not allowed.'
,
upload_pack_disabled_over_http:
'Pulling over HTTP is not allowed.'
,
receive_pack_disabled_over_http:
'Pushing over HTTP is not allowed.'
,
receive_pack_disabled_over_http:
'Pushing over HTTP is not allowed.'
,
...
@@ -73,6 +74,7 @@ module Gitlab
...
@@ -73,6 +74,7 @@ module Gitlab
return
custom_action
if
custom_action
return
custom_action
if
custom_action
check_db_accessibility!
(
cmd
)
check_db_accessibility!
(
cmd
)
check_namespace!
check_project!
(
changes
,
cmd
)
check_project!
(
changes
,
cmd
)
check_repository_existence!
check_repository_existence!
...
@@ -111,7 +113,6 @@ module Gitlab
...
@@ -111,7 +113,6 @@ module Gitlab
private
private
def
check_project!
(
changes
,
cmd
)
def
check_project!
(
changes
,
cmd
)
check_namespace!
ensure_project_on_push!
(
cmd
,
changes
)
ensure_project_on_push!
(
cmd
,
changes
)
check_project_accessibility!
check_project_accessibility!
add_project_moved_message!
add_project_moved_message!
...
@@ -156,7 +157,7 @@ module Gitlab
...
@@ -156,7 +157,7 @@ module Gitlab
def
check_namespace!
def
check_namespace!
return
if
namespace_path
.
present?
return
if
namespace_path
.
present?
raise
NotFoundError
,
ERROR_MESSAGES
[
:
project
_not_found
]
raise
NotFoundError
,
ERROR_MESSAGES
[
:
namespace
_not_found
]
end
end
def
check_active_user!
def
check_active_user!
...
...
lib/gitlab/git_access_snippet.rb
View file @
41526de5
...
@@ -39,11 +39,17 @@ module Gitlab
...
@@ -39,11 +39,17 @@ module Gitlab
private
private
override
:check_namespace!
def
check_namespace!
return
unless
snippet
.
is_a?
(
ProjectSnippet
)
super
end
override
:check_project!
override
:check_project!
def
check_project!
(
cmd
,
changes
)
def
check_project!
(
cmd
,
changes
)
return
unless
snippet
.
is_a?
(
ProjectSnippet
)
return
unless
snippet
.
is_a?
(
ProjectSnippet
)
check_namespace!
check_project_accessibility!
check_project_accessibility!
add_project_moved_message!
add_project_moved_message!
end
end
...
...
spec/lib/gitlab/git_access_spec.rb
View file @
41526de5
...
@@ -10,7 +10,7 @@ describe Gitlab::GitAccess do
...
@@ -10,7 +10,7 @@ describe Gitlab::GitAccess do
let
(
:actor
)
{
user
}
let
(
:actor
)
{
user
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project_path
)
{
project
.
path
}
let
(
:project_path
)
{
project
&
.
path
}
let
(
:namespace_path
)
{
project
&
.
namespace
&
.
path
}
let
(
:namespace_path
)
{
project
&
.
namespace
&
.
path
}
let
(
:protocol
)
{
'ssh'
}
let
(
:protocol
)
{
'ssh'
}
let
(
:authentication_abilities
)
{
%i[read_project download_code push_code]
}
let
(
:authentication_abilities
)
{
%i[read_project download_code push_code]
}
...
@@ -89,13 +89,14 @@ describe Gitlab::GitAccess do
...
@@ -89,13 +89,14 @@ describe Gitlab::GitAccess do
end
end
end
end
context
'when namespace does not exist'
do
context
'when namespace and project are nil'
do
let
(
:project
)
{
nil
}
let
(
:namespace_path
)
{
nil
}
let
(
:namespace_path
)
{
nil
}
it
'does not allow push and pull access'
do
it
'does not allow push and pull access'
do
aggregate_failures
do
aggregate_failures
do
expect
{
push_access_check
}.
to
raise_not_found
expect
{
push_access_check
}.
to
raise_n
amespace_n
ot_found
expect
{
pull_access_check
}.
to
raise_not_found
expect
{
pull_access_check
}.
to
raise_n
amespace_n
ot_found
end
end
end
end
end
end
...
@@ -228,13 +229,6 @@ describe Gitlab::GitAccess do
...
@@ -228,13 +229,6 @@ describe Gitlab::GitAccess do
let
(
:project
)
{
nil
}
let
(
:project
)
{
nil
}
let
(
:project_path
)
{
"new-project"
}
let
(
:project_path
)
{
"new-project"
}
it
'blocks push and pull with "not found"'
do
aggregate_failures
do
expect
{
pull_access_check
}.
to
raise_not_found
expect
{
push_access_check
}.
to
raise_not_found
end
end
context
'when user is allowed to create project in namespace'
do
context
'when user is allowed to create project in namespace'
do
let
(
:namespace_path
)
{
user
.
namespace
.
path
}
let
(
:namespace_path
)
{
user
.
namespace
.
path
}
let
(
:access
)
do
let
(
:access
)
do
...
@@ -1219,6 +1213,10 @@ describe Gitlab::GitAccess do
...
@@ -1219,6 +1213,10 @@ describe Gitlab::GitAccess do
raise_error
(
Gitlab
::
GitAccess
::
NotFoundError
,
Gitlab
::
GitAccess
::
ERROR_MESSAGES
[
:project_not_found
])
raise_error
(
Gitlab
::
GitAccess
::
NotFoundError
,
Gitlab
::
GitAccess
::
ERROR_MESSAGES
[
:project_not_found
])
end
end
def
raise_namespace_not_found
raise_error
(
Gitlab
::
GitAccess
::
NotFoundError
,
Gitlab
::
GitAccess
::
ERROR_MESSAGES
[
:namespace_not_found
])
end
def
build_authentication_abilities
def
build_authentication_abilities
[
[
:read_project
,
:read_project
,
...
...
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