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
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
Kazuhiko Shiozaki
gitlab-shell
Commits
c3f71412
Commit
c3f71412
authored
Mar 11, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test for GitlabNet discover
parent
b8ccc7a6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
9 deletions
+67
-9
spec/gitlab_net_spec.rb
spec/gitlab_net_spec.rb
+18
-9
spec/vcr_cassettes/discover-ok.yml
spec/vcr_cassettes/discover-ok.yml
+49
-0
No files found.
spec/gitlab_net_spec.rb
View file @
c3f71412
...
@@ -2,23 +2,32 @@ require_relative 'spec_helper'
...
@@ -2,23 +2,32 @@ require_relative 'spec_helper'
require_relative
'../lib/gitlab_net'
require_relative
'../lib/gitlab_net'
describe
GitlabNet
do
describe
GitlabNet
,
vcr:
true
do
describe
:allowed?
do
let
(
:gitlab_net
)
{
GitlabNet
.
new
}
let
(
:gitlab_net
)
{
GitlabNet
.
new
}
before
do
before
do
gitlab_net
.
stub!
(
:host
).
and_return
(
'https://dev.gitlab.org/api/v3/internal'
)
gitlab_net
.
stub!
(
:host
).
and_return
(
'https://dev.gitlab.org/api/v3/internal'
)
end
end
describe
:discover
do
it
'should return user has based on key id'
do
VCR
.
use_cassette
(
"discover-ok"
)
do
user
=
gitlab_net
.
discover
(
'key-1'
)
user
[
'name'
].
should
==
'Dmitriy Zaporozhets'
end
end
end
describe
:allowed?
do
context
'ssh key with access to project'
do
context
'ssh key with access to project'
do
it
'should allow pull access for dev.gitlab.org'
,
vcr:
true
do
it
'should allow pull access for dev.gitlab.org'
do
VCR
.
use_cassette
(
"allowed-pull"
)
do
VCR
.
use_cassette
(
"allowed-pull"
)
do
access
=
gitlab_net
.
allowed?
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-1'
,
'master'
)
access
=
gitlab_net
.
allowed?
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-1'
,
'master'
)
access
.
should
be_true
access
.
should
be_true
end
end
end
end
it
'should allow push access for dev.gitlab.org'
,
vcr:
true
do
it
'should allow push access for dev.gitlab.org'
do
VCR
.
use_cassette
(
"allowed-push"
)
do
VCR
.
use_cassette
(
"allowed-push"
)
do
access
=
gitlab_net
.
allowed?
(
'git-upload-pack'
,
'gitlab/gitlabhq.git'
,
'key-1'
,
'master'
)
access
=
gitlab_net
.
allowed?
(
'git-upload-pack'
,
'gitlab/gitlabhq.git'
,
'key-1'
,
'master'
)
access
.
should
be_true
access
.
should
be_true
...
@@ -27,14 +36,14 @@ describe GitlabNet do
...
@@ -27,14 +36,14 @@ describe GitlabNet do
end
end
context
'ssh key without access to project'
do
context
'ssh key without access to project'
do
it
'should deny pull access for dev.gitlab.org'
,
vcr:
true
do
it
'should deny pull access for dev.gitlab.org'
do
VCR
.
use_cassette
(
"denied-pull"
)
do
VCR
.
use_cassette
(
"denied-pull"
)
do
access
=
gitlab_net
.
allowed?
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-2'
,
'master'
)
access
=
gitlab_net
.
allowed?
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-2'
,
'master'
)
access
.
should
be_false
access
.
should
be_false
end
end
end
end
it
'should deny push access for dev.gitlab.org'
,
vcr:
true
do
it
'should deny push access for dev.gitlab.org'
do
VCR
.
use_cassette
(
"denied-push"
)
do
VCR
.
use_cassette
(
"denied-push"
)
do
access
=
gitlab_net
.
allowed?
(
'git-upload-pack'
,
'gitlab/gitlabhq.git'
,
'key-2'
,
'master'
)
access
=
gitlab_net
.
allowed?
(
'git-upload-pack'
,
'gitlab/gitlabhq.git'
,
'key-2'
,
'master'
)
access
.
should
be_false
access
.
should
be_false
...
...
spec/vcr_cassettes/discover-ok.yml
0 → 100644
View file @
c3f71412
---
http_interactions
:
-
request
:
method
:
get
uri
:
https://dev.gitlab.org/api/v3/internal/discover?key_id=1
body
:
encoding
:
US-ASCII
string
:
'
'
headers
:
Accept
:
-
!
'
*/*'
User-Agent
:
-
Ruby
response
:
status
:
code
:
200
message
:
OK
headers
:
Server
:
-
nginx/1.1.19
Date
:
-
Mon, 11 Mar 2013 12:25:45 GMT
Content-Type
:
-
application/json
Content-Length
:
-
'
332'
Connection
:
-
keep-alive
Status
:
-
200 OK
X-Ua-Compatible
:
-
IE=Edge,chrome=1
Etag
:
-
!
'
"132e22d01addb4fe7fc1ee9f954b69e1"'
Cache-Control
:
-
max-age=0, private, must-revalidate
X-Request-Id
:
-
47a6a45ce3073d1f7497d15290c109ef
X-Runtime
:
-
'
0.007938'
X-Rack-Cache
:
-
miss
body
:
encoding
:
US-ASCII
string
:
!
'
{"id":1,"username":"dzaporozhets","email":"dmitriy.zaporozhets@gmail.com","name":"Dmitriy
Zaporozhets","bio":"ruby
dev.","skype":"dmitriy-zaporozhets","linkedin":"dzaporozhets","twitter":"dzaporozhets","dark_scheme":true,"theme_id":2,"state":"active","created_at":"2011-09-19T09:11:36Z","extern_uid":"23944366","provider":"twitter"}'
http_version
:
recorded_at
:
Mon, 11 Mar 2013 12:25:44 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