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
nexedi
gitlab-shell
Commits
6aa60186
Commit
6aa60186
authored
Jun 22, 2016
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename ENV['PROTOCOL'] to ENV['GL_PROTOCOL'] and make it mandatory with no fallback value
parent
4cd4cf67
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
11 deletions
+11
-11
hooks/pre-receive
hooks/pre-receive
+1
-1
lib/gitlab_access.rb
lib/gitlab_access.rb
+1
-1
lib/gitlab_net.rb
lib/gitlab_net.rb
+1
-1
lib/gitlab_shell.rb
lib/gitlab_shell.rb
+1
-1
spec/gitlab_net_spec.rb
spec/gitlab_net_spec.rb
+7
-7
No files found.
hooks/pre-receive
View file @
6aa60186
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
refs
=
$stdin
.
read
refs
=
$stdin
.
read
key_id
=
ENV
[
'GL_ID'
]
key_id
=
ENV
[
'GL_ID'
]
protocol
=
ENV
[
'
PROTOCOL'
]
||
'http'
protocol
=
ENV
[
'
GL_PROTOCOL'
]
repo_path
=
Dir
.
pwd
repo_path
=
Dir
.
pwd
require_relative
'../lib/gitlab_custom_hook'
require_relative
'../lib/gitlab_custom_hook'
...
...
lib/gitlab_access.rb
View file @
6aa60186
...
@@ -11,7 +11,7 @@ class GitlabAccess
...
@@ -11,7 +11,7 @@ class GitlabAccess
attr_reader
:config
,
:repo_path
,
:repo_name
,
:changes
,
:protocol
attr_reader
:config
,
:repo_path
,
:repo_name
,
:changes
,
:protocol
def
initialize
(
repo_path
,
actor
,
changes
,
protocol
=
nil
)
def
initialize
(
repo_path
,
actor
,
changes
,
protocol
)
@config
=
GitlabConfig
.
new
@config
=
GitlabConfig
.
new
@repo_path
=
repo_path
.
strip
@repo_path
=
repo_path
.
strip
@actor
=
actor
@actor
=
actor
...
...
lib/gitlab_net.rb
View file @
6aa60186
...
@@ -14,7 +14,7 @@ class GitlabNet
...
@@ -14,7 +14,7 @@ class GitlabNet
CHECK_TIMEOUT
=
5
CHECK_TIMEOUT
=
5
READ_TIMEOUT
=
300
READ_TIMEOUT
=
300
def
check_access
(
cmd
,
repo
,
actor
,
changes
,
protocol
=
nil
)
def
check_access
(
cmd
,
repo
,
actor
,
changes
,
protocol
)
project_name
=
repo
.
gsub
(
"'"
,
""
)
project_name
=
repo
.
gsub
(
"'"
,
""
)
project_name
=
project_name
.
gsub
(
/\.git\Z/
,
""
)
project_name
=
project_name
.
gsub
(
/\.git\Z/
,
""
)
project_name
=
project_name
.
gsub
(
/\A\//
,
""
)
project_name
=
project_name
.
gsub
(
/\A\//
,
""
)
...
...
lib/gitlab_shell.rb
View file @
6aa60186
...
@@ -132,7 +132,7 @@ class GitlabShell
...
@@ -132,7 +132,7 @@ class GitlabShell
'LD_LIBRARY_PATH'
=>
ENV
[
'LD_LIBRARY_PATH'
],
'LD_LIBRARY_PATH'
=>
ENV
[
'LD_LIBRARY_PATH'
],
'LANG'
=>
ENV
[
'LANG'
],
'LANG'
=>
ENV
[
'LANG'
],
'GL_ID'
=>
@key_id
,
'GL_ID'
=>
@key_id
,
'PROTOCOL'
=>
'ssh'
'
GL_
PROTOCOL'
=>
'ssh'
}
}
if
@config
.
git_annex_enabled?
if
@config
.
git_annex_enabled?
...
...
spec/gitlab_net_spec.rb
View file @
6aa60186
...
@@ -110,7 +110,7 @@ describe GitlabNet, vcr: true do
...
@@ -110,7 +110,7 @@ describe GitlabNet, vcr: true 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'
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
.
check_access
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-126'
,
changes
)
access
=
gitlab_net
.
check_access
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-126'
,
changes
,
'ssh'
)
access
.
allowed?
.
should
be_true
access
.
allowed?
.
should
be_true
end
end
end
end
...
@@ -118,13 +118,13 @@ describe GitlabNet, vcr: true do
...
@@ -118,13 +118,13 @@ describe GitlabNet, vcr: true do
it
'adds the secret_token to the request'
do
it
'adds the secret_token to the request'
do
VCR
.
use_cassette
(
"allowed-pull"
)
do
VCR
.
use_cassette
(
"allowed-pull"
)
do
Net
::
HTTP
::
Post
.
any_instance
.
should_receive
(
:set_form_data
).
with
(
hash_including
(
secret_token:
'a123'
))
Net
::
HTTP
::
Post
.
any_instance
.
should_receive
(
:set_form_data
).
with
(
hash_including
(
secret_token:
'a123'
))
gitlab_net
.
check_access
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-126'
,
changes
)
gitlab_net
.
check_access
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-126'
,
changes
,
'ssh'
)
end
end
end
end
it
'should allow push access for dev.gitlab.org'
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
.
check_access
(
'git-upload-pack'
,
'gitlab/gitlabhq.git'
,
'key-126'
,
changes
)
access
=
gitlab_net
.
check_access
(
'git-upload-pack'
,
'gitlab/gitlabhq.git'
,
'key-126'
,
changes
,
'ssh'
)
access
.
allowed?
.
should
be_true
access
.
allowed?
.
should
be_true
end
end
end
end
...
@@ -169,21 +169,21 @@ describe GitlabNet, vcr: true do
...
@@ -169,21 +169,21 @@ describe GitlabNet, vcr: true do
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'
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
.
check_access
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-2'
,
changes
)
access
=
gitlab_net
.
check_access
(
'git-receive-pack'
,
'gitlab/gitlabhq.git'
,
'key-2'
,
changes
,
'ssh'
)
access
.
allowed?
.
should
be_false
access
.
allowed?
.
should
be_false
end
end
end
end
it
'should deny push access for dev.gitlab.org'
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
.
check_access
(
'git-upload-pack'
,
'gitlab/gitlabhq.git'
,
'key-2'
,
changes
)
access
=
gitlab_net
.
check_access
(
'git-upload-pack'
,
'gitlab/gitlabhq.git'
,
'key-2'
,
changes
,
'ssh'
)
access
.
allowed?
.
should
be_false
access
.
allowed?
.
should
be_false
end
end
end
end
it
'should deny push access for dev.gitlab.org (with user)'
do
it
'should deny push access for dev.gitlab.org (with user)'
do
VCR
.
use_cassette
(
"denied-push-with-user"
)
do
VCR
.
use_cassette
(
"denied-push-with-user"
)
do
access
=
gitlab_net
.
check_access
(
'git-upload-pack'
,
'gitlab/gitlabhq.git'
,
'user-1'
,
changes
)
access
=
gitlab_net
.
check_access
(
'git-upload-pack'
,
'gitlab/gitlabhq.git'
,
'user-1'
,
changes
,
'ssh'
)
access
.
allowed?
.
should
be_false
access
.
allowed?
.
should
be_false
end
end
end
end
...
@@ -192,7 +192,7 @@ describe GitlabNet, vcr: true do
...
@@ -192,7 +192,7 @@ describe GitlabNet, vcr: true do
it
"raises an exception if the connection fails"
do
it
"raises an exception if the connection fails"
do
Net
::
HTTP
.
any_instance
.
stub
(
:request
).
and_raise
(
StandardError
)
Net
::
HTTP
.
any_instance
.
stub
(
:request
).
and_raise
(
StandardError
)
expect
{
expect
{
gitlab_net
.
check_access
(
'git-upload-pack'
,
'gitlab/gitlabhq.git'
,
'user-1'
,
changes
)
gitlab_net
.
check_access
(
'git-upload-pack'
,
'gitlab/gitlabhq.git'
,
'user-1'
,
changes
,
'ssh'
)
}.
to
raise_error
(
GitlabNet
::
ApiUnreachableError
)
}.
to
raise_error
(
GitlabNet
::
ApiUnreachableError
)
end
end
end
end
...
...
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