summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authortyler-ball <tball@chef.io>2018-12-19 16:17:14 -0700
committerMark Anderson <mark@chef.io>2019-05-03 19:19:10 -0700
commitb134493e65d73636d25aa569f9b77f9c0b4c3f88 (patch)
treeb7969e6aea16fdedda9de9b3a344900438c00dd4 /spec
parentc83bdc4c6adefe29f15ae5bad9eb8f5a6ba30b7e (diff)
downloadchef-b134493e65d73636d25aa569f9b77f9c0b4c3f88.tar.gz
Adding in the license-acceptance flow
This adds a new feature to chef-client where users must accept the EULA before using the product. Users can accept the license by passing '--chef-license accept', setting ENV[CHEF_LICENSE]=accept or by running 'chef-client' and following the interactive prompt. Signed-off-by: tyler-ball <tball@chef.io>
Diffstat (limited to 'spec')
-rw-r--r--spec/integration/client/client_spec.rb18
-rw-r--r--spec/unit/application/knife_spec.rb8
-rw-r--r--spec/unit/application_spec.rb6
3 files changed, 27 insertions, 5 deletions
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index cde25662c1..23f262ad02 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -60,6 +60,24 @@ describe "chef-client" do
shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
end
+ it "should complete successfully with no other environment variables", skip: (Chef::Platform.windows?) do
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to('cookbooks')}"
+ # One environment variable we DO need to prevent hanging
+ ENV["CHEF_LICENSE"] = "accept-no-persist"
+ EOM
+
+ begin
+ result = shell_out("env -i #{critical_env_vars} #{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
+ result.error!
+ rescue
+ Chef::Log.info "Bare invocation will have the following load-path."
+ Chef::Log.info shell_out!("env -i #{critical_env_vars} ruby -e 'puts $:'").stdout
+ raise
+ end
+ end
+
it "should complete successfully with --no-listen" do
file "config/client.rb", <<~EOM
local_mode true
diff --git a/spec/unit/application/knife_spec.rb b/spec/unit/application/knife_spec.rb
index 8a574b4d0f..f5ede6318b 100644
--- a/spec/unit/application/knife_spec.rb
+++ b/spec/unit/application/knife_spec.rb
@@ -45,6 +45,7 @@ describe Chef::Application::Knife do
@knife = Chef::Application::Knife.new
allow(@knife).to receive(:puts)
allow(@knife).to receive(:trap)
+ allow(@knife).to receive(:check_license_acceptance)
allow(Chef::Knife).to receive(:list_commands)
end
@@ -65,6 +66,7 @@ describe Chef::Application::Knife do
with_argv(*%w{noop knife command with some args}) do
knife = double(Chef::Knife)
expect(Chef::Knife).to receive(:run).with(ARGV, @knife.options).and_return(knife)
+ expect(@knife).to receive(:check_license_acceptance)
expect(@knife).to receive(:exit).with(0)
@knife.run
end
@@ -75,11 +77,7 @@ describe Chef::Application::Knife do
expect(@knife).to receive(:exit).with(0)
@knife.run
end
- if windows?
- expect(Chef::Config[:color]).to be_truthy
- else
- expect(Chef::Config[:color]).to be_truthy
- end
+ expect(Chef::Config[:color]).to be_truthy
end
context "when given fips flags" do
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb
index e76e21bddc..ca8397f5d7 100644
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@ -72,6 +72,7 @@ describe Chef::Application do
describe "run" do
before do
allow(@app).to receive(:setup_application).and_return(true)
+ allow(@app).to receive(:check_license_acceptance)
allow(@app).to receive(:run_application).and_return(true)
allow(@app).to receive(:configure_chef).and_return(true)
allow(@app).to receive(:configure_logging).and_return(true)
@@ -87,6 +88,11 @@ describe Chef::Application do
@app.run
end
+ it "should check the license acceptance" do
+ expect(@app).to receive(:check_license_acceptance)
+ @app.run
+ end
+
it "should run the actual application" do
expect(@app).to receive(:run_application).and_return(true)
@app.run