summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortyler-ball <tball@chef.io>2019-04-18 15:27:54 -0600
committerMark Anderson <mark@chef.io>2019-05-03 21:40:19 -0700
commitdb12e959e88aae92b9414a7637007ce7263fed1a (patch)
tree08169d58c8ec86e3b0675dc4aff84e33dd5ca889
parentf02fe6b3ad2711f7e84f310bf19128b74fc3cd0e (diff)
downloadchef-db12e959e88aae92b9414a7637007ce7263fed1a.tar.gz
knife bootstrap is only knife command to have license acceptance flow
Because in order to run `chef-client` on the bootstrapped node the user needs to have accepted the licenses locally. Right now we have commented out this code because we will enforce it in a different PR. Signed-off-by: tyler-ball <tball@chef.io>
-rw-r--r--lib/chef/application/knife.rb3
-rw-r--r--lib/chef/knife/bootstrap.rb3
-rw-r--r--spec/unit/application/knife_spec.rb2
-rw-r--r--spec/unit/application_spec.rb9
-rw-r--r--spec/unit/knife/bootstrap_spec.rb5
5 files changed, 13 insertions, 9 deletions
diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb
index cc4e66c52f..52d447891f 100644
--- a/lib/chef/application/knife.rb
+++ b/lib/chef/application/knife.rb
@@ -21,10 +21,8 @@ require "mixlib/log"
require "ohai/config"
require "chef/monkey_patches/net_http.rb"
require "chef/dist"
-require "license_acceptance/cli_flags/mixlib_cli"
class Chef::Application::Knife < Chef::Application
- include LicenseAcceptance::CLIFlags::MixlibCLI
NO_COMMAND_GIVEN = "You need to pass a sub-command (e.g., knife SUB-COMMAND)\n".freeze
@@ -161,7 +159,6 @@ class Chef::Application::Knife < Chef::Application
Mixlib::Log::Formatter.show_time = false
validate_and_parse_options
quiet_traps
- check_license_acceptance
Chef::Knife.run(ARGV, options)
exit 0
end
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index 69d9ffb8c0..8539ee7c17 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -19,11 +19,14 @@
require "chef/knife"
require "chef/knife/data_bag_secret_options"
require "chef/dist"
+require "license_acceptance/cli_flags/mixlib_cli"
+require "license_acceptance/acceptor"
class Chef
class Knife
class Bootstrap < Knife
include DataBagSecretOptions
+ # include LicenseAcceptance::CLIFlags::MixlibCLI
SUPPORTED_CONNECTION_PROTOCOLS = %w{ssh winrm}.freeze
WINRM_AUTH_PROTOCOL_LIST = %w{plaintext kerberos ssl negotiate}.freeze
diff --git a/spec/unit/application/knife_spec.rb b/spec/unit/application/knife_spec.rb
index f5ede6318b..f8f5560597 100644
--- a/spec/unit/application/knife_spec.rb
+++ b/spec/unit/application/knife_spec.rb
@@ -45,7 +45,6 @@ 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
@@ -66,7 +65,6 @@ 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
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb
index ca8397f5d7..e5dc0c4a33 100644
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@ -72,7 +72,6 @@ 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)
@@ -88,9 +87,11 @@ describe Chef::Application do
@app.run
end
- it "should check the license acceptance" do
- expect(@app).to receive(:check_license_acceptance)
- @app.run
+ describe "when enforce_license is set to true" do
+ it "should check the license acceptance" do
+ expect(@app).to receive(:check_license_acceptance)
+ @app.run(true)
+ end
end
it "should run the actual application" do
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index 995a2ef4c9..da6bebfd1c 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -293,6 +293,7 @@ describe Chef::Knife::Bootstrap do
end
it "raises a Chef::Exceptions::BootstrapCommandInputError with the proper error message" do
+ # expect(LicenseAcceptance::Acceptor).to receive(:check_and_persist!)
knife.parse_options(["-j", '{"foo":{"bar":"baz"}}'])
knife.parse_options(["--json-attribute-file", jsonfile.path])
knife.merge_configs
@@ -1793,12 +1794,16 @@ describe Chef::Knife::Bootstrap do
end
it "verifies that a server to bootstrap was given as a command line arg" do
+ # expect(LicenseAcceptance::Acceptor).to receive(:check_and_persist!)
knife.name_args = nil
expect { knife.run }.to raise_error(SystemExit)
expect(stderr.string).to match(/ERROR:.+FQDN or ip/)
end
describe "#bootstrap_context" do
+ # before do
+ # expect(LicenseAcceptance::Acceptor).to receive(:check_and_persist!)
+ # end
context "under Windows" do
let(:windows_test) { true }
it "creates a WindowsBootstrapContext" do