|
8 | 8 |
|
9 | 9 | # Mock out Facter method called when evaluating confine for :kernel |
10 | 10 | allow(Facter::Core::Execution).to receive(:exec).with('uname -s').and_return('Linux') |
11 | | - expect(Facter.fact(:kernel)).to receive(:value).and_return('Linux') |
| 11 | + allow(Facter.fact(:kernel)).to receive(:value).and_return('Linux') |
12 | 12 |
|
13 | 13 | # Ensure that something sane is returned when finding the command |
14 | | - expect(Facter::Util::Resolution).to receive(:which).with('update-crypto-policies').and_return('update-crypto-policies') |
| 14 | + allow(Facter::Util::Resolution).to receive(:which).with('update-crypto-policies').and_return('update-crypto-policies') |
15 | 15 | end |
16 | 16 |
|
17 | 17 | context 'with a functional update-crypto-policies command' do |
18 | 18 | before :each do |
19 | | - expect(Facter::Core::Execution).to receive(:execute).with('update-crypto-policies --no-reload --show', on_fail: false).and_return("DEFAULT\n") |
| 19 | + allow(Facter::Core::Execution).to receive(:execute).with('update-crypto-policies --no-reload --show', on_fail: false).and_return("DEFAULT\n") |
20 | 20 |
|
21 | | - |
22 | | - expect(Dir).to receive(:glob).with('/usr/share/crypto-policies/policies/*.pol').and_return( |
| 21 | + allow(Dir).to receive(:glob).with(['/usr/share/crypto-policies/policies/*.pol', '/etc/crypto-policies/policies/*.pol']).and_return( |
23 | 22 | [ |
24 | 23 | '/usr/share/crypto-policies/policies/DEFAULT.pol', |
25 | | - '/usr/share/crypto-policies/policies/LEGACY.pol' |
26 | | - ] |
| 24 | + '/usr/share/crypto-policies/policies/LEGACY.pol', |
| 25 | + '/etc/crypto-policies/policies/DEFAULT.pol', |
| 26 | + '/etc/crypto-policies/policies/CUSTOM.pol', |
| 27 | + ], |
27 | 28 | ) |
28 | 29 | end |
29 | 30 |
|
30 | 31 | context 'when applied' do |
31 | 32 | before :each do |
32 | | - expect(Facter::Core::Execution).to receive(:execute).with('update-crypto-policies --no-reload --is-applied', on_fail: false).and_return("The configured policy is applied\n") |
| 33 | + allow(Facter::Core::Execution).to receive(:execute).with('update-crypto-policies --no-reload --is-applied', on_fail: false).and_return("The configured policy is applied\n") |
33 | 34 | end |
34 | 35 |
|
35 | 36 | it do |
36 | 37 | expect(Facter.fact('simplib__crypto_policy_state').value).to include( |
37 | 38 | { |
38 | 39 | 'global_policy' => 'DEFAULT', |
39 | 40 | 'global_policy_applied' => true, |
40 | | - 'global_policies_available' => ['DEFAULT', 'LEGACY'] |
| 41 | + 'global_policies_available' => ['DEFAULT', 'LEGACY', 'CUSTOM'] |
41 | 42 | }, |
42 | 43 | ) |
43 | 44 | end |
44 | 45 | end |
45 | 46 |
|
46 | 47 | context 'when not applied' do |
47 | 48 | before :each do |
48 | | - expect(Facter::Core::Execution).to receive(:execute).with('update-crypto-policies --no-reload --is-applied', on_fail: false).and_return("The configured policy is NOT applied\n") |
| 49 | + allow(Facter::Core::Execution).to receive(:execute).with('update-crypto-policies --no-reload --is-applied', on_fail: false).and_return("The configured policy is NOT applied\n") |
49 | 50 | end |
50 | 51 |
|
51 | 52 | it do |
52 | 53 | expect(Facter.fact('simplib__crypto_policy_state').value).to include( |
53 | 54 | { |
54 | 55 | 'global_policy' => 'DEFAULT', |
55 | 56 | 'global_policy_applied' => false, |
56 | | - 'global_policies_available' => ['DEFAULT', 'LEGACY'] |
| 57 | + 'global_policies_available' => ['DEFAULT', 'LEGACY', 'CUSTOM'] |
57 | 58 | }, |
58 | 59 | ) |
59 | 60 | end |
|
62 | 63 |
|
63 | 64 | context 'with a non-functional update-crypto-policies command' do |
64 | 65 | it 'returns a nil value' do |
65 | | - expect(Facter::Core::Execution).to receive(:execute).with('update-crypto-policies --no-reload --show', on_fail: false).and_return(false) |
| 66 | + allow(Facter::Core::Execution).to receive(:execute).with('update-crypto-policies --no-reload --show', on_fail: false).and_return(false) |
66 | 67 |
|
67 | 68 | expect(Facter.fact('simplib__crypto_policy_state').value).to be_nil |
68 | 69 | end |
|
0 commit comments