chef-config 18.2.5 → 18.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +201 -201
- data/Rakefile +14 -14
- data/chef-config.gemspec +39 -39
- data/lib/chef-config/config.rb +1315 -1315
- data/lib/chef-config/exceptions.rb +27 -27
- data/lib/chef-config/fips.rb +53 -53
- data/lib/chef-config/logger.rb +53 -53
- data/lib/chef-config/mixin/credentials.rb +102 -102
- data/lib/chef-config/mixin/dot_d.rb +44 -44
- data/lib/chef-config/mixin/fuzzy_hostname_matcher.rb +49 -49
- data/lib/chef-config/mixin/train_transport.rb +143 -143
- data/lib/chef-config/path_helper.rb +350 -350
- data/lib/chef-config/version.rb +19 -19
- data/lib/chef-config/windows.rb +24 -24
- data/lib/chef-config/workstation_config_loader.rb +282 -282
- data/lib/chef-config.rb +20 -20
- data/spec/spec_helper.rb +75 -75
- data/spec/unit/config_spec.rb +1399 -1399
- data/spec/unit/fips_spec.rb +128 -128
- data/spec/unit/path_helper_spec.rb +372 -372
- data/spec/unit/workstation_config_loader_spec.rb +633 -633
- metadata +4 -4
data/spec/unit/fips_spec.rb
CHANGED
@@ -1,128 +1,128 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Matt Wrock (<matt@mattwrock.com>)
|
3
|
-
# Copyright:: Copyright (c) Chef Software Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require "chef-config/fips"
|
20
|
-
require "spec_helper"
|
21
|
-
|
22
|
-
begin
|
23
|
-
require "win32/registry" unless defined?(Win32::Registry)
|
24
|
-
rescue LoadError
|
25
|
-
# not on unix
|
26
|
-
end
|
27
|
-
|
28
|
-
RSpec.describe "ChefConfig.fips?" do
|
29
|
-
let(:enabled) { "0" }
|
30
|
-
|
31
|
-
context "on *nix" do
|
32
|
-
let(:fips_path) { "/proc/sys/crypto/fips_enabled" }
|
33
|
-
|
34
|
-
before(:each) do
|
35
|
-
allow(ChefUtils).to receive(:windows?).and_return(false)
|
36
|
-
allow(::File).to receive(:exist?).with(fips_path).and_return(true)
|
37
|
-
allow(::File).to receive(:read).with(fips_path).and_return(enabled)
|
38
|
-
end
|
39
|
-
|
40
|
-
context "fips file is present and contains 1" do
|
41
|
-
let(:enabled) { "1" }
|
42
|
-
|
43
|
-
it "returns true" do
|
44
|
-
expect(ChefConfig.fips?).to be(true)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context "fips file does not contain 1" do
|
49
|
-
let(:enabled) { "0" }
|
50
|
-
|
51
|
-
it "returns false" do
|
52
|
-
expect(ChefConfig.fips?).to be(false)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "fips file is not present" do
|
57
|
-
before do
|
58
|
-
allow(::File).to receive(:exist?).with(fips_path).and_return(false)
|
59
|
-
end
|
60
|
-
|
61
|
-
it "returns false" do
|
62
|
-
expect(ChefConfig.fips?).to be(false)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context "on windows", :windows_only do
|
68
|
-
let(:fips_key) { "System\\CurrentControlSet\\Control\\Lsa\\FIPSAlgorithmPolicy" }
|
69
|
-
let(:win_reg_entry) { { "Enabled" => enabled } }
|
70
|
-
|
71
|
-
before(:each) do
|
72
|
-
allow(ChefUtils).to receive(:windows?).and_return(true)
|
73
|
-
allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with(fips_key, arch).and_yield(win_reg_entry)
|
74
|
-
end
|
75
|
-
|
76
|
-
shared_examples "fips_detection" do
|
77
|
-
context "fips enabled key is set to 1" do
|
78
|
-
let(:enabled) { 1 }
|
79
|
-
|
80
|
-
it "returns true" do
|
81
|
-
expect(ChefConfig.fips?).to be(true)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context "fips enabled key is set to 0" do
|
86
|
-
let(:enabled) { 0 }
|
87
|
-
|
88
|
-
it "returns false" do
|
89
|
-
expect(ChefConfig.fips?).to be(false)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
context "fips key does not exist" do
|
94
|
-
before do
|
95
|
-
allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).and_raise(Win32::Registry::Error, 50)
|
96
|
-
end
|
97
|
-
|
98
|
-
it "returns false" do
|
99
|
-
expect(ChefConfig.fips?).to be(false)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context "on 32 bit ruby" do
|
105
|
-
let(:arch) { Win32::Registry::KEY_READ | 0x100 }
|
106
|
-
|
107
|
-
before { stub_const("::RbConfig::CONFIG", { "target_cpu" => "i386" } ) }
|
108
|
-
|
109
|
-
it_behaves_like "fips_detection"
|
110
|
-
end
|
111
|
-
|
112
|
-
context "on 64 bit ruby" do
|
113
|
-
let(:arch) { Win32::Registry::KEY_READ | 0x200 }
|
114
|
-
|
115
|
-
before { stub_const("::RbConfig::CONFIG", { "target_cpu" => "x86_64" } ) }
|
116
|
-
|
117
|
-
it_behaves_like "fips_detection"
|
118
|
-
end
|
119
|
-
|
120
|
-
context "on unknown ruby" do
|
121
|
-
let(:arch) { Win32::Registry::KEY_READ }
|
122
|
-
|
123
|
-
before { stub_const("::RbConfig::CONFIG", { "target_cpu" => nil } ) }
|
124
|
-
|
125
|
-
it_behaves_like "fips_detection"
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
1
|
+
#
|
2
|
+
# Author:: Matt Wrock (<matt@mattwrock.com>)
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require "chef-config/fips"
|
20
|
+
require "spec_helper"
|
21
|
+
|
22
|
+
begin
|
23
|
+
require "win32/registry" unless defined?(Win32::Registry)
|
24
|
+
rescue LoadError
|
25
|
+
# not on unix
|
26
|
+
end
|
27
|
+
|
28
|
+
RSpec.describe "ChefConfig.fips?" do
|
29
|
+
let(:enabled) { "0" }
|
30
|
+
|
31
|
+
context "on *nix" do
|
32
|
+
let(:fips_path) { "/proc/sys/crypto/fips_enabled" }
|
33
|
+
|
34
|
+
before(:each) do
|
35
|
+
allow(ChefUtils).to receive(:windows?).and_return(false)
|
36
|
+
allow(::File).to receive(:exist?).with(fips_path).and_return(true)
|
37
|
+
allow(::File).to receive(:read).with(fips_path).and_return(enabled)
|
38
|
+
end
|
39
|
+
|
40
|
+
context "fips file is present and contains 1" do
|
41
|
+
let(:enabled) { "1" }
|
42
|
+
|
43
|
+
it "returns true" do
|
44
|
+
expect(ChefConfig.fips?).to be(true)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "fips file does not contain 1" do
|
49
|
+
let(:enabled) { "0" }
|
50
|
+
|
51
|
+
it "returns false" do
|
52
|
+
expect(ChefConfig.fips?).to be(false)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "fips file is not present" do
|
57
|
+
before do
|
58
|
+
allow(::File).to receive(:exist?).with(fips_path).and_return(false)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "returns false" do
|
62
|
+
expect(ChefConfig.fips?).to be(false)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "on windows", :windows_only do
|
68
|
+
let(:fips_key) { "System\\CurrentControlSet\\Control\\Lsa\\FIPSAlgorithmPolicy" }
|
69
|
+
let(:win_reg_entry) { { "Enabled" => enabled } }
|
70
|
+
|
71
|
+
before(:each) do
|
72
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
73
|
+
allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with(fips_key, arch).and_yield(win_reg_entry)
|
74
|
+
end
|
75
|
+
|
76
|
+
shared_examples "fips_detection" do
|
77
|
+
context "fips enabled key is set to 1" do
|
78
|
+
let(:enabled) { 1 }
|
79
|
+
|
80
|
+
it "returns true" do
|
81
|
+
expect(ChefConfig.fips?).to be(true)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "fips enabled key is set to 0" do
|
86
|
+
let(:enabled) { 0 }
|
87
|
+
|
88
|
+
it "returns false" do
|
89
|
+
expect(ChefConfig.fips?).to be(false)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "fips key does not exist" do
|
94
|
+
before do
|
95
|
+
allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).and_raise(Win32::Registry::Error, 50)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "returns false" do
|
99
|
+
expect(ChefConfig.fips?).to be(false)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
context "on 32 bit ruby" do
|
105
|
+
let(:arch) { Win32::Registry::KEY_READ | 0x100 }
|
106
|
+
|
107
|
+
before { stub_const("::RbConfig::CONFIG", { "target_cpu" => "i386" } ) }
|
108
|
+
|
109
|
+
it_behaves_like "fips_detection"
|
110
|
+
end
|
111
|
+
|
112
|
+
context "on 64 bit ruby" do
|
113
|
+
let(:arch) { Win32::Registry::KEY_READ | 0x200 }
|
114
|
+
|
115
|
+
before { stub_const("::RbConfig::CONFIG", { "target_cpu" => "x86_64" } ) }
|
116
|
+
|
117
|
+
it_behaves_like "fips_detection"
|
118
|
+
end
|
119
|
+
|
120
|
+
context "on unknown ruby" do
|
121
|
+
let(:arch) { Win32::Registry::KEY_READ }
|
122
|
+
|
123
|
+
before { stub_const("::RbConfig::CONFIG", { "target_cpu" => nil } ) }
|
124
|
+
|
125
|
+
it_behaves_like "fips_detection"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|