diff options
author | ash <smashwilson@gmail.com> | 2013-05-18 19:07:00 +0000 |
---|---|---|
committer | ash <smashwilson@gmail.com> | 2013-05-18 19:07:00 +0000 |
commit | 51727f5cd51d20d5c9fb1cfafe380da828d5f52f (patch) | |
tree | f4cecb859b3ed0aca38eba4f3247c7edabc6adac | |
parent | cdbfbc9be1db8e2ed946dc3b0a0304b9dcfbcf34 (diff) | |
download | gitlab-shell-51727f5cd51d20d5c9fb1cfafe380da828d5f52f.tar.gz |
Specs for logging in gitlab-shell.
-rw-r--r-- | spec/gitlab_shell_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/gitlab_shell_spec.rb b/spec/gitlab_shell_spec.rb index da91c36..0367675 100644 --- a/spec/gitlab_shell_spec.rb +++ b/spec/gitlab_shell_spec.rb @@ -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) |