Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
4bacb370cad3
Commit
d2cec126
authored
Mar 07, 2013
by
Dmitriy Zaporozhets
Browse files
block user should not be able to push
parent
93e75b79b18d
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/api/internal.rb
View file @
4bacb370
...
...
@@ -20,6 +20,9 @@ class Internal < Grape::API
project
==
key
.
project
&&
git_cmd
==
'git-upload-pack'
else
user
=
key
.
user
return
false
if
user
.
blocked?
action
=
case
git_cmd
when
'git-upload-pack'
then
:download_code
...
...
spec/requests/api/internal_spec.rb
View file @
4bacb370
...
...
@@ -34,13 +34,7 @@
context
"git pull"
do
it
do
get
(
api
(
"/internal/allowed"
),
ref:
'master'
,
key_id:
key
.
id
,
project:
project
.
path_with_namespace
,
action:
'git-upload-pack'
)
pull
(
key
,
project
)
response
.
status
.
should
==
200
response
.
body
.
should
==
'true'
...
...
@@ -49,13 +43,7 @@
context
"git push"
do
it
do
get
(
api
(
"/internal/allowed"
),
ref:
'master'
,
key_id:
key
.
id
,
project:
project
.
path_with_namespace
,
action:
'git-receive-pack'
)
push
(
key
,
project
)
response
.
status
.
should
==
200
response
.
body
.
should
==
'true'
...
...
@@ -70,13 +58,7 @@
context
"git pull"
do
it
do
get
(
api
(
"/internal/allowed"
),
ref:
'master'
,
key_id:
key
.
id
,
project:
project
.
path_with_namespace
,
action:
'git-upload-pack'
)
pull
(
key
,
project
)
response
.
status
.
should
==
200
response
.
body
.
should
==
'false'
...
...
@@ -85,13 +67,7 @@
context
"git push"
do
it
do
get
(
api
(
"/internal/allowed"
),
ref:
'master'
,
key_id:
key
.
id
,
project:
project
.
path_with_namespace
,
action:
'git-receive-pack'
)
push
(
key
,
project
)
response
.
status
.
should
==
200
response
.
body
.
should
==
'false'
...
...
@@ -99,5 +75,50 @@
end
end
context
"blocked user"
do
let
(
:personal_project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
before
do
user
.
block
end
context
"git pull"
do
it
do
pull
(
key
,
personal_project
)
response
.
status
.
should
==
200
response
.
body
.
should
==
'false'
end
end
context
"git push"
do
it
do
push
(
key
,
personal_project
)
response
.
status
.
should
==
200
response
.
body
.
should
==
'false'
end
end
end
end
def
pull
(
key
,
project
)
get
(
api
(
"/internal/allowed"
),
ref:
'master'
,
key_id:
key
.
id
,
project:
project
.
path_with_namespace
,
action:
'git-upload-pack'
)
end
def
push
(
key
,
project
)
get
(
api
(
"/internal/allowed"
),
ref:
'master'
,
key_id:
key
.
id
,
project:
project
.
path_with_namespace
,
action:
'git-receive-pack'
)
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