summaryrefslogtreecommitdiff
path: root/spec/lib/system_check/app/authorized_keys_permission_check_spec.rb
blob: ac216c1860c5d0780b96181134131606fc8c9300 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true

require 'spec_helper'

describe SystemCheck::App::AuthorizedKeysPermissionCheck do
  subject(:system_check) { described_class.new }

  describe '#skip?' do
    subject { system_check.skip? }

    context 'authorized keys enabled' do
      it { is_expected.to eq(false) }
    end

    context 'authorized keys not enabled' do
      before do
        stub_application_setting(authorized_keys_enabled: false)
      end

      it { is_expected.to eq(true) }
    end
  end

  describe '#check?' do
    subject { system_check.check? }

    before do
      expect_next_instance_of(Gitlab::AuthorizedKeys) do |instance|
        allow(instance).to receive(:accessible?) { accessible? }
      end
    end

    context 'authorized keys is accessible' do
      let(:accessible?) { true }

      it { is_expected.to eq(true) }
    end

    context 'authorized keys is not accessible' do
      let(:accessible?) { false }

      it { is_expected.to eq(false) }
    end
  end
end