diff options
author | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-08-20 11:59:29 +0530 |
---|---|---|
committer | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-08-20 11:59:29 +0530 |
commit | 5194689e252ad7caabc37eb60bde13de35ea06ee (patch) | |
tree | f7b0729ad25254d5acc70c11d599e9a63a184a1e | |
parent | 703ef2ac39833fd3883815eb77d4434dacade7ca (diff) | |
download | chef-5194689e252ad7caabc37eb60bde13de35ea06ee.tar.gz |
Add test case to ensure pty requested
Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index 2d5db2a98a..ac31e31a51 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -1998,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) } + 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 |