diff options
author | Tim Smith <tsmith@chef.io> | 2019-09-09 19:39:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-09 19:39:40 -0700 |
commit | 683b1284e18afa9a0dac508afb5b590aa233b09c (patch) | |
tree | 782932c8ff41d3bd51f6b1dbe19d9b78f9d112b9 /spec | |
parent | a5854d7ae6100a4f4a125d15dbef8fa69ca1cfad (diff) | |
parent | b95561376295a74b04664004071844a3ac52d849 (diff) | |
download | chef-683b1284e18afa9a0dac508afb5b590aa233b09c.tar.gz |
Merge pull request #8816 from MsysTechnologiesllc/VSingh/MSYS-1063-retry-with-pty-true
Bootstrap: Set pty true only if required
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index 5f4be8dfa2..752fcff1e3 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -1021,7 +1021,6 @@ describe Chef::Knife::Bootstrap do verify_host_key: nil, port: 9999, non_interactive: true, - pty: true, } end @@ -1076,7 +1075,6 @@ describe Chef::Knife::Bootstrap do verify_host_key: nil, # Config port: 12, # cli non_interactive: true, - pty: true, } end @@ -1128,7 +1126,6 @@ describe Chef::Knife::Bootstrap do sudo_password: "blah", verify_host_key: true, non_interactive: true, - pty: true, } end it "generates a config hash using the CLI options and pulling nothing from Chef::Config" do @@ -1152,7 +1149,6 @@ describe Chef::Knife::Bootstrap do sudo: false, verify_host_key: "always", non_interactive: true, - pty: true, connection_timeout: 60, } end @@ -1504,7 +1500,6 @@ describe Chef::Knife::Bootstrap do let(:default_opts) do { non_interactive: true, - pty: true, forward_agent: false, connection_timeout: 60, } @@ -2003,6 +1998,19 @@ describe Chef::Knife::Bootstrap do expect(connection).to receive(:connect!) knife.do_connect({}) end + + context "when sshd confgiured with requiretty" do + let(:pty_err_msg) { "Sudo requires a TTY. Please see the README on how to configure sudo to allow for non-interactive usage." } + let(:expected_error) { Train::UserError.new(pty_err_msg, :sudo_no_tty) } + before do + allow(connection).to receive(:connect!).and_raise(expected_error) + end + it "retry with pty true request option" do + expect(Chef::Knife::Bootstrap::TrainConnector).to receive(:new).and_return(connection).exactly(2).times + expect(knife.ui).to receive(:warn).with("#{pty_err_msg} - trying with pty request") + expect { knife.do_connect({}) }.to raise_error(expected_error) + end + end end describe "validate_winrm_transport_opts!" do |