blob: a5a3105c125cee2c988404886b194fe797b487d2 (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.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
describe '#repair!' do
subject { system_check.repair! }
before do
expect_next_instance_of(Gitlab::AuthorizedKeys) do |instance|
allow(instance).to receive(:create) { created }
end
end
context 'authorized_keys file created' do
let(:created) { true }
it { is_expected.to eq(true) }
end
context 'authorized_keys file is not created' do
let(:created) { false }
it { is_expected.to eq(false) }
end
end
end
|