Commit b8ccc7a6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

cover denied context for GitlabNet

parent a94d8996
......@@ -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
......
---
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
---
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment