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
51727f5c
Commit
51727f5c
authored
May 18, 2013
by
ash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Specs for logging in gitlab-shell.
parent
cdbfbc9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
spec/gitlab_shell_spec.rb
spec/gitlab_shell_spec.rb
+26
-0
No files found.
spec/gitlab_shell_spec.rb
View file @
51727f5c
...
...
@@ -64,6 +64,13 @@ describe GitlabShell do
it
"should set the GL_ID environment variable"
do
ENV
.
should_receive
(
"[]="
).
with
(
"GL_ID"
,
key_id
)
end
it
"should log the command execution"
do
message
=
"gitlab-shell: executing git command "
message
<<
"<git-upload-pack
#{
File
.
join
(
repository_path
,
'gitlab-ci.git'
)
}
> "
message
<<
"for user with key
#{
key_id
}
."
$logger
.
should_receive
(
:info
).
with
(
message
)
end
end
context
'git-receive-pack'
do
...
...
@@ -77,6 +84,13 @@ describe GitlabShell do
it
"should execute the command"
do
subject
.
should_receive
(
:exec_cmd
).
with
(
"git-receive-pack
#{
File
.
join
(
repository_path
,
'gitlab-ci.git'
)
}
"
)
end
it
"should log the command execution"
do
message
=
"gitlab-shell: executing git command "
message
<<
"<git-receive-pack
#{
File
.
join
(
repository_path
,
'gitlab-ci.git'
)
}
> "
message
<<
"for user with key
#{
key_id
}
."
$logger
.
should_receive
(
:info
).
with
(
message
)
end
end
context
'arbitrary command'
do
...
...
@@ -90,6 +104,11 @@ describe GitlabShell do
it
"should not execute the command"
do
subject
.
should_not_receive
(
:exec_cmd
)
end
it
"should log the attempt"
do
message
=
"gitlab-shell: Attempt to execute disallowed command <arbitrary command> by user with key
#{
key_id
}
."
$logger
.
should_receive
(
:warn
).
with
(
message
)
end
end
context
'no command'
do
...
...
@@ -110,6 +129,13 @@ describe GitlabShell do
api
.
should_receive
(
:allowed?
).
with
(
'git-upload-pack'
,
'gitlab-ci.git'
,
key_id
,
'_any'
)
end
it
"should disallow access and log the attempt if allowed? returns false"
do
api
.
stub
(
allowed?:
false
)
message
=
"gitlab-shell: Access denied for git command <git-upload-pack gitlab-ci.git> "
message
<<
"by user with key
#{
key_id
}
."
$logger
.
should_receive
(
:warn
).
with
(
message
)
end
end
def
ssh_cmd
(
cmd
)
...
...
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