summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG3
-rw-r--r--lib/gitlab_keys.rb2
-rw-r--r--spec/gitlab_keys_spec.rb13
3 files changed, 16 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 778ca4d..07f6c1b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+v1.9.5
+ - Put authorized_keys.lock in the same directory as authorized_keys
+
v1.9.4
- Use lock file when modify authorized_keys
diff --git a/lib/gitlab_keys.rb b/lib/gitlab_keys.rb
index 675f5e1..faa0716 100644
--- a/lib/gitlab_keys.rb
+++ b/lib/gitlab_keys.rb
@@ -92,6 +92,6 @@ class GitlabKeys
end
def lock_file
- @lock_file ||= File.join(ROOT_PATH, "authorized_keys.lock")
+ @lock_file ||= auth_file + '.lock'
end
end
diff --git a/spec/gitlab_keys_spec.rb b/spec/gitlab_keys_spec.rb
index 2ef7241..773b0b6 100644
--- a/spec/gitlab_keys_spec.rb
+++ b/spec/gitlab_keys_spec.rb
@@ -96,7 +96,10 @@ describe GitlabKeys do
end
context "without file writing" do
- before { Tempfile.stub(:open) }
+ before do
+ Tempfile.stub(:open)
+ gitlab_keys.stub(:lock).and_yield
+ end
it "should log an rm-key event" do
$logger.should_receive(:info).with('Removing key key-741')
@@ -146,6 +149,10 @@ describe GitlabKeys do
end
describe :lock do
+ before do
+ GitlabKeys.any_instance.stub(lock_file: tmp_lock_file_path)
+ end
+
it "should raise exception if operation lasts more then timeout" do
key = GitlabKeys.new
expect do
@@ -201,4 +208,8 @@ describe GitlabKeys do
def tmp_authorized_keys_path
File.join(ROOT_PATH, 'tmp', 'authorized_keys')
end
+
+ def tmp_lock_file_path
+ tmp_authorized_keys_path + '.lock'
+ end
end