Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-shell
Commits
b8ccc7a6
Commit
b8ccc7a6
authored
Mar 11, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cover denied context for GitlabNet
parent
a94d8996
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
8 deletions
+118
-8
spec/gitlab_net_spec.rb
spec/gitlab_net_spec.rb
+26
-8
spec/vcr_cassettes/denied-pull.yml
spec/vcr_cassettes/denied-pull.yml
+46
-0
spec/vcr_cassettes/denied-push.yml
spec/vcr_cassettes/denied-push.yml
+46
-0
No files found.
spec/gitlab_net_spec.rb
View file @
b8ccc7a6
...
...
@@ -10,17 +10,35 @@ describe GitlabNet do
gitlab_net
.
stub!
(
:host
).
and_return
(
'https://dev.gitlab.org/api/v3/internal'
)
end
it
'should allow pull access for dev.gitlab.org'
,
vcr:
true
do
VCR
.
use_cassette
(
"allowed-pull"
)
do
access
=
gitlab_net
.
allowed?
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-1'
,
'master'
)
access
.
should
be_true
context
'ssh key with access to project'
do
it
'should allow pull access for dev.gitlab.org'
,
vcr:
true
do
VCR
.
use_cassette
(
"allowed-pull"
)
do
access
=
gitlab_net
.
allowed?
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-1'
,
'master'
)
access
.
should
be_true
end
end
it
'should allow push access for dev.gitlab.org'
,
vcr:
true
do
VCR
.
use_cassette
(
"allowed-push"
)
do
access
=
gitlab_net
.
allowed?
(
'git-upload-pack'
,
'gitlab/gitlabhq.git'
,
'key-1'
,
'master'
)
access
.
should
be_true
end
end
end
it
'should allow push access for dev.gitlab.org'
,
vcr:
true
do
VCR
.
use_cassette
(
"allowed-push"
)
do
access
=
gitlab_net
.
allowed?
(
'git-upload-pack'
,
'gitlab/gitlabhq.git'
,
'key-1'
,
'master'
)
access
.
should
be_true
context
'ssh key without access to project'
do
it
'should deny pull access for dev.gitlab.org'
,
vcr:
true
do
VCR
.
use_cassette
(
"denied-pull"
)
do
access
=
gitlab_net
.
allowed?
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-2'
,
'master'
)
access
.
should
be_false
end
end
it
'should deny push access for dev.gitlab.org'
,
vcr:
true
do
VCR
.
use_cassette
(
"denied-push"
)
do
access
=
gitlab_net
.
allowed?
(
'git-upload-pack'
,
'gitlab/gitlabhq.git'
,
'key-2'
,
'master'
)
access
.
should
be_false
end
end
end
end
...
...
spec/vcr_cassettes/denied-pull.yml
0 → 100644
View file @
b8ccc7a6
---
http_interactions
:
-
request
:
method
:
get
uri
:
https://dev.gitlab.org/api/v3/internal/allowed?action=git-receive-pack&key_id=2&project=gitlab/gitlabhq&ref=master
body
:
encoding
:
US-ASCII
string
:
'
'
headers
:
Accept
:
-
!
'
*/*'
User-Agent
:
-
Ruby
response
:
status
:
code
:
404
message
:
Not Found
headers
:
Server
:
-
nginx/1.1.19
Date
:
-
Mon, 11 Mar 2013 12:21:31 GMT
Content-Type
:
-
application/json
Content-Length
:
-
'
27'
Connection
:
-
keep-alive
Status
:
-
404 Not Found
X-Ua-Compatible
:
-
IE=Edge,chrome=1
Cache-Control
:
-
no-cache
X-Request-Id
:
-
bda6c4046ea050c5bad39a38337f5771
X-Runtime
:
-
'
0.005632'
X-Rack-Cache
:
-
miss
body
:
encoding
:
US-ASCII
string
:
!
'
{"message":"404
Not
found"}'
http_version
:
recorded_at
:
Mon, 11 Mar 2013 12:21:30 GMT
recorded_with
:
VCR 2.4.0
spec/vcr_cassettes/denied-push.yml
0 → 100644
View file @
b8ccc7a6
---
http_interactions
:
-
request
:
method
:
get
uri
:
https://dev.gitlab.org/api/v3/internal/allowed?action=git-upload-pack&key_id=2&project=gitlab/gitlabhq&ref=master
body
:
encoding
:
US-ASCII
string
:
'
'
headers
:
Accept
:
-
!
'
*/*'
User-Agent
:
-
Ruby
response
:
status
:
code
:
404
message
:
Not Found
headers
:
Server
:
-
nginx/1.1.19
Date
:
-
Mon, 11 Mar 2013 12:21:31 GMT
Content-Type
:
-
application/json
Content-Length
:
-
'
27'
Connection
:
-
keep-alive
Status
:
-
404 Not Found
X-Ua-Compatible
:
-
IE=Edge,chrome=1
Cache-Control
:
-
no-cache
X-Request-Id
:
-
6242870566154e17170c86ebb7f7a448
X-Runtime
:
-
'
0.005174'
X-Rack-Cache
:
-
miss
body
:
encoding
:
US-ASCII
string
:
!
'
{"message":"404
Not
found"}'
http_version
:
recorded_at
:
Mon, 11 Mar 2013 12:21:31 GMT
recorded_with
:
VCR 2.4.0
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