diff options
author | Patrick Bajao <ebajao@gitlab.com> | 2019-08-29 11:28:22 +0300 |
---|---|---|
committer | Patrick Bajao <ebajao@gitlab.com> | 2019-08-29 11:33:04 +0300 |
commit | a1ec2ad0b2638f084dffbe804b681c96dc6dadb8 (patch) | |
tree | eff3f8eee80adf8abdf7b656512f85ffee5527dd /spec/lib/gitlab/authorized_keys_spec.rb | |
parent | b047359de5b365022d63b8da10a3a87f3ad92397 (diff) |
Auto create authorized_keys file if doesn't exist
Utilize the auto repair functionality of system checks.
Diffstat (limited to 'spec/lib/gitlab/authorized_keys_spec.rb')
-rw-r--r-- | spec/lib/gitlab/authorized_keys_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/lib/gitlab/authorized_keys_spec.rb b/spec/lib/gitlab/authorized_keys_spec.rb index 0aeccc256ca..adf36cf1050 100644 --- a/spec/lib/gitlab/authorized_keys_spec.rb +++ b/spec/lib/gitlab/authorized_keys_spec.rb @@ -37,6 +37,41 @@ describe Gitlab::AuthorizedKeys do end end + describe '#create' do + subject { authorized_keys.create } + + context 'authorized_keys file exists' do + before do + create_authorized_keys_fixture + end + + after do + delete_authorized_keys_file + end + + it { is_expected.to be_truthy } + end + + context 'authorized_keys file does not exist' do + after do + delete_authorized_keys_file + end + + it 'creates authorized_keys file' do + expect(subject).to be_truthy + expect(File.exist?(tmp_authorized_keys_path)).to be_truthy + end + end + + context 'cannot create file' do + before do + allow(File).to receive(:open).and_raise(Errno::EACCES) + end + + it { is_expected.to be_falsey } + end + end + describe '#add_key' do let(:id) { 'key-741' } |