summaryrefslogtreecommitdiff
path: root/spec/gitlab_keys_spec.rb
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2015-07-16 10:10:46 +0200
committerJacob Vosmaer <contact@jacobvosmaer.nl>2015-07-16 10:10:46 +0200
commit4fd8e44ba12d126b0553b90c099d1b63fa163d00 (patch)
treefab244d21d1792283f53a4dd4bdca4e7970e358f /spec/gitlab_keys_spec.rb
parent4d30c0c5d3d0f23a221ee507b6bd110a539b8570 (diff)
downloadgitlab-shell-4fd8e44ba12d126b0553b90c099d1b63fa163d00.tar.gz
Remove keys from authorized_keys in-place
This will speed up the rm-key operation. The downside is that authorized_keys will not shrink when you remove a key. If this ever becomes a problem it can be fixed by running 'rake gitlab:shell:setup'.
Diffstat (limited to 'spec/gitlab_keys_spec.rb')
-rw-r--r--spec/gitlab_keys_spec.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/spec/gitlab_keys_spec.rb b/spec/gitlab_keys_spec.rb
index bcce628..ed2fd58 100644
--- a/spec/gitlab_keys_spec.rb
+++ b/spec/gitlab_keys_spec.rb
@@ -109,17 +109,19 @@ describe GitlabKeys do
it "removes the right line" do
create_authorized_keys_fixture
other_line = "command=\"#{ROOT_PATH}/bin/gitlab-shell key-742\",options ssh-rsa AAAAB3NzaDAxx2E"
+ delete_line = "command=\"#{ROOT_PATH}/bin/gitlab-shell key-741\",options ssh-rsa AAAAB3NzaDAxx2E"
open(tmp_authorized_keys_path, 'a') do |auth_file|
- auth_file.puts "command=\"#{ROOT_PATH}/bin/gitlab-shell key-741\",options ssh-rsa AAAAB3NzaDAxx2E"
+ auth_file.puts delete_line
auth_file.puts other_line
end
gitlab_keys.send :rm_key
- File.read(tmp_authorized_keys_path).should == "existing content\n#{other_line}\n"
+ erased_line = delete_line.gsub(/./, '#')
+ File.read(tmp_authorized_keys_path).should == "existing content\n#{erased_line}\n#{other_line}\n"
end
context "without file writing" do
before do
- Tempfile.stub(:open)
+ gitlab_keys.stub(:open)
gitlab_keys.stub(:lock).and_yield
end