summaryrefslogtreecommitdiff
path: root/spec/gitlab_keys_spec.rb
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2013-10-31 17:18:41 +0100
committerJacob Vosmaer <contact@jacobvosmaer.nl>2013-10-31 18:13:03 +0100
commit8d6807098ffbe9492dbf1de2a7d9620bdeb348e3 (patch)
tree4eb26616042f328a1a4f3faeb5efabf713a25a0f /spec/gitlab_keys_spec.rb
parentd3c3fbc6163ca13b16351214349bd5a7f5b729a3 (diff)
downloadgitlab-shell-8d6807098ffbe9492dbf1de2a7d9620bdeb348e3.tar.gz
Use Kernel#open to append lines to authorized_keys
Diffstat (limited to 'spec/gitlab_keys_spec.rb')
-rw-r--r--spec/gitlab_keys_spec.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/spec/gitlab_keys_spec.rb b/spec/gitlab_keys_spec.rb
index c888b8e..cbe09bd 100644
--- a/spec/gitlab_keys_spec.rb
+++ b/spec/gitlab_keys_spec.rb
@@ -16,15 +16,18 @@ describe GitlabKeys do
describe :add_key do
let(:gitlab_keys) { build_gitlab_keys('add-key', 'key-741', 'ssh-rsa AAAAB3NzaDAxx2E') }
+ let(:file) { mock(:file) }
it "should receive valid cmd" do
- valid_cmd = "echo 'command=\"#{ROOT_PATH}/bin/gitlab-shell key-741\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3NzaDAxx2E' >> #{GitlabConfig.new.auth_file}"
- gitlab_keys.should_receive(:system).with(valid_cmd)
+ auth_line = "command=\"#{ROOT_PATH}/bin/gitlab-shell key-741\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3NzaDAxx2E"
+ gitlab_keys.should_receive(:open).with(GitlabConfig.new.auth_file, 'a').and_yield(file)
+ file.should_receive(:puts).with(auth_line)
gitlab_keys.send :add_key
end
it "should log an add-key event" do
$logger.should_receive(:info).with('Adding key key-741 => "ssh-rsa AAAAB3NzaDAxx2E"')
+ gitlab_keys.stub(:open)
gitlab_keys.send :add_key
end
end