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
4cd4cf67
Commit
4cd4cf67
authored
Jun 21, 2016
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added better tests for the protocol check
parent
fd41b8a4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
126 additions
and
1 deletion
+126
-1
spec/gitlab_access_spec.rb
spec/gitlab_access_spec.rb
+2
-1
spec/gitlab_net_spec.rb
spec/gitlab_net_spec.rb
+36
-0
spec/vcr_cassettes/http-access-disabled.yml
spec/vcr_cassettes/http-access-disabled.yml
+44
-0
spec/vcr_cassettes/ssh-access-disabled.yml
spec/vcr_cassettes/ssh-access-disabled.yml
+44
-0
No files found.
spec/gitlab_access_spec.rb
View file @
4cd4cf67
...
...
@@ -11,7 +11,7 @@ describe GitlabAccess do
end
end
subject
do
GitlabAccess
.
new
(
repo_path
,
'key-123'
,
'wow'
).
tap
do
|
access
|
GitlabAccess
.
new
(
repo_path
,
'key-123'
,
'wow'
,
'ssh'
).
tap
do
|
access
|
access
.
stub
(
exec_cmd: :exec_called
)
access
.
stub
(
api:
api
)
end
...
...
@@ -25,6 +25,7 @@ describe GitlabAccess do
it
{
subject
.
repo_name
.
should
==
repo_name
}
it
{
subject
.
repo_path
.
should
==
repo_path
}
it
{
subject
.
changes
.
should
==
[
'wow'
]
}
it
{
subject
.
protocol
.
should
==
'ssh'
}
end
describe
"#exec"
do
...
...
spec/gitlab_net_spec.rb
View file @
4cd4cf67
...
...
@@ -130,6 +130,42 @@ describe GitlabNet, vcr: true do
end
end
context
'ssh access has been disabled'
do
it
'should deny pull access for dev.gitlab.org'
do
VCR
.
use_cassette
(
'ssh-access-disabled'
)
do
access
=
gitlab_net
.
check_access
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-2'
,
changes
,
'ssh'
)
access
.
allowed?
.
should
be_false
access
.
message
.
should
eq
'Git access over SSH is not allowed'
end
end
it
'should deny pull access for dev.gitlab.org'
do
VCR
.
use_cassette
(
'ssh-access-disabled'
)
do
access
=
gitlab_net
.
check_access
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-2'
,
changes
,
'ssh'
)
access
.
allowed?
.
should
be_false
access
.
message
.
should
eq
'Git access over SSH is not allowed'
end
end
end
context
'http access has been disabled'
do
it
'should deny pull access for dev.gitlab.org'
do
VCR
.
use_cassette
(
'http-access-disabled'
)
do
access
=
gitlab_net
.
check_access
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-2'
,
changes
,
'http'
)
access
.
allowed?
.
should
be_false
access
.
message
.
should
eq
'Git access over HTTP is not allowed'
end
end
it
'should deny pull access for dev.gitlab.org'
do
VCR
.
use_cassette
(
'http-access-disabled'
)
do
access
=
gitlab_net
.
check_access
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-2'
,
changes
,
'http'
)
access
.
allowed?
.
should
be_false
access
.
message
.
should
eq
'Git access over HTTP is not allowed'
end
end
end
context
'ssh key without access to project'
do
it
'should deny pull access for dev.gitlab.org'
do
VCR
.
use_cassette
(
"denied-pull"
)
do
...
...
spec/vcr_cassettes/http-access-disabled.yml
0 → 100644
View file @
4cd4cf67
---
http_interactions
:
-
request
:
method
:
post
uri
:
https://dev.gitlab.org/api/v3/internal/allowed
body
:
encoding
:
US-ASCII
string
:
action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&protocol=http&key_id=2&secret_token=a123
headers
:
Accept-Encoding
:
-
gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept
:
-
"
*/*"
User-Agent
:
-
Ruby
Content-Type
:
-
application/x-www-form-urlencoded
response
:
status
:
code
:
200
message
:
OK
headers
:
Cache-Control
:
-
no-cache
Content-Length
:
-
'
30'
Content-Type
:
-
application/json
Date
:
-
Wed, 22 Jun 2016 01:03:41 GMT
Status
:
-
200 OK
Vary
:
-
Origin
X-Request-Id
:
-
55b7af2c-3559-41d2-b301-9b86ad1d8fac
X-Runtime
:
-
'
2.280895'
body
:
encoding
:
UTF-8
string
:
'
{"status":
false,
"message":"Git
access
over
HTTP
is
not
allowed"}'
http_version
:
recorded_at
:
Wed, 22 Jun 2016 01:03:41 GMT
recorded_with
:
VCR 2.4.0
\ No newline at end of file
spec/vcr_cassettes/ssh-access-disabled.yml
0 → 100644
View file @
4cd4cf67
---
http_interactions
:
-
request
:
method
:
post
uri
:
https://dev.gitlab.org/api/v3/internal/allowed
body
:
encoding
:
US-ASCII
string
:
action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&protocol=ssh&key_id=2&secret_token=a123
headers
:
Accept-Encoding
:
-
gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept
:
-
"
*/*"
User-Agent
:
-
Ruby
Content-Type
:
-
application/x-www-form-urlencoded
response
:
status
:
code
:
200
message
:
OK
headers
:
Cache-Control
:
-
no-cache
Content-Length
:
-
'
30'
Content-Type
:
-
application/json
Date
:
-
Wed, 22 Jun 2016 01:01:41 GMT
Status
:
-
200 OK
Vary
:
-
Origin
X-Request-Id
:
-
55b7af2c-3559-41d2-b301-9b86ad1d8fac
X-Runtime
:
-
'
2.280895'
body
:
encoding
:
UTF-8
string
:
'
{"status":
false,
"message":"Git
access
over
SSH
is
not
allowed"}'
http_version
:
recorded_at
:
Wed, 22 Jun 2016 01:01:41 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