diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-06-27 22:29:54 -0700 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-06-28 07:32:49 -0700 |
commit | a012d24e08c37ebfff038cca46578e88480e345f (patch) | |
tree | dc3e50024d8bc94382a55492ba679f8989168106 | |
parent | f980d8f59b172122d4985923094ea3b8342d6da2 (diff) | |
download | gitlab-shell-a012d24e08c37ebfff038cca46578e88480e345f.tar.gz |
Ensure rm-key works with only ID
-rw-r--r-- | spec/gitlab_keys_spec.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/gitlab_keys_spec.rb b/spec/gitlab_keys_spec.rb index 92d5909..b9f2f87 100644 --- a/spec/gitlab_keys_spec.rb +++ b/spec/gitlab_keys_spec.rb @@ -177,6 +177,23 @@ describe GitlabKeys do gitlab_keys.send(:rm_key).should be_true end end + + context 'without key content' do + let(:gitlab_keys) { build_gitlab_keys('rm-key', 'key-741') } + + it "removes the right line by key ID" 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 delete_line + auth_file.puts other_line + end + gitlab_keys.send :rm_key + erased_line = delete_line.gsub(/./, '#') + File.read(tmp_authorized_keys_path).should == "existing content\n#{erased_line}\n#{other_line}\n" + end + end end describe :clear do |