summaryrefslogtreecommitdiff
path: root/spec/gitlab_shell_spec.rb
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2014-08-27 13:26:27 +0200
committerJacob Vosmaer <contact@jacobvosmaer.nl>2014-08-27 14:42:58 +0200
commitea88c9b2747ffb4cb0481b8cb274ebc4919474db (patch)
treea7894facacdc2f0c29e3abbaa6054bc6a44d6e3f /spec/gitlab_shell_spec.rb
parentb5284310c2c9d6f53e983ca5224bea7c48e0f779 (diff)
downloadgitlab-shell-ea88c9b2747ffb4cb0481b8cb274ebc4919474db.tar.gz
Handle invalid number of arguments
When a remote user with a valid SSH key runs something like 'ssh git@gitlab.example.com foobar', gitlab-shell would raise an exception in the GitlabShell#escape_path method. With this change, we catch an invalid number of arguments as soon as possible and exit.
Diffstat (limited to 'spec/gitlab_shell_spec.rb')
-rw-r--r--spec/gitlab_shell_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/gitlab_shell_spec.rb b/spec/gitlab_shell_spec.rb
index f997477..4741303 100644
--- a/spec/gitlab_shell_spec.rb
+++ b/spec/gitlab_shell_spec.rb
@@ -48,6 +48,14 @@ describe GitlabShell do
its(:repo_name) { should == 'dmitriy.zaporozhets/gitlab-ci.git' }
its(:git_cmd) { should == 'git-upload-pack' }
end
+
+ context 'with an invalid number of arguments' do
+ before { ssh_cmd 'foobar' }
+
+ it "should raise an DisallowedCommandError" do
+ expect { subject.send :parse_cmd }.to raise_error(GitlabShell::DisallowedCommandError)
+ end
+ end
end
describe :exec do