diff options
author | Tyler Ball <tyler-ball@users.noreply.github.com> | 2017-02-23 12:41:25 -0600 |
---|---|---|
committer | tyler-ball <tyleraball@gmail.com> | 2017-02-23 12:52:33 -0600 |
commit | 9a066eece59dfd146d8b72c970a7189b65004a5f (patch) | |
tree | 6345ab07e6608d70e6b4fcca943a512dee0fb3c3 /spec | |
parent | 42445a55fe97a4c8c1b5b88b91b38e3f15babc61 (diff) | |
download | chef-9a066eece59dfd146d8b72c970a7189b65004a5f.tar.gz |
Require chef/version when trying to read iter-478/fips_bootstrap
When a node is bootstrapped in FIPS mode and then tries to run a
chef-client run it gets the following error:
```
STDERR: /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-config-12.18.31/lib/chef-config/workstation_config_loader.rb:163:in `rescue in apply_config': You have an error in your config file /var/opt/delivery/workspace/.chef/knife.rb (ChefConfig::ConfigurationError)
NameError: uninitialized constant Chef
/var/opt/delivery/workspace/.chef/knife.rb:2:in `eval'
/var/opt/delivery/workspace/.chef/knife.rb:2:in `eval'
/var/opt/delivery/workspace/.chef/knife.rb:2:in `from_string'
```
Signed-off-by: tyler-ball <tyleraball@gmail.com>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/knife/core/bootstrap_context_spec.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb index 515381cf6e..3a32155063 100644 --- a/spec/unit/knife/core/bootstrap_context_spec.rb +++ b/spec/unit/knife/core/bootstrap_context_spec.rb @@ -213,6 +213,23 @@ EXPECTED end end + describe "fips mode" do + before do + Chef::Config[:fips] = true + end + + it "adds the chef version check" do + expect(bootstrap_context.config_content).to include <<-CONFIG.gsub(/^ {8}/, "") + fips true + require "chef/version" + chef_version = ::Chef::VERSION.split(".") + unless chef_version[0].to_i > 12 || (chef_version[0].to_i == 12 && chef_version[1].to_i >= 8) + raise "FIPS Mode requested but not supported by this client" + end + CONFIG + end + end + describe "verify_api_cert" do it "isn't set in the config_content by default" do expect(bootstrap_context.config_content).not_to include("verify_api_cert") |