diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-03-02 09:20:00 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-03-02 09:20:00 -0800 |
commit | d9c94d3cf4d76c7fafb0cea7c7becf2b92e8ceb4 (patch) | |
tree | c1a2f0f3d18c057e70a602b8e82a6ba0964f4445 | |
parent | c5bfea7486beb649091d9248310252ae2c0ab416 (diff) | |
download | ohai-fips.tar.gz |
Combine Linux / Windows fips plugins into a single pluginfips
Now that we just reach out to openssl to do the heavy lifting these are the same plugin. There's no point in shipping it twice.
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/plugins/fips.rb (renamed from lib/ohai/plugins/linux/fips.rb) | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/windows/fips.rb | 38 | ||||
-rw-r--r-- | spec/unit/plugins/fips_spec.rb (renamed from spec/unit/plugins/linux/fips_spec.rb) | 6 | ||||
-rw-r--r-- | spec/unit/plugins/windows/fips_spec.rb | 60 |
4 files changed, 4 insertions, 102 deletions
diff --git a/lib/ohai/plugins/linux/fips.rb b/lib/ohai/plugins/fips.rb index 2f90ea94..4c63be88 100644 --- a/lib/ohai/plugins/linux/fips.rb +++ b/lib/ohai/plugins/fips.rb @@ -25,7 +25,7 @@ Ohai.plugin(:Fips) do provides "fips" - collect_data(:linux) do + collect_data(:linux, :windows) do fips Mash.new require "openssl" unless defined?(OpenSSL) diff --git a/lib/ohai/plugins/windows/fips.rb b/lib/ohai/plugins/windows/fips.rb deleted file mode 100644 index 27d36f2d..00000000 --- a/lib/ohai/plugins/windows/fips.rb +++ /dev/null @@ -1,38 +0,0 @@ -# -# Author:: Matt Wrock (<matt@mattwrock.com>) -# Copyright:: Copyright (c) 2016-2018 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# After long discussion in IRC the "powers that be" have come to a concensus -# that there is no other Windows platforms exist that were not based on the -# Windows_NT kernel, so we herby decree that "windows" will refer to all -# platforms built upon the Windows_NT kernel and have access to win32 or win64 -# subsystems. - -Ohai.plugin(:Fips) do - provides "fips" - - collect_data(:windows) do - fips Mash.new - - require "openssl" unless defined?(OpenSSL) - if defined?(OpenSSL.fips_mode) && OpenSSL.fips_mode && !$FIPS_TEST_MODE - fips["kernel"] = { "enabled" => true } - else - fips["kernel"] = { "enabled" => false } - end - end -end diff --git a/spec/unit/plugins/linux/fips_spec.rb b/spec/unit/plugins/fips_spec.rb index cfc6c711..c91ef5b2 100644 --- a/spec/unit/plugins/linux/fips_spec.rb +++ b/spec/unit/plugins/fips_spec.rb @@ -1,6 +1,6 @@ # # Author:: Matt Wrock (<matt@mattwrock.com>) -# Copyright:: Copyright (c) 2016-2018 Chef Software, Inc. +# Copyright:: Copyright (c) 2016-2020 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,8 +25,8 @@ describe Ohai::System, "plugin fips" do plugin["fips"]["kernel"]["enabled"] end - let(:enabled) { "0" } - let(:plugin) { get_plugin("linux/fips") } + let(:enabled) { 0 } + let(:plugin) { get_plugin("fips") } let(:openssl_test_mode) { false } before do diff --git a/spec/unit/plugins/windows/fips_spec.rb b/spec/unit/plugins/windows/fips_spec.rb deleted file mode 100644 index b0b36f54..00000000 --- a/spec/unit/plugins/windows/fips_spec.rb +++ /dev/null @@ -1,60 +0,0 @@ -# -# Author:: Matt Wrock (<matt@mattwrock.com>) -# Copyright:: Copyright (c) 2016-2018 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "spec_helper" -require "openssl" - -describe Ohai::System, "plugin fips" do - subject do - plugin.run - plugin["fips"]["kernel"]["enabled"] - end - - let(:enabled) { 0 } - let(:plugin) { get_plugin("windows/fips") } - let(:openssl_test_mode) { false } - - before do - allow(plugin).to receive(:collect_os).and_return(:windows) - end - - around do |ex| - - $FIPS_TEST_MODE = openssl_test_mode - ex.run - ensure - $FIPS_TEST_MODE = false - - end - - context "with OpenSSL.fips_mode == false" do - before { allow(OpenSSL).to receive(:fips_mode).and_return(false) } - - it "does not set fips plugin" do - expect(subject).to be(false) - end - end - - context "with OpenSSL.fips_mode == true" do - before { allow(OpenSSL).to receive(:fips_mode).and_return(true) } - - it "sets fips plugin" do - expect(subject).to be(true) - end - end -end |