summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Wrock <matt@mattwrock.com>2016-06-23 16:08:16 -0700
committerGitHub <noreply@github.com>2016-06-23 16:08:16 -0700
commit20774deff25b952ff24d6e6d100007713dcbf005 (patch)
treec7299c8ad8b43444ca4cce51dec51752ce15d672
parent96f9995561bdcf6e5af06303ae4cb4c7e8b876f8 (diff)
parentfbd47fb65265ebbe0cc536cc8ab087a5775b08b3 (diff)
downloadchef-20774deff25b952ff24d6e6d100007713dcbf005.tar.gz
Merge pull request #5048 from chef/fips_unit
Turn off fips with an empty environment var
-rw-r--r--chef-config/lib/chef-config/config.rb11
-rw-r--r--chef-config/spec/unit/config_spec.rb10
2 files changed, 20 insertions, 1 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index 568467456f..094c8641a3 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -519,7 +519,16 @@ module ChefConfig
# Set to true if Chef is to set OpenSSL to run in FIPS mode
default(:fips) do
- !ENV["CHEF_FIPS"].nil? || ChefConfig.fips?
+ # CHEF_FIPS is used in testing to override checking for system level
+ # enablement. There are 3 possible values that this variable may have:
+ # nil - no override and the system will be checked
+ # empty - FIPS is NOT enabled
+ # a non empty value - FIPS is enabled
+ if ENV["CHEF_FIPS"] == ""
+ false
+ else
+ !ENV["CHEF_FIPS"].nil? || ChefConfig.fips?
+ end
end
# Initialize openssl
diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb
index f09dbb517a..0ddb56cf0d 100644
--- a/chef-config/spec/unit/config_spec.rb
+++ b/chef-config/spec/unit/config_spec.rb
@@ -186,6 +186,16 @@ RSpec.describe ChefConfig::Config do
expect(ChefConfig::Config[:fips]).to eq(false)
end
+ context "when ENV['CHEF_FIPS'] is empty" do
+ before do
+ ENV["CHEF_FIPS"] = ""
+ end
+
+ it "returns false" do
+ expect(ChefConfig::Config[:fips]).to eq(false)
+ end
+ end
+
context "when ENV['CHEF_FIPS'] is set" do
before do
ENV["CHEF_FIPS"] = "1"