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
a94d8996
Commit
a94d8996
authored
Mar 11, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test GitlabNet allowed method
parent
238fd9b6
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
191 additions
and
0 deletions
+191
-0
Gemfile
Gemfile
+2
-0
Gemfile.lock
Gemfile.lock
+8
-0
lib/gitlab_net.rb
lib/gitlab_net.rb
+1
-0
spec/gitlab_net_spec.rb
spec/gitlab_net_spec.rb
+27
-0
spec/spec_helper.rb
spec/spec_helper.rb
+9
-0
spec/vcr_cassettes/allowed-pull.yml
spec/vcr_cassettes/allowed-pull.yml
+48
-0
spec/vcr_cassettes/allowed-push.yml
spec/vcr_cassettes/allowed-push.yml
+48
-0
spec/vcr_cassettes/dev_gitlab_org.yml
spec/vcr_cassettes/dev_gitlab_org.yml
+48
-0
No files found.
Gemfile
View file @
a94d8996
...
...
@@ -3,6 +3,8 @@ source "http://rubygems.org"
group
:development
do
gem
'
coveralls
'
,
require:
false
gem
'
rspec
'
gem
'
webmock
'
gem
'
guard
'
gem
'
guard-rspec
'
gem
'
vcr
'
end
Gemfile.lock
View file @
a94d8996
GEM
remote: http://rubygems.org/
specs:
addressable (2.3.2)
coderay (1.0.8)
colorize (0.5.8)
coveralls (0.6.2)
...
...
@@ -9,6 +10,7 @@ GEM
rest-client
simplecov (>= 0.7)
thor
crack (0.3.1)
diff-lcs (1.1.3)
guard (1.5.4)
listen (>= 0.4.2)
...
...
@@ -43,6 +45,10 @@ GEM
simplecov-html (0.7.1)
slop (3.3.3)
thor (0.16.0)
vcr (2.4.0)
webmock (1.9.0)
addressable (>= 2.2.7)
crack (>= 0.1.7)
PLATFORMS
ruby
...
...
@@ -52,3 +58,5 @@ DEPENDENCIES
guard
guard-rspec
rspec
vcr
webmock
lib/gitlab_net.rb
View file @
a94d8996
...
...
@@ -35,6 +35,7 @@ class GitlabNet
end
def
get
(
url
)
puts
url
.
inspect
url
=
URI
.
parse
(
url
)
http
=
Net
::
HTTP
.
new
(
url
.
host
,
url
.
port
)
http
.
use_ssl
=
(
url
.
port
==
443
)
...
...
spec/gitlab_net_spec.rb
0 → 100644
View file @
a94d8996
require_relative
'spec_helper'
require_relative
'../lib/gitlab_net'
describe
GitlabNet
do
describe
:allowed?
do
let
(
:gitlab_net
)
{
GitlabNet
.
new
}
before
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
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
end
spec/spec_helper.rb
View file @
a94d8996
...
...
@@ -4,3 +4,12 @@ if ENV['TRAVIS']
require
'coveralls'
Coveralls
.
wear!
end
require
'vcr'
require
'webmock'
VCR
.
configure
do
|
c
|
c
.
cassette_library_dir
=
'spec/vcr_cassettes'
c
.
hook_into
:webmock
c
.
configure_rspec_metadata!
end
spec/vcr_cassettes/allowed-pull.yml
0 → 100644
View file @
a94d8996
---
http_interactions
:
-
request
:
method
:
get
uri
:
https://dev.gitlab.org/api/v3/internal/allowed?action=git-receive-pack&key_id=1&project=gitlab/gitlabhq&ref=master
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:13:31 GMT
Content-Type
:
-
application/json
Content-Length
:
-
'
4'
Connection
:
-
keep-alive
Status
:
-
200 OK
X-Ua-Compatible
:
-
IE=Edge,chrome=1
Etag
:
-
!
'
"b326b5062b2f0e69046810717534cb09"'
Cache-Control
:
-
max-age=0, private, must-revalidate
X-Request-Id
:
-
ac00b27743e177559476f6575e45d1c2
X-Runtime
:
-
'
0.017272'
X-Rack-Cache
:
-
miss
body
:
encoding
:
US-ASCII
string
:
'
true'
http_version
:
recorded_at
:
Mon, 11 Mar 2013 12:13:31 GMT
recorded_with
:
VCR 2.4.0
spec/vcr_cassettes/allowed-push.yml
0 → 100644
View file @
a94d8996
---
http_interactions
:
-
request
:
method
:
get
uri
:
https://dev.gitlab.org/api/v3/internal/allowed?action=git-upload-pack&key_id=1&project=gitlab/gitlabhq&ref=master
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:13:32 GMT
Content-Type
:
-
application/json
Content-Length
:
-
'
4'
Connection
:
-
keep-alive
Status
:
-
200 OK
X-Ua-Compatible
:
-
IE=Edge,chrome=1
Etag
:
-
!
'
"b326b5062b2f0e69046810717534cb09"'
Cache-Control
:
-
max-age=0, private, must-revalidate
X-Request-Id
:
-
c65f8ea13ac34cf182fcb6daefeb1bdd
X-Runtime
:
-
'
0.018934'
X-Rack-Cache
:
-
miss
body
:
encoding
:
US-ASCII
string
:
'
true'
http_version
:
recorded_at
:
Mon, 11 Mar 2013 12:13:31 GMT
recorded_with
:
VCR 2.4.0
spec/vcr_cassettes/dev_gitlab_org.yml
0 → 100644
View file @
a94d8996
---
http_interactions
:
-
request
:
method
:
get
uri
:
https://dev.gitlab.org/api/v3/internal/allowed?action=git-receive-pack&key_id=100&project=gitlab/gitlabhq&ref=master
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:13:05 GMT
Content-Type
:
-
application/json
Content-Length
:
-
'
4'
Connection
:
-
keep-alive
Status
:
-
200 OK
X-Ua-Compatible
:
-
IE=Edge,chrome=1
Etag
:
-
!
'
"b326b5062b2f0e69046810717534cb09"'
Cache-Control
:
-
max-age=0, private, must-revalidate
X-Request-Id
:
-
aabf04bba02ad88d256633dc34097095
X-Runtime
:
-
'
0.017099'
X-Rack-Cache
:
-
miss
body
:
encoding
:
US-ASCII
string
:
'
true'
http_version
:
recorded_at
:
Mon, 11 Mar 2013 12:13:05 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