Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Bajao <ebajao@gitlab.com>2019-08-27 07:33:48 +0300
committerPatrick Bajao <ebajao@gitlab.com>2019-08-29 11:33:04 +0300
commit0e33f16b5f93382214f806737d3fcf5e065c5447 (patch)
treed7ba941512c78438f7605f63bbf255ecb9f22eab /spec/lib/system_check
parent95ffd22f07d821f223388bd60a287365d3b7d8f6 (diff)
Add system check for authorized_keys file perm
This check is being removed from gitlab-shell as the file is now being managed by gitlab-rails.
Diffstat (limited to 'spec/lib/system_check')
-rw-r--r--spec/lib/system_check/app/authorized_keys_permission_check_spec.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/lib/system_check/app/authorized_keys_permission_check_spec.rb b/spec/lib/system_check/app/authorized_keys_permission_check_spec.rb
new file mode 100644
index 00000000000..0aa3539e2bd
--- /dev/null
+++ b/spec/lib/system_check/app/authorized_keys_permission_check_spec.rb
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe SystemCheck::App::AuthorizedKeysPermissionCheck do
+ subject { described_class.new }
+
+ describe '#skip?' do
+ context 'authorized keys enabled' do
+ it 'returns false' do
+ expect(subject.skip?).to eq(false)
+ end
+ end
+
+ context 'authorized keys not enabled' do
+ before do
+ stub_application_setting(authorized_keys_enabled: false)
+ end
+
+ it 'returns true' do
+ expect(subject.skip?).to eq(true)
+ end
+ end
+ end
+
+ describe '#check?' do
+ let(:authorized_keys) { double }
+
+ before do
+ allow(Gitlab::AuthorizedKeys).to receive(:new).and_return(authorized_keys)
+ allow(authorized_keys).to receive(:accessible?).and_return(accessible?)
+ end
+
+ context 'authorized keys is accessible' do
+ let(:accessible?) { true }
+
+ it 'returns true' do
+ expect(subject.check?).to eq(true)
+ end
+ end
+
+ context 'authorized keys is not accessible' do
+ let(:accessible?) { false }
+
+ it 'returns false' do
+ expect(subject.check?).to eq(false)
+ end
+ end
+ end
+end