knife-windows 3.0.17 → 4.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/chef/knife/bootstrap_windows_ssh.rb +3 -4
 - data/lib/chef/knife/helpers/bootstrap_windows_base.rb +14 -21
 - data/lib/chef/knife/helpers/winrm_base.rb +10 -23
 - data/lib/chef/knife/helpers/winrm_knife_base.rb +22 -22
 - data/lib/chef/knife/helpers/winrm_session.rb +1 -2
 - data/lib/chef/knife/windows_cert_generate.rb +3 -3
 - data/lib/chef/knife/windows_listener_create.rb +1 -1
 - data/lib/chef/knife/winrm.rb +1 -3
 - data/lib/knife-windows/version.rb +1 -1
 - data/spec/spec_helper.rb +16 -1
 - data/spec/unit/knife/winrm_spec.rb +7 -9
 - data/spec/unit/knife/wsman_test_spec.rb +2 -1
 - metadata +5 -18
 - data/lib/chef/knife/helpers/knife_windows_base.rb +0 -34
 - data/spec/assets/win_template_rendered_with_bootstrap_install_command.txt +0 -220
 - data/spec/assets/win_template_rendered_with_bootstrap_install_command_on_13_client.txt +0 -220
 - data/spec/assets/win_template_rendered_without_bootstrap_install_command.txt +0 -332
 - data/spec/assets/win_template_rendered_without_bootstrap_install_command_on_12_5_client.txt +0 -332
 - data/spec/assets/win_template_rendered_without_bootstrap_install_command_on_13_client.txt +0 -332
 - data/spec/assets/win_template_unrendered.txt +0 -246
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 8f429ee0fa74c0d2ececf226e1605a165233e01d84071ec07dcd294bcce0e47a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7e45e692b1496971400cf3da7af3a39139589d17ccc9badff99aaa8d456f6c84
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 9fadc2ce078b8845adefde49d8bfcf8e87940b690cb88b1ceab7f1659f413dea8093247e91151802c095bb99cb8f750441c87f0836845a58a83aa8a000ffda71
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 37022b1de2db4b3861617e9035b3197a691b690ba197bccf59b98758c1e77387ffa8837c3c3536e46a8e469a8507bb2e9ed57add8b4998c9ecd8f385c5f25de4
         
     | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #
         
     | 
| 
       2 
2 
     | 
    
         
             
            # Author:: Seth Chisamore (<schisamo@chef.io>)
         
     | 
| 
       3 
     | 
    
         
            -
            # Copyright:: Copyright (c)  
     | 
| 
      
 3 
     | 
    
         
            +
            # Copyright:: Copyright (c) Chef Software Inc.
         
     | 
| 
       4 
4 
     | 
    
         
             
            # License:: Apache License, Version 2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
         @@ -42,13 +42,12 @@ class Chef 
     | 
|
| 
       42 
42 
     | 
    
         
             
                    short: "-p PORT",
         
     | 
| 
       43 
43 
     | 
    
         
             
                    long: "--ssh-port PORT",
         
     | 
| 
       44 
44 
     | 
    
         
             
                    description: "The ssh port",
         
     | 
| 
       45 
     | 
    
         
            -
                    proc: Proc.new { |key|  
     | 
| 
      
 45 
     | 
    
         
            +
                    proc: Proc.new { |key| key.strip }
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
       47 
47 
     | 
    
         
             
                  option :ssh_gateway,
         
     | 
| 
       48 
48 
     | 
    
         
             
                    short: "-G GATEWAY",
         
     | 
| 
       49 
49 
     | 
    
         
             
                    long: "--ssh-gateway GATEWAY",
         
     | 
| 
       50 
     | 
    
         
            -
                    description: "The ssh gateway" 
     | 
| 
       51 
     | 
    
         
            -
                    proc: Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key }
         
     | 
| 
      
 50 
     | 
    
         
            +
                    description: "The ssh gateway"
         
     | 
| 
       52 
51 
     | 
    
         | 
| 
       53 
52 
     | 
    
         
             
                  option :forward_agent,
         
     | 
| 
       54 
53 
     | 
    
         
             
                    short: "-A",
         
     | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #
         
     | 
| 
       2 
2 
     | 
    
         
             
            # Author:: Seth Chisamore (<schisamo@chef.io>)
         
     | 
| 
       3 
     | 
    
         
            -
            # Copyright:: Copyright (c)  
     | 
| 
      
 3 
     | 
    
         
            +
            # Copyright:: Copyright (c) Chef Software Inc.
         
     | 
| 
       4 
4 
     | 
    
         
             
            # License:: Apache License, Version 2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
         @@ -17,15 +17,11 @@ 
     | 
|
| 
       17 
17 
     | 
    
         
             
            #
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
            require "chef/knife"
         
     | 
| 
       20 
     | 
    
         
            -
            require_relative "knife_windows_base"
         
     | 
| 
       21 
20 
     | 
    
         
             
            require "chef/util/path_helper"
         
     | 
| 
       22 
21 
     | 
    
         | 
| 
       23 
22 
     | 
    
         
             
            class Chef
         
     | 
| 
       24 
23 
     | 
    
         
             
              class Knife
         
     | 
| 
       25 
24 
     | 
    
         
             
                module BootstrapWindowsBase
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                  include Chef::Knife::KnifeWindowsBase
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
25 
     | 
    
         
             
                  # :nodoc:
         
     | 
| 
       30 
26 
     | 
    
         
             
                  # Would prefer to do this in a rational way, but can't be done b/c of
         
     | 
| 
       31 
27 
     | 
    
         
             
                  # Mixlib::CLI's design :(
         
     | 
| 
         @@ -43,23 +39,19 @@ class Chef 
     | 
|
| 
       43 
39 
     | 
    
         | 
| 
       44 
40 
     | 
    
         
             
                      option :bootstrap_version,
         
     | 
| 
       45 
41 
     | 
    
         
             
                        long: "--bootstrap-version VERSION",
         
     | 
| 
       46 
     | 
    
         
            -
                        description: "The version of Chef to install" 
     | 
| 
       47 
     | 
    
         
            -
                        proc: Proc.new { |v| Chef::Config[:knife][:bootstrap_version] = v }
         
     | 
| 
      
 42 
     | 
    
         
            +
                        description: "The version of Chef to install"
         
     | 
| 
       48 
43 
     | 
    
         | 
| 
       49 
44 
     | 
    
         
             
                      option :bootstrap_proxy,
         
     | 
| 
       50 
45 
     | 
    
         
             
                        long: "--bootstrap-proxy PROXY_URL",
         
     | 
| 
       51 
     | 
    
         
            -
                        description: "The proxy server for the node being bootstrapped" 
     | 
| 
       52 
     | 
    
         
            -
                        proc: Proc.new { |p| Chef::Config[:knife][:bootstrap_proxy] = p }
         
     | 
| 
      
 46 
     | 
    
         
            +
                        description: "The proxy server for the node being bootstrapped"
         
     | 
| 
       53 
47 
     | 
    
         | 
| 
       54 
48 
     | 
    
         
             
                      option :bootstrap_no_proxy,
         
     | 
| 
       55 
49 
     | 
    
         
             
                        long: "--bootstrap-no-proxy [NO_PROXY_URL|NO_PROXY_IP]",
         
     | 
| 
       56 
     | 
    
         
            -
                        description: "Do not proxy locations for the node being bootstrapped; this option is used internally by Opscode" 
     | 
| 
       57 
     | 
    
         
            -
                        proc: Proc.new { |np| Chef::Config[:knife][:bootstrap_no_proxy] = np }
         
     | 
| 
      
 50 
     | 
    
         
            +
                        description: "Do not proxy locations for the node being bootstrapped; this option is used internally by Opscode"
         
     | 
| 
       58 
51 
     | 
    
         | 
| 
       59 
52 
     | 
    
         
             
                      option :bootstrap_install_command,
         
     | 
| 
       60 
53 
     | 
    
         
             
                        long: "--bootstrap-install-command COMMANDS",
         
     | 
| 
       61 
     | 
    
         
            -
                        description: "Custom command to install chef-client" 
     | 
| 
       62 
     | 
    
         
            -
                        proc: Proc.new { |ic| Chef::Config[:knife][:bootstrap_install_command] = ic }
         
     | 
| 
      
 54 
     | 
    
         
            +
                        description: "Custom command to install chef-client"
         
     | 
| 
       63 
55 
     | 
    
         | 
| 
       64 
56 
     | 
    
         
             
                      option :bootstrap_template,
         
     | 
| 
       65 
57 
     | 
    
         
             
                        short: "-t TEMPLATE",
         
     | 
| 
         @@ -76,10 +68,11 @@ class Chef 
     | 
|
| 
       76 
68 
     | 
    
         
             
                      option :hint,
         
     | 
| 
       77 
69 
     | 
    
         
             
                        long: "--hint HINT_NAME[=HINT_FILE]",
         
     | 
| 
       78 
70 
     | 
    
         
             
                        description: "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.",
         
     | 
| 
       79 
     | 
    
         
            -
                        proc: Proc.new { |h|
         
     | 
| 
       80 
     | 
    
         
            -
                           
     | 
| 
      
 71 
     | 
    
         
            +
                        proc: Proc.new { |h, accumulator|
         
     | 
| 
      
 72 
     | 
    
         
            +
                          accumulator ||= {}
         
     | 
| 
       81 
73 
     | 
    
         
             
                          name, path = h.split("=")
         
     | 
| 
       82 
     | 
    
         
            -
                           
     | 
| 
      
 74 
     | 
    
         
            +
                          accumulator[name] = path ? Chef::JSONCompat.parse(::File.read(path)) : {}
         
     | 
| 
      
 75 
     | 
    
         
            +
                          accumulator
         
     | 
| 
       83 
76 
     | 
    
         
             
                        }
         
     | 
| 
       84 
77 
     | 
    
         | 
| 
       85 
78 
     | 
    
         
             
                      option :first_boot_attributes,
         
     | 
| 
         @@ -151,12 +144,12 @@ class Chef 
     | 
|
| 
       151 
144 
     | 
    
         
             
                      option :bootstrap_vault_item,
         
     | 
| 
       152 
145 
     | 
    
         
             
                        long: "--bootstrap-vault-item VAULT_ITEM",
         
     | 
| 
       153 
146 
     | 
    
         
             
                        description: 'A single vault and item to update as "vault:item"',
         
     | 
| 
       154 
     | 
    
         
            -
                        proc: Proc.new { |i|
         
     | 
| 
      
 147 
     | 
    
         
            +
                        proc: Proc.new { |i, accumulator|
         
     | 
| 
       155 
148 
     | 
    
         
             
                          (vault, item) = i.split(/:/)
         
     | 
| 
       156 
     | 
    
         
            -
                           
     | 
| 
       157 
     | 
    
         
            -
                           
     | 
| 
       158 
     | 
    
         
            -
                           
     | 
| 
       159 
     | 
    
         
            -
                           
     | 
| 
      
 149 
     | 
    
         
            +
                          accumulator ||= {}
         
     | 
| 
      
 150 
     | 
    
         
            +
                          accumulator[vault] ||= []
         
     | 
| 
      
 151 
     | 
    
         
            +
                          accumulator[vault].push(item)
         
     | 
| 
      
 152 
     | 
    
         
            +
                          accumulator
         
     | 
| 
       160 
153 
     | 
    
         
             
                        }
         
     | 
| 
       161 
154 
     | 
    
         | 
| 
       162 
155 
     | 
    
         
             
                      option :policy_name,
         
     | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #
         
     | 
| 
       2 
2 
     | 
    
         
             
            # Author:: Seth Chisamore (<schisamo@chef.io>)
         
     | 
| 
       3 
     | 
    
         
            -
            # Copyright:: Copyright (c)  
     | 
| 
      
 3 
     | 
    
         
            +
            # Copyright:: Copyright (c) Chef Software Inc.
         
     | 
| 
       4 
4 
     | 
    
         
             
            # License:: Apache License, Version 2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
         @@ -42,14 +42,12 @@ class Chef 
     | 
|
| 
       42 
42 
     | 
    
         
             
                        short: "-x USERNAME",
         
     | 
| 
       43 
43 
     | 
    
         
             
                        long: "--winrm-user USERNAME",
         
     | 
| 
       44 
44 
     | 
    
         
             
                        description: "The WinRM username",
         
     | 
| 
       45 
     | 
    
         
            -
                        default: "Administrator" 
     | 
| 
       46 
     | 
    
         
            -
                        proc: Proc.new { |key| Chef::Config[:knife][:winrm_user] = key }
         
     | 
| 
      
 45 
     | 
    
         
            +
                        default: "Administrator"
         
     | 
| 
       47 
46 
     | 
    
         | 
| 
       48 
47 
     | 
    
         
             
                      option :winrm_password,
         
     | 
| 
       49 
48 
     | 
    
         
             
                        short: "-P PASSWORD",
         
     | 
| 
       50 
49 
     | 
    
         
             
                        long: "--winrm-password PASSWORD",
         
     | 
| 
       51 
     | 
    
         
            -
                        description: "The WinRM password" 
     | 
| 
       52 
     | 
    
         
            -
                        proc: Proc.new { |key| Chef::Config[:knife][:winrm_password] = key }
         
     | 
| 
      
 50 
     | 
    
         
            +
                        description: "The WinRM password"
         
     | 
| 
       53 
51 
     | 
    
         | 
| 
       54 
52 
     | 
    
         
             
                      option :winrm_shell,
         
     | 
| 
       55 
53 
     | 
    
         
             
                        long: "--winrm-shell SHELL",
         
     | 
| 
         @@ -61,42 +59,32 @@ class Chef 
     | 
|
| 
       61 
59 
     | 
    
         
             
                        short: "-w TRANSPORT",
         
     | 
| 
       62 
60 
     | 
    
         
             
                        long: "--winrm-transport TRANSPORT",
         
     | 
| 
       63 
61 
     | 
    
         
             
                        description: "The WinRM transport type. Valid choices are [ssl, plaintext]",
         
     | 
| 
       64 
     | 
    
         
            -
                        default: "plaintext" 
     | 
| 
       65 
     | 
    
         
            -
                        proc: Proc.new { |transport|
         
     | 
| 
       66 
     | 
    
         
            -
                          Chef::Config[:knife][:winrm_port] = "5986" if transport == "ssl"
         
     | 
| 
       67 
     | 
    
         
            -
                          Chef::Config[:knife][:winrm_transport] = transport
         
     | 
| 
       68 
     | 
    
         
            -
                        }
         
     | 
| 
      
 62 
     | 
    
         
            +
                        default: "plaintext"
         
     | 
| 
       69 
63 
     | 
    
         | 
| 
       70 
64 
     | 
    
         
             
                      option :winrm_port,
         
     | 
| 
       71 
65 
     | 
    
         
             
                        short: "-p PORT",
         
     | 
| 
       72 
66 
     | 
    
         
             
                        long: "--winrm-port PORT",
         
     | 
| 
       73 
     | 
    
         
            -
                        description: "The WinRM port, by default this is '5985' for 'plaintext' and '5986' for 'ssl' winrm transport" 
     | 
| 
       74 
     | 
    
         
            -
                        default: "5985",
         
     | 
| 
       75 
     | 
    
         
            -
                        proc: Proc.new { |key| Chef::Config[:knife][:winrm_port] = key }
         
     | 
| 
      
 67 
     | 
    
         
            +
                        description: "The WinRM port, by default this is '5985' for 'plaintext' and '5986' for 'ssl' winrm transport"
         
     | 
| 
       76 
68 
     | 
    
         | 
| 
       77 
69 
     | 
    
         
             
                      option :kerberos_keytab_file,
         
     | 
| 
       78 
70 
     | 
    
         
             
                        short: "-T KEYTAB_FILE",
         
     | 
| 
       79 
71 
     | 
    
         
             
                        long: "--keytab-file KEYTAB_FILE",
         
     | 
| 
       80 
     | 
    
         
            -
                        description: "The Kerberos keytab file used for authentication" 
     | 
| 
       81 
     | 
    
         
            -
                        proc: Proc.new { |keytab| Chef::Config[:knife][:kerberos_keytab_file] = keytab }
         
     | 
| 
      
 72 
     | 
    
         
            +
                        description: "The Kerberos keytab file used for authentication"
         
     | 
| 
       82 
73 
     | 
    
         | 
| 
       83 
74 
     | 
    
         
             
                      option :kerberos_realm,
         
     | 
| 
       84 
75 
     | 
    
         
             
                        short: "-R KERBEROS_REALM",
         
     | 
| 
       85 
76 
     | 
    
         
             
                        long: "--kerberos-realm KERBEROS_REALM",
         
     | 
| 
       86 
     | 
    
         
            -
                        description: "The Kerberos realm used for authentication" 
     | 
| 
       87 
     | 
    
         
            -
                        proc: Proc.new { |realm| Chef::Config[:knife][:kerberos_realm] = realm }
         
     | 
| 
      
 77 
     | 
    
         
            +
                        description: "The Kerberos realm used for authentication"
         
     | 
| 
       88 
78 
     | 
    
         | 
| 
       89 
79 
     | 
    
         
             
                      option :kerberos_service,
         
     | 
| 
       90 
80 
     | 
    
         
             
                        short: "-S KERBEROS_SERVICE",
         
     | 
| 
       91 
81 
     | 
    
         
             
                        long: "--kerberos-service KERBEROS_SERVICE",
         
     | 
| 
       92 
     | 
    
         
            -
                        description: "The Kerberos service used for authentication" 
     | 
| 
       93 
     | 
    
         
            -
                        proc: Proc.new { |service| Chef::Config[:knife][:kerberos_service] = service }
         
     | 
| 
      
 82 
     | 
    
         
            +
                        description: "The Kerberos service used for authentication"
         
     | 
| 
       94 
83 
     | 
    
         | 
| 
       95 
84 
     | 
    
         
             
                      option :ca_trust_file,
         
     | 
| 
       96 
85 
     | 
    
         
             
                        short: "-f CA_TRUST_FILE",
         
     | 
| 
       97 
86 
     | 
    
         
             
                        long: "--ca-trust-file CA_TRUST_FILE",
         
     | 
| 
       98 
     | 
    
         
            -
                        description: "The Certificate Authority (CA) trust file used for SSL transport" 
     | 
| 
       99 
     | 
    
         
            -
                        proc: Proc.new { |trust| Chef::Config[:knife][:ca_trust_file] = trust }
         
     | 
| 
      
 87 
     | 
    
         
            +
                        description: "The Certificate Authority (CA) trust file used for SSL transport"
         
     | 
| 
       100 
88 
     | 
    
         | 
| 
       101 
89 
     | 
    
         
             
                      option :winrm_ssl_verify_mode,
         
     | 
| 
       102 
90 
     | 
    
         
             
                        long: "--winrm-ssl-verify-mode SSL_VERIFY_MODE",
         
     | 
| 
         @@ -111,8 +99,7 @@ class Chef 
     | 
|
| 
       111 
99 
     | 
    
         
             
                      option :winrm_authentication_protocol,
         
     | 
| 
       112 
100 
     | 
    
         
             
                        long: "--winrm-authentication-protocol AUTHENTICATION_PROTOCOL",
         
     | 
| 
       113 
101 
     | 
    
         
             
                        description: "The authentication protocol used during WinRM communication. The supported protocols are #{WINRM_AUTH_PROTOCOL_LIST.join(",")}. Default is 'negotiate'.",
         
     | 
| 
       114 
     | 
    
         
            -
                        default: "negotiate" 
     | 
| 
       115 
     | 
    
         
            -
                        proc: Proc.new { |protocol| Chef::Config[:knife][:winrm_authentication_protocol] = protocol }
         
     | 
| 
      
 102 
     | 
    
         
            +
                        default: "negotiate"
         
     | 
| 
       116 
103 
     | 
    
         | 
| 
       117 
104 
     | 
    
         
             
                      option :session_timeout,
         
     | 
| 
       118 
105 
     | 
    
         
             
                        long: "--session-timeout Minutes",
         
     | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #
         
     | 
| 
       2 
2 
     | 
    
         
             
            # Author:: Steven Murawski (<smurawski@chef.io)
         
     | 
| 
       3 
     | 
    
         
            -
            # Copyright:: Copyright (c)  
     | 
| 
      
 3 
     | 
    
         
            +
            # Copyright:: Copyright (c) Chef Software Inc.
         
     | 
| 
       4 
4 
     | 
    
         
             
            # License:: Apache License, Version 2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
         @@ -19,7 +19,6 @@ 
     | 
|
| 
       19 
19 
     | 
    
         
             
            require "chef/knife"
         
     | 
| 
       20 
20 
     | 
    
         
             
            require_relative "winrm_base"
         
     | 
| 
       21 
21 
     | 
    
         
             
            require_relative "winrm_shared_options"
         
     | 
| 
       22 
     | 
    
         
            -
            require_relative "knife_windows_base"
         
     | 
| 
       23 
22 
     | 
    
         
             
            require_relative "winrm_session"
         
     | 
| 
       24 
23 
     | 
    
         | 
| 
       25 
24 
     | 
    
         
             
            class Chef
         
     | 
| 
         @@ -40,10 +39,9 @@ class Chef 
     | 
|
| 
       40 
39 
     | 
    
         | 
| 
       41 
40 
     | 
    
         
             
                      include Chef::Knife::WinrmBase
         
     | 
| 
       42 
41 
     | 
    
         
             
                      include Chef::Knife::WinrmSharedOptions
         
     | 
| 
       43 
     | 
    
         
            -
                      include Chef::Knife::KnifeWindowsBase
         
     | 
| 
       44 
42 
     | 
    
         | 
| 
       45 
43 
     | 
    
         
             
                      def validate_winrm_options!
         
     | 
| 
       46 
     | 
    
         
            -
                        winrm_auth_protocol =  
     | 
| 
      
 44 
     | 
    
         
            +
                        winrm_auth_protocol = config[:winrm_authentication_protocol]
         
     | 
| 
       47 
45 
     | 
    
         | 
| 
       48 
46 
     | 
    
         
             
                        unless Chef::Knife::WinrmBase::WINRM_AUTH_PROTOCOL_LIST.include?(winrm_auth_protocol)
         
     | 
| 
       49 
47 
     | 
    
         
             
                          ui.error "Invalid value '#{winrm_auth_protocol}' for --winrm-authentication-protocol option."
         
     | 
| 
         @@ -121,7 +119,7 @@ class Chef 
     | 
|
| 
       121 
119 
     | 
    
         
             
                        @session_results = []
         
     | 
| 
       122 
120 
     | 
    
         
             
                        queue = Queue.new
         
     | 
| 
       123 
121 
     | 
    
         
             
                        @winrm_sessions.each { |s| queue << s }
         
     | 
| 
       124 
     | 
    
         
            -
                        num_sessions =  
     | 
| 
      
 122 
     | 
    
         
            +
                        num_sessions = config[:concurrency]
         
     | 
| 
       125 
123 
     | 
    
         
             
                        num_targets = @winrm_sessions.length
         
     | 
| 
       126 
124 
     | 
    
         
             
                        num_sessions = (num_sessions.nil? || num_sessions == 0) ? num_targets : [num_sessions, num_targets].min
         
     | 
| 
       127 
125 
     | 
    
         | 
| 
         @@ -147,7 +145,7 @@ class Chef 
     | 
|
| 
       147 
145 
     | 
    
         
             
                        if authorization_error?(e)
         
     | 
| 
       148 
146 
     | 
    
         
             
                          unless config[:suppress_auth_failure]
         
     | 
| 
       149 
147 
     | 
    
         
             
                            # Display errors if the caller hasn't opted to retry
         
     | 
| 
       150 
     | 
    
         
            -
                            ui.error "Failed to authenticate to #{s.host} as #{ 
     | 
| 
      
 148 
     | 
    
         
            +
                            ui.error "Failed to authenticate to #{s.host} as #{config[:winrm_user]}"
         
     | 
| 
       151 
149 
     | 
    
         
             
                            ui.info "Response: #{e.message}"
         
     | 
| 
       152 
150 
     | 
    
         
             
                            ui.info get_failed_authentication_hint
         
     | 
| 
       153 
151 
     | 
    
         
             
                            raise e
         
     | 
| 
         @@ -203,33 +201,35 @@ class Chef 
     | 
|
| 
       203 
201 
     | 
    
         
             
                      end
         
     | 
| 
       204 
202 
     | 
    
         | 
| 
       205 
203 
     | 
    
         
             
                      def resolve_session_options
         
     | 
| 
      
 204 
     | 
    
         
            +
                        config[:winrm_port] ||= ( config[:winrm_transport] == "ssl" ) ? "5986" : "5985"
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
       206 
206 
     | 
    
         
             
                        @session_opts = {
         
     | 
| 
       207 
207 
     | 
    
         
             
                          user: resolve_winrm_user,
         
     | 
| 
       208 
     | 
    
         
            -
                          password:  
     | 
| 
       209 
     | 
    
         
            -
                          port:  
     | 
| 
      
 208 
     | 
    
         
            +
                          password: config[:winrm_password],
         
     | 
| 
      
 209 
     | 
    
         
            +
                          port: config[:winrm_port],
         
     | 
| 
       210 
210 
     | 
    
         
             
                          operation_timeout: resolve_winrm_session_timeout,
         
     | 
| 
       211 
211 
     | 
    
         
             
                          basic_auth_only: resolve_winrm_basic_auth,
         
     | 
| 
       212 
212 
     | 
    
         
             
                          disable_sspi: resolve_winrm_disable_sspi,
         
     | 
| 
       213 
213 
     | 
    
         
             
                          transport: resolve_winrm_transport,
         
     | 
| 
       214 
214 
     | 
    
         
             
                          no_ssl_peer_verification: resolve_no_ssl_peer_verification,
         
     | 
| 
       215 
215 
     | 
    
         
             
                          ssl_peer_fingerprint: resolve_ssl_peer_fingerprint,
         
     | 
| 
       216 
     | 
    
         
            -
                          shell:  
     | 
| 
       217 
     | 
    
         
            -
                          codepage:  
     | 
| 
      
 216 
     | 
    
         
            +
                          shell: config[:winrm_shell],
         
     | 
| 
      
 217 
     | 
    
         
            +
                          codepage: config[:winrm_codepage],
         
     | 
| 
       218 
218 
     | 
    
         
             
                        }
         
     | 
| 
       219 
219 
     | 
    
         | 
| 
       220 
220 
     | 
    
         
             
                        if @session_opts[:user] && (not @session_opts[:password])
         
     | 
| 
       221 
     | 
    
         
            -
                          @session_opts[:password] =  
     | 
| 
      
 221 
     | 
    
         
            +
                          @session_opts[:password] = config[:winrm_password] = get_password
         
     | 
| 
       222 
222 
     | 
    
         
             
                        end
         
     | 
| 
       223 
223 
     | 
    
         | 
| 
       224 
224 
     | 
    
         
             
                        if @session_opts[:transport] == :kerberos
         
     | 
| 
       225 
225 
     | 
    
         
             
                          @session_opts.merge!(resolve_winrm_kerberos_options)
         
     | 
| 
       226 
226 
     | 
    
         
             
                        end
         
     | 
| 
       227 
227 
     | 
    
         | 
| 
       228 
     | 
    
         
            -
                        @session_opts[:ca_trust_path] =  
     | 
| 
      
 228 
     | 
    
         
            +
                        @session_opts[:ca_trust_path] = config[:ca_trust_file] if config[:ca_trust_file]
         
     | 
| 
       229 
229 
     | 
    
         
             
                      end
         
     | 
| 
       230 
230 
     | 
    
         | 
| 
       231 
231 
     | 
    
         
             
                      def resolve_winrm_user
         
     | 
| 
       232 
     | 
    
         
            -
                        user =  
     | 
| 
      
 232 
     | 
    
         
            +
                        user = config[:winrm_user]
         
     | 
| 
       233 
233 
     | 
    
         | 
| 
       234 
234 
     | 
    
         
             
                        # Prefixing with '.\' when using negotiate
         
     | 
| 
       235 
235 
     | 
    
         
             
                        # to auth user against local machine domain
         
     | 
| 
         @@ -245,23 +245,23 @@ class Chef 
     | 
|
| 
       245 
245 
     | 
    
         | 
| 
       246 
246 
     | 
    
         
             
                      def resolve_winrm_session_timeout
         
     | 
| 
       247 
247 
     | 
    
         
             
                        # 30 min (Default) OperationTimeout for long bootstraps fix for KNIFE_WINDOWS-8
         
     | 
| 
       248 
     | 
    
         
            -
                         
     | 
| 
      
 248 
     | 
    
         
            +
                        config[:session_timeout].to_i * 60 if config[:session_timeout]
         
     | 
| 
       249 
249 
     | 
    
         
             
                      end
         
     | 
| 
       250 
250 
     | 
    
         | 
| 
       251 
251 
     | 
    
         
             
                      def resolve_winrm_basic_auth
         
     | 
| 
       252 
     | 
    
         
            -
                         
     | 
| 
      
 252 
     | 
    
         
            +
                        config[:winrm_authentication_protocol] == "basic"
         
     | 
| 
       253 
253 
     | 
    
         
             
                      end
         
     | 
| 
       254 
254 
     | 
    
         | 
| 
       255 
255 
     | 
    
         
             
                      def resolve_winrm_kerberos_options
         
     | 
| 
       256 
256 
     | 
    
         
             
                        kerberos_opts = {}
         
     | 
| 
       257 
     | 
    
         
            -
                        kerberos_opts[:keytab] =  
     | 
| 
       258 
     | 
    
         
            -
                        kerberos_opts[:realm] =  
     | 
| 
       259 
     | 
    
         
            -
                        kerberos_opts[:service] =  
     | 
| 
      
 257 
     | 
    
         
            +
                        kerberos_opts[:keytab] = config[:kerberos_keytab_file] if config[:kerberos_keytab_file]
         
     | 
| 
      
 258 
     | 
    
         
            +
                        kerberos_opts[:realm] = config[:kerberos_realm] if config[:kerberos_realm]
         
     | 
| 
      
 259 
     | 
    
         
            +
                        kerberos_opts[:service] = config[:kerberos_service] if config[:kerberos_service]
         
     | 
| 
       260 
260 
     | 
    
         
             
                        kerberos_opts
         
     | 
| 
       261 
261 
     | 
    
         
             
                      end
         
     | 
| 
       262 
262 
     | 
    
         | 
| 
       263 
263 
     | 
    
         
             
                      def resolve_winrm_transport
         
     | 
| 
       264 
     | 
    
         
            -
                        transport =  
     | 
| 
      
 264 
     | 
    
         
            +
                        transport = config[:winrm_transport].to_sym
         
     | 
| 
       265 
265 
     | 
    
         
             
                        if config.any? { |k, v| k.to_s =~ /kerberos/ && !v.nil? }
         
     | 
| 
       266 
266 
     | 
    
         
             
                          transport = :kerberos
         
     | 
| 
       267 
267 
     | 
    
         
             
                        elsif transport != :ssl && negotiate_auth?
         
     | 
| 
         @@ -272,11 +272,11 @@ class Chef 
     | 
|
| 
       272 
272 
     | 
    
         
             
                      end
         
     | 
| 
       273 
273 
     | 
    
         | 
| 
       274 
274 
     | 
    
         
             
                      def resolve_no_ssl_peer_verification
         
     | 
| 
       275 
     | 
    
         
            -
                         
     | 
| 
      
 275 
     | 
    
         
            +
                        config[:ca_trust_file].nil? && config[:winrm_ssl_verify_mode] == :verify_none && resolve_winrm_transport == :ssl
         
     | 
| 
       276 
276 
     | 
    
         
             
                      end
         
     | 
| 
       277 
277 
     | 
    
         | 
| 
       278 
278 
     | 
    
         
             
                      def resolve_ssl_peer_fingerprint
         
     | 
| 
       279 
     | 
    
         
            -
                         
     | 
| 
      
 279 
     | 
    
         
            +
                        config[:ssl_peer_fingerprint]
         
     | 
| 
       280 
280 
     | 
    
         
             
                      end
         
     | 
| 
       281 
281 
     | 
    
         | 
| 
       282 
282 
     | 
    
         
             
                      def resolve_winrm_disable_sspi
         
     | 
| 
         @@ -288,7 +288,7 @@ class Chef 
     | 
|
| 
       288 
288 
     | 
    
         
             
                      end
         
     | 
| 
       289 
289 
     | 
    
         | 
| 
       290 
290 
     | 
    
         
             
                      def negotiate_auth?
         
     | 
| 
       291 
     | 
    
         
            -
                         
     | 
| 
      
 291 
     | 
    
         
            +
                        config[:winrm_authentication_protocol] == "negotiate"
         
     | 
| 
       292 
292 
     | 
    
         
             
                      end
         
     | 
| 
       293 
293 
     | 
    
         | 
| 
       294 
294 
     | 
    
         
             
                      def warn_no_ssl_peer_verification
         
     | 
| 
         @@ -27,8 +27,8 @@ class Chef 
     | 
|
| 
       27 
27 
     | 
    
         
             
                  banner "knife windows cert generate FILE_PATH (options)"
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
                  deps do
         
     | 
| 
       30 
     | 
    
         
            -
                    require "openssl"
         
     | 
| 
       31 
     | 
    
         
            -
                    require "socket"
         
     | 
| 
      
 30 
     | 
    
         
            +
                    require "openssl" unless defined?(OpenSSL)
         
     | 
| 
      
 31 
     | 
    
         
            +
                    require "socket" unless defined?(Socket)
         
     | 
| 
       32 
32 
     | 
    
         
             
                  end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
                  option :hostname,
         
     | 
| 
         @@ -98,7 +98,7 @@ class Chef 
     | 
|
| 
       98 
98 
     | 
    
         
             
                    cert.add_extension(ef.create_extension("subjectKeyIdentifier", "hash", false))
         
     | 
| 
       99 
99 
     | 
    
         
             
                    cert.add_extension(ef.create_extension("authorityKeyIdentifier", "keyid:always", false))
         
     | 
| 
       100 
100 
     | 
    
         
             
                    cert.add_extension(ef.create_extension("extendedKeyUsage", "1.3.6.1.5.5.7.3.1", false))
         
     | 
| 
       101 
     | 
    
         
            -
                    cert.sign(rsa_key, OpenSSL::Digest 
     | 
| 
      
 101 
     | 
    
         
            +
                    cert.sign(rsa_key, OpenSSL::Digest.new("SHA1"))
         
     | 
| 
       102 
102 
     | 
    
         
             
                    @thumbprint = OpenSSL::Digest::SHA1.new(cert.to_der)
         
     | 
| 
       103 
103 
     | 
    
         
             
                    cert
         
     | 
| 
       104 
104 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/chef/knife/winrm.rb
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #
         
     | 
| 
       2 
2 
     | 
    
         
             
            # Author:: Seth Chisamore (<schisamo@chef.io>)
         
     | 
| 
       3 
     | 
    
         
            -
            # Copyright:: Copyright (c)  
     | 
| 
      
 3 
     | 
    
         
            +
            # Copyright:: Copyright (c) Chef Software Inc.
         
     | 
| 
       4 
4 
     | 
    
         
             
            # License:: Apache License, Version 2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
         @@ -18,14 +18,12 @@ 
     | 
|
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
            require "chef/knife"
         
     | 
| 
       20 
20 
     | 
    
         
             
            require_relative "helpers/winrm_knife_base" # WinrmCommandSharedFunctions
         
     | 
| 
       21 
     | 
    
         
            -
            require_relative "helpers/knife_windows_base"
         
     | 
| 
       22 
21 
     | 
    
         | 
| 
       23 
22 
     | 
    
         
             
            class Chef
         
     | 
| 
       24 
23 
     | 
    
         
             
              class Knife
         
     | 
| 
       25 
24 
     | 
    
         
             
                class Winrm < Knife
         
     | 
| 
       26 
25 
     | 
    
         | 
| 
       27 
26 
     | 
    
         
             
                  include Chef::Knife::WinrmCommandSharedFunctions
         
     | 
| 
       28 
     | 
    
         
            -
                  include Chef::Knife::KnifeWindowsBase
         
     | 
| 
       29 
27 
     | 
    
         | 
| 
       30 
28 
     | 
    
         
             
                  deps do
         
     | 
| 
       31 
29 
     | 
    
         
             
                    require_relative "windows_cert_generate"
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         | 
| 
       2 
2 
     | 
    
         
             
            # Author:: Adam Edwards (<adamed@chef.io>)
         
     | 
| 
       3 
     | 
    
         
            -
            # Copyright:: Copyright (c)  
     | 
| 
      
 3 
     | 
    
         
            +
            # Copyright:: Copyright (c) Chef Software Inc.
         
     | 
| 
       4 
4 
     | 
    
         
             
            # License:: Apache License, Version 2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
         @@ -22,7 +22,22 @@ def sample_data(file_name) 
     | 
|
| 
       22 
22 
     | 
    
         
             
              File.read(file)
         
     | 
| 
       23 
23 
     | 
    
         
             
            end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
      
 25 
     | 
    
         
            +
            class UnexpectedSystemExit < RuntimeError
         
     | 
| 
      
 26 
     | 
    
         
            +
              def self.from(system_exit)
         
     | 
| 
      
 27 
     | 
    
         
            +
                new(system_exit.message).tap { |e| e.set_backtrace(system_exit.backtrace) }
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
       25 
31 
     | 
    
         
             
            RSpec.configure do |config|
         
     | 
| 
      
 32 
     | 
    
         
            +
              config.raise_on_warning = true
         
     | 
| 
      
 33 
     | 
    
         
            +
              config.raise_errors_for_deprecations!
         
     | 
| 
       26 
34 
     | 
    
         
             
              config.run_all_when_everything_filtered = true
         
     | 
| 
       27 
35 
     | 
    
         
             
              config.filter_run focus: true
         
     | 
| 
      
 36 
     | 
    
         
            +
              config.around(:example) do |ex|
         
     | 
| 
      
 37 
     | 
    
         
            +
                begin
         
     | 
| 
      
 38 
     | 
    
         
            +
                  ex.run
         
     | 
| 
      
 39 
     | 
    
         
            +
                rescue SystemExit => e
         
     | 
| 
      
 40 
     | 
    
         
            +
                  raise UnexpectedSystemExit.from(e)
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
       28 
43 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #
         
     | 
| 
       2 
2 
     | 
    
         
             
            # Author:: Bryan McLellan <btm@chef.io>
         
     | 
| 
       3 
     | 
    
         
            -
            # Copyright:: Copyright (c)  
     | 
| 
      
 3 
     | 
    
         
            +
            # Copyright:: Copyright (c) Chef Software Inc.
         
     | 
| 
       4 
4 
     | 
    
         
             
            # License:: Apache License, Version 2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
         @@ -250,7 +250,7 @@ describe Chef::Knife::Winrm do 
     | 
|
| 
       250 
250 
     | 
    
         
             
                    end
         
     | 
| 
       251 
251 
     | 
    
         | 
| 
       252 
252 
     | 
    
         
             
                    it "sets the user specified winrm port" do
         
     | 
| 
       253 
     | 
    
         
            -
                       
     | 
| 
      
 253 
     | 
    
         
            +
                      winrm_command_http.config[:knife] = { winrm_port: "5988" }
         
     | 
| 
       254 
254 
     | 
    
         
             
                      expect(Chef::Knife::WinrmSession).to receive(:new).with(hash_including(transport: :plaintext)).and_call_original
         
     | 
| 
       255 
255 
     | 
    
         
             
                      expect(WinRM::Connection).to receive(:new).with(hash_including(transport: :plaintext)).and_return(winrm_connection)
         
     | 
| 
       256 
256 
     | 
    
         
             
                      winrm_command_http.configure_chef
         
     | 
| 
         @@ -269,7 +269,7 @@ describe Chef::Knife::Winrm do 
     | 
|
| 
       269 
269 
     | 
    
         
             
                    let(:winrm_command_https) { Chef::Knife::Winrm.new(["-m", "localhost", "-x", "testuser", "-P", "testpassword", "--winrm-transport", "ssl", "echo helloworld"]) }
         
     | 
| 
       270 
270 
     | 
    
         | 
| 
       271 
271 
     | 
    
         
             
                    it "uses the https uri scheme if the ssl transport is specified" do
         
     | 
| 
       272 
     | 
    
         
            -
                       
     | 
| 
      
 272 
     | 
    
         
            +
                      winrm_command_http.config[:winrm_transport] = "ssl"
         
     | 
| 
       273 
273 
     | 
    
         
             
                      expect(Chef::Knife::WinrmSession).to receive(:new).with(hash_including(transport: :ssl)).and_call_original
         
     | 
| 
       274 
274 
     | 
    
         
             
                      expect(WinRM::Connection).to receive(:new).with(hash_including(endpoint: "https://localhost:5986/wsman")).and_return(winrm_connection)
         
     | 
| 
       275 
275 
     | 
    
         
             
                      winrm_command_https.configure_chef
         
     | 
| 
         @@ -277,7 +277,7 @@ describe Chef::Knife::Winrm do 
     | 
|
| 
       277 
277 
     | 
    
         
             
                    end
         
     | 
| 
       278 
278 
     | 
    
         | 
| 
       279 
279 
     | 
    
         
             
                    it "uses the winrm port '5986' by default for ssl transport" do
         
     | 
| 
       280 
     | 
    
         
            -
                       
     | 
| 
      
 280 
     | 
    
         
            +
                      winrm_command_http.config[:winrm_transport] = "ssl"
         
     | 
| 
       281 
281 
     | 
    
         
             
                      expect(Chef::Knife::WinrmSession).to receive(:new).with(hash_including(transport: :ssl)).and_call_original
         
     | 
| 
       282 
282 
     | 
    
         
             
                      expect(WinRM::Connection).to receive(:new).with(hash_including(endpoint: "https://localhost:5986/wsman")).and_return(winrm_connection)
         
     | 
| 
       283 
283 
     | 
    
         
             
                      winrm_command_https.configure_chef
         
     | 
| 
         @@ -361,8 +361,8 @@ describe Chef::Knife::Winrm do 
     | 
|
| 
       361 
361 
     | 
    
         | 
| 
       362 
362 
     | 
    
         
             
                before(:each) do
         
     | 
| 
       363 
363 
     | 
    
         
             
                  allow(Chef::Knife::WinrmSession).to receive(:new).and_return(session)
         
     | 
| 
       364 
     | 
    
         
            -
                  Chef::Config[:knife] = { winrm_transport: "plaintext" }
         
     | 
| 
       365 
364 
     | 
    
         
             
                  @winrm = Chef::Knife::Winrm.new(["-m", "localhost", "-x", "testuser", "-P", "testpassword", "--winrm-authentication-protocol", "basic", "echo helloworld"])
         
     | 
| 
      
 365 
     | 
    
         
            +
                  @winrm.config[:winrm_transport] = "plaintext"
         
     | 
| 
       366 
366 
     | 
    
         
             
                end
         
     | 
| 
       367 
367 
     | 
    
         | 
| 
       368 
368 
     | 
    
         
             
                it "returns with 0 if the command succeeds" do
         
     | 
| 
         @@ -375,7 +375,6 @@ describe Chef::Knife::Winrm do 
     | 
|
| 
       375 
375 
     | 
    
         
             
                  command_status = 510
         
     | 
| 
       376 
376 
     | 
    
         | 
| 
       377 
377 
     | 
    
         
             
                  @winrm.config[:returns] = "0"
         
     | 
| 
       378 
     | 
    
         
            -
                  Chef::Config[:knife][:returns] = [0]
         
     | 
| 
       379 
378 
     | 
    
         | 
| 
       380 
379 
     | 
    
         
             
                  allow(@winrm).to receive(:relay_winrm_command)
         
     | 
| 
       381 
380 
     | 
    
         
             
                  allow(@winrm.ui).to receive(:error)
         
     | 
| 
         @@ -386,7 +385,6 @@ describe Chef::Knife::Winrm do 
     | 
|
| 
       386 
385 
     | 
    
         
             
                it "exits with non-zero status if the command fails and returns config is set to 0" do
         
     | 
| 
       387 
386 
     | 
    
         
             
                  command_status = 1
         
     | 
| 
       388 
387 
     | 
    
         
             
                  @winrm.config[:returns] = "0,53"
         
     | 
| 
       389 
     | 
    
         
            -
                  Chef::Config[:knife][:returns] = [0, 53]
         
     | 
| 
       390 
388 
     | 
    
         
             
                  allow(@winrm).to receive(:relay_winrm_command).and_return(command_status)
         
     | 
| 
       391 
389 
     | 
    
         
             
                  allow(@winrm.ui).to receive(:error)
         
     | 
| 
       392 
390 
     | 
    
         
             
                  allow(session).to receive(:exit_code).and_return(command_status)
         
     | 
| 
         @@ -395,7 +393,7 @@ describe Chef::Knife::Winrm do 
     | 
|
| 
       395 
393 
     | 
    
         | 
| 
       396 
394 
     | 
    
         
             
                it "exits with a zero status if the command returns an expected non-zero status" do
         
     | 
| 
       397 
395 
     | 
    
         
             
                  command_status = 53
         
     | 
| 
       398 
     | 
    
         
            -
                   
     | 
| 
      
 396 
     | 
    
         
            +
                  @winrm.config[:returns] = "0,53"
         
     | 
| 
       399 
397 
     | 
    
         
             
                  allow(@winrm).to receive(:relay_winrm_command).and_return(command_status)
         
     | 
| 
       400 
398 
     | 
    
         
             
                  allow(session).to receive(:exit_codes).and_return({ "thishost" => command_status })
         
     | 
| 
       401 
399 
     | 
    
         
             
                  exit_code = @winrm.run
         
     | 
| 
         @@ -448,7 +446,7 @@ describe Chef::Knife::Winrm do 
     | 
|
| 
       448 
446 
     | 
    
         | 
| 
       449 
447 
     | 
    
         
             
                context "when winrm_authentication_protocol specified" do
         
     | 
| 
       450 
448 
     | 
    
         
             
                  before do
         
     | 
| 
       451 
     | 
    
         
            -
                     
     | 
| 
      
 449 
     | 
    
         
            +
                    @winrm.config[:winrm_transport] = "plaintext"
         
     | 
| 
       452 
450 
     | 
    
         
             
                    allow(@winrm).to receive(:relay_winrm_command).and_return(0)
         
     | 
| 
       453 
451 
     | 
    
         
             
                  end
         
     | 
| 
       454 
452 
     | 
    
         |