knife-windows 1.2.0 → 1.2.1
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/.gitignore +5 -5
 - data/.travis.yml +23 -23
 - data/CHANGELOG.md +104 -101
 - data/DOC_CHANGES.md +14 -14
 - data/Gemfile +12 -12
 - data/LICENSE +201 -201
 - data/README.md +376 -376
 - data/RELEASE_NOTES.md +34 -34
 - data/Rakefile +21 -21
 - data/appveyor.yml +42 -42
 - data/ci.gemfile +15 -15
 - data/features/knife_help.feature +20 -20
 - data/features/support/env.rb +5 -5
 - data/knife-windows.gemspec +25 -26
 - data/lib/chef/knife/bootstrap/windows-chef-client-msi.erb +247 -247
 - data/lib/chef/knife/bootstrap_windows_base.rb +415 -415
 - data/lib/chef/knife/bootstrap_windows_ssh.rb +115 -115
 - data/lib/chef/knife/bootstrap_windows_winrm.rb +95 -95
 - data/lib/chef/knife/core/windows_bootstrap_context.rb +366 -362
 - data/lib/chef/knife/knife_windows_base.rb +33 -33
 - data/lib/chef/knife/windows_cert_generate.rb +155 -155
 - data/lib/chef/knife/windows_cert_install.rb +68 -68
 - data/lib/chef/knife/windows_helper.rb +36 -36
 - data/lib/chef/knife/windows_listener_create.rb +107 -107
 - data/lib/chef/knife/winrm.rb +122 -122
 - data/lib/chef/knife/winrm_base.rb +113 -113
 - data/lib/chef/knife/winrm_knife_base.rb +298 -298
 - data/lib/chef/knife/winrm_session.rb +86 -86
 - data/lib/chef/knife/winrm_shared_options.rb +47 -47
 - data/lib/chef/knife/wsman_endpoint.rb +44 -44
 - data/lib/chef/knife/wsman_test.rb +117 -95
 - data/lib/knife-windows/path_helper.rb +234 -234
 - data/lib/knife-windows/version.rb +6 -6
 - data/spec/assets/win_template_rendered_with_bootstrap_install_command.txt +217 -217
 - data/spec/assets/win_template_rendered_with_bootstrap_install_command_on_12_5_client.txt +217 -217
 - data/spec/assets/win_template_rendered_without_bootstrap_install_command.txt +329 -329
 - data/spec/assets/win_template_rendered_without_bootstrap_install_command_on_12_5_client.txt +329 -329
 - data/spec/assets/win_template_unrendered.txt +246 -246
 - data/spec/functional/bootstrap_download_spec.rb +234 -234
 - data/spec/spec_helper.rb +93 -93
 - data/spec/unit/knife/bootstrap_options_spec.rb +154 -150
 - data/spec/unit/knife/bootstrap_template_spec.rb +92 -92
 - data/spec/unit/knife/bootstrap_windows_winrm_spec.rb +295 -295
 - data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +177 -151
 - data/spec/unit/knife/windows_cert_generate_spec.rb +90 -90
 - data/spec/unit/knife/windows_cert_install_spec.rb +51 -51
 - data/spec/unit/knife/windows_listener_create_spec.rb +76 -76
 - data/spec/unit/knife/winrm_session_spec.rb +64 -64
 - data/spec/unit/knife/winrm_spec.rb +516 -516
 - data/spec/unit/knife/wsman_test_spec.rb +201 -178
 - metadata +2 -16
 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -1,93 +1,93 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
            # Author:: Adam Edwards (<adamed@opscode.com>)
         
     | 
| 
       3 
     | 
    
         
            -
            # Copyright:: Copyright (c) 2012 Opscode, Inc.
         
     | 
| 
       4 
     | 
    
         
            -
            # License:: Apache License, Version 2.0
         
     | 
| 
       5 
     | 
    
         
            -
            #
         
     | 
| 
       6 
     | 
    
         
            -
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
       7 
     | 
    
         
            -
            # you may not use this file except in compliance with the License.
         
     | 
| 
       8 
     | 
    
         
            -
            # You may obtain a copy of the License at
         
     | 
| 
       9 
     | 
    
         
            -
            #
         
     | 
| 
       10 
     | 
    
         
            -
            #     http://www.apache.org/licenses/LICENSE-2.0
         
     | 
| 
       11 
     | 
    
         
            -
            #
         
     | 
| 
       12 
     | 
    
         
            -
            # Unless required by applicable law or agreed to in writing, software
         
     | 
| 
       13 
     | 
    
         
            -
            # distributed under the License is distributed on an "AS IS" BASIS,
         
     | 
| 
       14 
     | 
    
         
            -
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
         
     | 
| 
       15 
     | 
    
         
            -
            # implied.
         
     | 
| 
       16 
     | 
    
         
            -
            # See the License for the specific language governing permissions and
         
     | 
| 
       17 
     | 
    
         
            -
            # limitations under the License.
         
     | 
| 
       18 
     | 
    
         
            -
            #
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            def windows?
         
     | 
| 
       21 
     | 
    
         
            -
              !!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
         
     | 
| 
       22 
     | 
    
         
            -
            end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
            require_relative '../lib/chef/knife/core/windows_bootstrap_context'
         
     | 
| 
       25 
     | 
    
         
            -
            require_relative '../lib/chef/knife/bootstrap_windows_winrm'
         
     | 
| 
       26 
     | 
    
         
            -
            require_relative '../lib/chef/knife/bootstrap_windows_ssh'
         
     | 
| 
       27 
     | 
    
         
            -
            require_relative '../lib/chef/knife/wsman_test'
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
            if windows?
         
     | 
| 
       30 
     | 
    
         
            -
              require 'ruby-wmi'
         
     | 
| 
       31 
     | 
    
         
            -
            end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
            def windows2012?
         
     | 
| 
       34 
     | 
    
         
            -
              is_win2k12 = false
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
              if  windows?
         
     | 
| 
       37 
     | 
    
         
            -
                this_operating_system = WMI::Win32_OperatingSystem.find(:first)
         
     | 
| 
       38 
     | 
    
         
            -
                os_version = this_operating_system.send('Version')
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                # The operating system version is a string in the following form
         
     | 
| 
       41 
     | 
    
         
            -
                # that can be split into components based on the '.' delimiter:
         
     | 
| 
       42 
     | 
    
         
            -
                # MajorVersionNumber.MinorVersionNumber.BuildNumber
         
     | 
| 
       43 
     | 
    
         
            -
                os_version_components = os_version.split('.')
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                if os_version_components.length < 2
         
     | 
| 
       46 
     | 
    
         
            -
                  raise 'WMI returned a Windows version from Win32_OperatingSystem.Version ' +
         
     | 
| 
       47 
     | 
    
         
            -
                    'with an unexpected format. The Windows version could not be determined.'
         
     | 
| 
       48 
     | 
    
         
            -
                end
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                # Windows 6.2 is Windows Server 2012, so test the major and
         
     | 
| 
       51 
     | 
    
         
            -
                # minor version components
         
     | 
| 
       52 
     | 
    
         
            -
                is_win2k12 = os_version_components[0] == '6' && os_version_components[1] == '2'
         
     | 
| 
       53 
     | 
    
         
            -
              end
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
              is_win2k12
         
     | 
| 
       56 
     | 
    
         
            -
            end
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
            def chef_gte_12?
         
     | 
| 
       59 
     | 
    
         
            -
              Chef::VERSION.split('.').first.to_i >= 12
         
     | 
| 
       60 
     | 
    
         
            -
            end
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
            def chef_gte_12_5?
         
     | 
| 
       63 
     | 
    
         
            -
              Chef::VERSION.split('.')[0..1].join('.').to_f >= 12.5
         
     | 
| 
       64 
     | 
    
         
            -
            end
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
            def chef_gte_12_6?
         
     | 
| 
       67 
     | 
    
         
            -
              Chef::VERSION.split('.')[0..1].join('.').to_f >= 12.6
         
     | 
| 
       68 
     | 
    
         
            -
            end
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
            def chef_lt_12?
         
     | 
| 
       71 
     | 
    
         
            -
              Chef::VERSION.split('.').first.to_i < 12
         
     | 
| 
       72 
     | 
    
         
            -
            end
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
            def chef_eq_11?
         
     | 
| 
       75 
     | 
    
         
            -
              Chef::VERSION.split('.').first.to_i == 11
         
     | 
| 
       76 
     | 
    
         
            -
            end
         
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
            def sample_data(file_name)
         
     | 
| 
       79 
     | 
    
         
            -
              file =  File.expand_path(File.dirname("spec/assets/*"))+"/#{file_name}"
         
     | 
| 
       80 
     | 
    
         
            -
              File.read(file)
         
     | 
| 
       81 
     | 
    
         
            -
            end
         
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
            RSpec.configure do |config|
         
     | 
| 
       84 
     | 
    
         
            -
              config.filter_run_excluding :windows_only => true unless windows?
         
     | 
| 
       85 
     | 
    
         
            -
              config.filter_run_excluding :windows_2012_only => true unless windows2012?
         
     | 
| 
       86 
     | 
    
         
            -
              config.filter_run_excluding :chef_gte_12_only => true unless chef_gte_12?
         
     | 
| 
       87 
     | 
    
         
            -
              config.filter_run_excluding :chef_gte_12_5_only => true unless chef_gte_12_5?
         
     | 
| 
       88 
     | 
    
         
            -
              config.filter_run_excluding :chef_gte_12_6_only => true unless chef_gte_12_6?
         
     | 
| 
       89 
     | 
    
         
            -
              config.filter_run_excluding :chef_lt_12_5_only => true if chef_gte_12_5?
         
     | 
| 
       90 
     | 
    
         
            -
              config.filter_run_excluding :chef_lt_12_only => true unless chef_lt_12?
         
     | 
| 
       91 
     | 
    
         
            -
              config.filter_run_excluding :if_chef_11 => true if chef_eq_11?
         
     | 
| 
       92 
     | 
    
         
            -
            end
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            # Author:: Adam Edwards (<adamed@opscode.com>)
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Copyright:: Copyright (c) 2012 Opscode, Inc.
         
     | 
| 
      
 4 
     | 
    
         
            +
            # License:: Apache License, Version 2.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            #
         
     | 
| 
      
 6 
     | 
    
         
            +
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
      
 7 
     | 
    
         
            +
            # you may not use this file except in compliance with the License.
         
     | 
| 
      
 8 
     | 
    
         
            +
            # You may obtain a copy of the License at
         
     | 
| 
      
 9 
     | 
    
         
            +
            #
         
     | 
| 
      
 10 
     | 
    
         
            +
            #     http://www.apache.org/licenses/LICENSE-2.0
         
     | 
| 
      
 11 
     | 
    
         
            +
            #
         
     | 
| 
      
 12 
     | 
    
         
            +
            # Unless required by applicable law or agreed to in writing, software
         
     | 
| 
      
 13 
     | 
    
         
            +
            # distributed under the License is distributed on an "AS IS" BASIS,
         
     | 
| 
      
 14 
     | 
    
         
            +
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
         
     | 
| 
      
 15 
     | 
    
         
            +
            # implied.
         
     | 
| 
      
 16 
     | 
    
         
            +
            # See the License for the specific language governing permissions and
         
     | 
| 
      
 17 
     | 
    
         
            +
            # limitations under the License.
         
     | 
| 
      
 18 
     | 
    
         
            +
            #
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            def windows?
         
     | 
| 
      
 21 
     | 
    
         
            +
              !!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            require_relative '../lib/chef/knife/core/windows_bootstrap_context'
         
     | 
| 
      
 25 
     | 
    
         
            +
            require_relative '../lib/chef/knife/bootstrap_windows_winrm'
         
     | 
| 
      
 26 
     | 
    
         
            +
            require_relative '../lib/chef/knife/bootstrap_windows_ssh'
         
     | 
| 
      
 27 
     | 
    
         
            +
            require_relative '../lib/chef/knife/wsman_test'
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            if windows?
         
     | 
| 
      
 30 
     | 
    
         
            +
              require 'ruby-wmi'
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            def windows2012?
         
     | 
| 
      
 34 
     | 
    
         
            +
              is_win2k12 = false
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              if  windows?
         
     | 
| 
      
 37 
     | 
    
         
            +
                this_operating_system = WMI::Win32_OperatingSystem.find(:first)
         
     | 
| 
      
 38 
     | 
    
         
            +
                os_version = this_operating_system.send('Version')
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                # The operating system version is a string in the following form
         
     | 
| 
      
 41 
     | 
    
         
            +
                # that can be split into components based on the '.' delimiter:
         
     | 
| 
      
 42 
     | 
    
         
            +
                # MajorVersionNumber.MinorVersionNumber.BuildNumber
         
     | 
| 
      
 43 
     | 
    
         
            +
                os_version_components = os_version.split('.')
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                if os_version_components.length < 2
         
     | 
| 
      
 46 
     | 
    
         
            +
                  raise 'WMI returned a Windows version from Win32_OperatingSystem.Version ' +
         
     | 
| 
      
 47 
     | 
    
         
            +
                    'with an unexpected format. The Windows version could not be determined.'
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                # Windows 6.2 is Windows Server 2012, so test the major and
         
     | 
| 
      
 51 
     | 
    
         
            +
                # minor version components
         
     | 
| 
      
 52 
     | 
    
         
            +
                is_win2k12 = os_version_components[0] == '6' && os_version_components[1] == '2'
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              is_win2k12
         
     | 
| 
      
 56 
     | 
    
         
            +
            end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            def chef_gte_12?
         
     | 
| 
      
 59 
     | 
    
         
            +
              Chef::VERSION.split('.').first.to_i >= 12
         
     | 
| 
      
 60 
     | 
    
         
            +
            end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            def chef_gte_12_5?
         
     | 
| 
      
 63 
     | 
    
         
            +
              Chef::VERSION.split('.')[0..1].join('.').to_f >= 12.5
         
     | 
| 
      
 64 
     | 
    
         
            +
            end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            def chef_gte_12_6?
         
     | 
| 
      
 67 
     | 
    
         
            +
              Chef::VERSION.split('.')[0..1].join('.').to_f >= 12.6
         
     | 
| 
      
 68 
     | 
    
         
            +
            end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            def chef_lt_12?
         
     | 
| 
      
 71 
     | 
    
         
            +
              Chef::VERSION.split('.').first.to_i < 12
         
     | 
| 
      
 72 
     | 
    
         
            +
            end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            def chef_eq_11?
         
     | 
| 
      
 75 
     | 
    
         
            +
              Chef::VERSION.split('.').first.to_i == 11
         
     | 
| 
      
 76 
     | 
    
         
            +
            end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            def sample_data(file_name)
         
     | 
| 
      
 79 
     | 
    
         
            +
              file =  File.expand_path(File.dirname("spec/assets/*"))+"/#{file_name}"
         
     | 
| 
      
 80 
     | 
    
         
            +
              File.read(file)
         
     | 
| 
      
 81 
     | 
    
         
            +
            end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 84 
     | 
    
         
            +
              config.filter_run_excluding :windows_only => true unless windows?
         
     | 
| 
      
 85 
     | 
    
         
            +
              config.filter_run_excluding :windows_2012_only => true unless windows2012?
         
     | 
| 
      
 86 
     | 
    
         
            +
              config.filter_run_excluding :chef_gte_12_only => true unless chef_gte_12?
         
     | 
| 
      
 87 
     | 
    
         
            +
              config.filter_run_excluding :chef_gte_12_5_only => true unless chef_gte_12_5?
         
     | 
| 
      
 88 
     | 
    
         
            +
              config.filter_run_excluding :chef_gte_12_6_only => true unless chef_gte_12_6?
         
     | 
| 
      
 89 
     | 
    
         
            +
              config.filter_run_excluding :chef_lt_12_5_only => true if chef_gte_12_5?
         
     | 
| 
      
 90 
     | 
    
         
            +
              config.filter_run_excluding :chef_lt_12_only => true unless chef_lt_12?
         
     | 
| 
      
 91 
     | 
    
         
            +
              config.filter_run_excluding :if_chef_11 => true if chef_eq_11?
         
     | 
| 
      
 92 
     | 
    
         
            +
            end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
         @@ -1,150 +1,154 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #
         
     | 
| 
       2 
     | 
    
         
            -
            # Author:: Kartik Null Cating-Subramanian(<ksubramanian@chef.io>)
         
     | 
| 
       3 
     | 
    
         
            -
            # Copyright:: Copyright (c) 2015 Chef Software, Inc.
         
     | 
| 
       4 
     | 
    
         
            -
            # License:: Apache License, Version 2.0
         
     | 
| 
       5 
     | 
    
         
            -
            #
         
     | 
| 
       6 
     | 
    
         
            -
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
       7 
     | 
    
         
            -
            # you may not use this file except in compliance with the License.
         
     | 
| 
       8 
     | 
    
         
            -
            # You may obtain a copy of the License at
         
     | 
| 
       9 
     | 
    
         
            -
            #
         
     | 
| 
       10 
     | 
    
         
            -
            #     http://www.apache.org/licenses/LICENSE-2.0
         
     | 
| 
       11 
     | 
    
         
            -
            #
         
     | 
| 
       12 
     | 
    
         
            -
            # Unless required by applicable law or agreed to in writing, software
         
     | 
| 
       13 
     | 
    
         
            -
            # distributed under the License is distributed on an "AS IS" BASIS,
         
     | 
| 
       14 
     | 
    
         
            -
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         
     | 
| 
       15 
     | 
    
         
            -
            # See the License for the specific language governing permissions and
         
     | 
| 
       16 
     | 
    
         
            -
            # limitations under the License.
         
     | 
| 
       17 
     | 
    
         
            -
            #
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
            describe Chef::Knife::Bootstrap, :chef_gte_12_6_only do
         
     | 
| 
       22 
     | 
    
         
            -
              before(:all) do
         
     | 
| 
       23 
     | 
    
         
            -
                Chef::Config.reset
         
     | 
| 
       24 
     | 
    
         
            -
              end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
              let(:bootstrap) { Chef::Knife::Bootstrap.new }
         
     | 
| 
       27 
     | 
    
         
            -
              let(:win_bootstrap) { nil }
         
     | 
| 
       28 
     | 
    
         
            -
              let(:opt_map) { {} }
         
     | 
| 
       29 
     | 
    
         
            -
              let(:ref_ignore) { [] }
         
     | 
| 
       30 
     | 
    
         
            -
              let(:win_ignore) { [] }
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
              def compare_property(sym)
         
     | 
| 
       33 
     | 
    
         
            -
                win_bootstrap.options.each do |win_key, win_val|
         
     | 
| 
       34 
     | 
    
         
            -
                  unless win_ignore.include?(win_key) || opt_map.include?(win_key) then
         
     | 
| 
       35 
     | 
    
         
            -
                    actual = win_val[sym]
         
     | 
| 
       36 
     | 
    
         
            -
                    expected = bootstrap.options[win_key][sym]
         
     | 
| 
       37 
     | 
    
         
            -
                    expect(actual).to eq(expected),
         
     | 
| 
       38 
     | 
    
         
            -
                      "#{win_key} flag's #{sym} property doesn't match
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
            expected: #{expected}
         
     | 
| 
       41 
     | 
    
         
            -
                 got: #{actual}"
         
     | 
| 
       42 
     | 
    
         
            -
                  end
         
     | 
| 
       43 
     | 
    
         
            -
                end
         
     | 
| 
       44 
     | 
    
         
            -
              end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
              shared_examples 'compare_options' do
         
     | 
| 
       47 
     | 
    
         
            -
                it 'contains the option flags' do
         
     | 
| 
       48 
     | 
    
         
            -
                  opt_map.default_proc = proc { |map, key| key }
         
     | 
| 
       49 
     | 
    
         
            -
                  filtered_keys = (win_bootstrap.options.keys - win_ignore).map! { |key| opt_map[key] }
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
                  expect(filtered_keys).to match_array(bootstrap.options.keys - ref_ignore)
         
     | 
| 
       52 
     | 
    
         
            -
                end
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                it 'uses the same long-name' do
         
     | 
| 
       55 
     | 
    
         
            -
                  compare_property(:long)
         
     | 
| 
       56 
     | 
    
         
            -
                end
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                it 'uses the same short-name' do
         
     | 
| 
       59 
     | 
    
         
            -
                  compare_property(:short)
         
     | 
| 
       60 
     | 
    
         
            -
                end
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
                it 'uses the same description' do
         
     | 
| 
       63 
     | 
    
         
            -
                  compare_property(:description)
         
     | 
| 
       64 
     | 
    
         
            -
                end
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                it 'uses the same default value' do
         
     | 
| 
       67 
     | 
    
         
            -
                  compare_property(:default)
         
     | 
| 
       68 
     | 
    
         
            -
                end
         
     | 
| 
       69 
     | 
    
         
            -
              end
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
              context 'when compared to BootstrapWindowsWinrm' do
         
     | 
| 
       72 
     | 
    
         
            -
                let(:win_bootstrap) { Chef::Knife::BootstrapWindowsWinrm.new }
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
                # opt_map: Hash of symbols in windows mapping to symbols in core.  Name checks are
         
     | 
| 
       75 
     | 
    
         
            -
                #   ignored for these.
         
     | 
| 
       76 
     | 
    
         
            -
                let(:opt_map) { {
         
     | 
| 
       77 
     | 
    
         
            -
                  :msi_url => :bootstrap_url,
         
     | 
| 
       78 
     | 
    
         
            -
                  :encrypted_data_bag_secret => :secret,
         
     | 
| 
       79 
     | 
    
         
            -
                  :encrypted_data_bag_secret_file => :secret_file,
         
     | 
| 
       80 
     | 
    
         
            -
                  :winrm_user => :ssh_user,
         
     | 
| 
       81 
     | 
    
         
            -
                  :winrm_password => :ssh_password,
         
     | 
| 
       82 
     | 
    
         
            -
                  :winrm_port => :ssh_port,
         
     | 
| 
       83 
     | 
    
         
            -
                  :winrm_ssl_verify_mode => :host_key_verify,
         
     | 
| 
       84 
     | 
    
         
            -
                  :bootstrap_install_command => :bootstrap_install_command,
         
     | 
| 
       85 
     | 
    
         
            -
                }}
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
                # ref_ignore: Options in core that are not implemented here.
         
     | 
| 
       88 
     | 
    
         
            -
                let(:ref_ignore) { [
         
     | 
| 
       89 
     | 
    
         
            -
                  # These are irrelevant to WinRM.
         
     | 
| 
       90 
     | 
    
         
            -
                  :bootstrap_curl_options,
         
     | 
| 
       91 
     | 
    
         
            -
                  :bootstrap_wget_options,
         
     | 
| 
       92 
     | 
    
         
            -
                  :forward_agent,
         
     | 
| 
       93 
     | 
    
         
            -
                  :preserve_home,
         
     | 
| 
       94 
     | 
    
         
            -
                  :ssh_gateway,
         
     | 
| 
       95 
     | 
    
         
            -
                  :use_sudo,
         
     | 
| 
       96 
     | 
    
         
            -
                  :use_sudo_password,
         
     | 
| 
       97 
     | 
    
         
            -
                  :encrypt, # irrelevant during bootstrap
         
     | 
| 
       98 
     | 
    
         
            -
                  :identity_file,
         
     | 
| 
       99 
     | 
    
         
            -
                  :ssh_identity_file,
         
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
                 
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
                  : 
     | 
| 
       106 
     | 
    
         
            -
                  : 
     | 
| 
       107 
     | 
    
         
            -
                  : 
     | 
| 
       108 
     | 
    
         
            -
                  : 
     | 
| 
       109 
     | 
    
         
            -
                  : 
     | 
| 
       110 
     | 
    
         
            -
                  : 
     | 
| 
       111 
     | 
    
         
            -
                  : 
     | 
| 
       112 
     | 
    
         
            -
                  : 
     | 
| 
       113 
     | 
    
         
            -
                  : 
     | 
| 
       114 
     | 
    
         
            -
                  : 
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
                 
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
               
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
                 
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
                 
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
                  : 
     | 
| 
       129 
     | 
    
         
            -
                  : 
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
                 
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
                  : 
     | 
| 
       136 
     | 
    
         
            -
                  : 
     | 
| 
       137 
     | 
    
         
            -
                  : 
     | 
| 
       138 
     | 
    
         
            -
                  : 
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
       143 
     | 
    
         
            -
             
     | 
| 
       144 
     | 
    
         
            -
             
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            #
         
     | 
| 
      
 2 
     | 
    
         
            +
            # Author:: Kartik Null Cating-Subramanian(<ksubramanian@chef.io>)
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Copyright:: Copyright (c) 2015 Chef Software, Inc.
         
     | 
| 
      
 4 
     | 
    
         
            +
            # License:: Apache License, Version 2.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            #
         
     | 
| 
      
 6 
     | 
    
         
            +
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
      
 7 
     | 
    
         
            +
            # you may not use this file except in compliance with the License.
         
     | 
| 
      
 8 
     | 
    
         
            +
            # You may obtain a copy of the License at
         
     | 
| 
      
 9 
     | 
    
         
            +
            #
         
     | 
| 
      
 10 
     | 
    
         
            +
            #     http://www.apache.org/licenses/LICENSE-2.0
         
     | 
| 
      
 11 
     | 
    
         
            +
            #
         
     | 
| 
      
 12 
     | 
    
         
            +
            # Unless required by applicable law or agreed to in writing, software
         
     | 
| 
      
 13 
     | 
    
         
            +
            # distributed under the License is distributed on an "AS IS" BASIS,
         
     | 
| 
      
 14 
     | 
    
         
            +
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         
     | 
| 
      
 15 
     | 
    
         
            +
            # See the License for the specific language governing permissions and
         
     | 
| 
      
 16 
     | 
    
         
            +
            # limitations under the License.
         
     | 
| 
      
 17 
     | 
    
         
            +
            #
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            describe Chef::Knife::Bootstrap, :chef_gte_12_6_only do
         
     | 
| 
      
 22 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 23 
     | 
    
         
            +
                Chef::Config.reset
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              let(:bootstrap) { Chef::Knife::Bootstrap.new }
         
     | 
| 
      
 27 
     | 
    
         
            +
              let(:win_bootstrap) { nil }
         
     | 
| 
      
 28 
     | 
    
         
            +
              let(:opt_map) { {} }
         
     | 
| 
      
 29 
     | 
    
         
            +
              let(:ref_ignore) { [] }
         
     | 
| 
      
 30 
     | 
    
         
            +
              let(:win_ignore) { [] }
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              def compare_property(sym)
         
     | 
| 
      
 33 
     | 
    
         
            +
                win_bootstrap.options.each do |win_key, win_val|
         
     | 
| 
      
 34 
     | 
    
         
            +
                  unless win_ignore.include?(win_key) || opt_map.include?(win_key) then
         
     | 
| 
      
 35 
     | 
    
         
            +
                    actual = win_val[sym]
         
     | 
| 
      
 36 
     | 
    
         
            +
                    expected = bootstrap.options[win_key][sym]
         
     | 
| 
      
 37 
     | 
    
         
            +
                    expect(actual).to eq(expected),
         
     | 
| 
      
 38 
     | 
    
         
            +
                      "#{win_key} flag's #{sym} property doesn't match
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            expected: #{expected}
         
     | 
| 
      
 41 
     | 
    
         
            +
                 got: #{actual}"
         
     | 
| 
      
 42 
     | 
    
         
            +
                  end
         
     | 
| 
      
 43 
     | 
    
         
            +
                end
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              shared_examples 'compare_options' do
         
     | 
| 
      
 47 
     | 
    
         
            +
                it 'contains the option flags' do
         
     | 
| 
      
 48 
     | 
    
         
            +
                  opt_map.default_proc = proc { |map, key| key }
         
     | 
| 
      
 49 
     | 
    
         
            +
                  filtered_keys = (win_bootstrap.options.keys - win_ignore).map! { |key| opt_map[key] }
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                  expect(filtered_keys).to match_array(bootstrap.options.keys - ref_ignore)
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                it 'uses the same long-name' do
         
     | 
| 
      
 55 
     | 
    
         
            +
                  compare_property(:long)
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                it 'uses the same short-name' do
         
     | 
| 
      
 59 
     | 
    
         
            +
                  compare_property(:short)
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                it 'uses the same description' do
         
     | 
| 
      
 63 
     | 
    
         
            +
                  compare_property(:description)
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                it 'uses the same default value' do
         
     | 
| 
      
 67 
     | 
    
         
            +
                  compare_property(:default)
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
              context 'when compared to BootstrapWindowsWinrm' do
         
     | 
| 
      
 72 
     | 
    
         
            +
                let(:win_bootstrap) { Chef::Knife::BootstrapWindowsWinrm.new }
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                # opt_map: Hash of symbols in windows mapping to symbols in core.  Name checks are
         
     | 
| 
      
 75 
     | 
    
         
            +
                #   ignored for these.
         
     | 
| 
      
 76 
     | 
    
         
            +
                let(:opt_map) { {
         
     | 
| 
      
 77 
     | 
    
         
            +
                  :msi_url => :bootstrap_url,
         
     | 
| 
      
 78 
     | 
    
         
            +
                  :encrypted_data_bag_secret => :secret,
         
     | 
| 
      
 79 
     | 
    
         
            +
                  :encrypted_data_bag_secret_file => :secret_file,
         
     | 
| 
      
 80 
     | 
    
         
            +
                  :winrm_user => :ssh_user,
         
     | 
| 
      
 81 
     | 
    
         
            +
                  :winrm_password => :ssh_password,
         
     | 
| 
      
 82 
     | 
    
         
            +
                  :winrm_port => :ssh_port,
         
     | 
| 
      
 83 
     | 
    
         
            +
                  :winrm_ssl_verify_mode => :host_key_verify,
         
     | 
| 
      
 84 
     | 
    
         
            +
                  :bootstrap_install_command => :bootstrap_install_command,
         
     | 
| 
      
 85 
     | 
    
         
            +
                }}
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                # ref_ignore: Options in core that are not implemented here.
         
     | 
| 
      
 88 
     | 
    
         
            +
                let(:ref_ignore) { [
         
     | 
| 
      
 89 
     | 
    
         
            +
                  # These are irrelevant to WinRM.
         
     | 
| 
      
 90 
     | 
    
         
            +
                  :bootstrap_curl_options,
         
     | 
| 
      
 91 
     | 
    
         
            +
                  :bootstrap_wget_options,
         
     | 
| 
      
 92 
     | 
    
         
            +
                  :forward_agent,
         
     | 
| 
      
 93 
     | 
    
         
            +
                  :preserve_home,
         
     | 
| 
      
 94 
     | 
    
         
            +
                  :ssh_gateway,
         
     | 
| 
      
 95 
     | 
    
         
            +
                  :use_sudo,
         
     | 
| 
      
 96 
     | 
    
         
            +
                  :use_sudo_password,
         
     | 
| 
      
 97 
     | 
    
         
            +
                  :encrypt, # irrelevant during bootstrap
         
     | 
| 
      
 98 
     | 
    
         
            +
                  :identity_file,
         
     | 
| 
      
 99 
     | 
    
         
            +
                  :ssh_identity_file,
         
     | 
| 
      
 100 
     | 
    
         
            +
                  :fips, #until chef 12.7 is released
         
     | 
| 
      
 101 
     | 
    
         
            +
                ]}
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
                # win_ignore: Options in windows that aren't relevant to core.
         
     | 
| 
      
 104 
     | 
    
         
            +
                let(:win_ignore) { [
         
     | 
| 
      
 105 
     | 
    
         
            +
                  :attribute,
         
     | 
| 
      
 106 
     | 
    
         
            +
                  :auth_timeout,
         
     | 
| 
      
 107 
     | 
    
         
            +
                  :ca_trust_file,
         
     | 
| 
      
 108 
     | 
    
         
            +
                  :install_as_service,
         
     | 
| 
      
 109 
     | 
    
         
            +
                  :kerberos_keytab_file,
         
     | 
| 
      
 110 
     | 
    
         
            +
                  :kerberos_realm,
         
     | 
| 
      
 111 
     | 
    
         
            +
                  :kerberos_service,
         
     | 
| 
      
 112 
     | 
    
         
            +
                  :manual,
         
     | 
| 
      
 113 
     | 
    
         
            +
                  :session_timeout,
         
     | 
| 
      
 114 
     | 
    
         
            +
                  :winrm_authentication_protocol,
         
     | 
| 
      
 115 
     | 
    
         
            +
                  :winrm_transport,
         
     | 
| 
      
 116 
     | 
    
         
            +
                  :fips, #until chef 12.7 is released
         
     | 
| 
      
 117 
     | 
    
         
            +
                ] }
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
                include_examples 'compare_options'
         
     | 
| 
      
 120 
     | 
    
         
            +
              end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
              context 'when compared to BootstrapWindowsSsh' do
         
     | 
| 
      
 123 
     | 
    
         
            +
                let(:win_bootstrap) { Chef::Knife::BootstrapWindowsSsh.new }
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
                # opt_map: Hash of symbols in windows mapping to symbols in core.  Name checks are
         
     | 
| 
      
 126 
     | 
    
         
            +
                #   ignored for these.
         
     | 
| 
      
 127 
     | 
    
         
            +
                let(:opt_map) { {
         
     | 
| 
      
 128 
     | 
    
         
            +
                  :msi_url => :bootstrap_url,
         
     | 
| 
      
 129 
     | 
    
         
            +
                  :encrypted_data_bag_secret => :secret,
         
     | 
| 
      
 130 
     | 
    
         
            +
                  :encrypted_data_bag_secret_file => :secret_file,
         
     | 
| 
      
 131 
     | 
    
         
            +
                  :bootstrap_install_command => :bootstrap_install_command,
         
     | 
| 
      
 132 
     | 
    
         
            +
                }}
         
     | 
| 
      
 133 
     | 
    
         
            +
                # ref_ignore: Options in core that are not implemented here.
         
     | 
| 
      
 134 
     | 
    
         
            +
                let(:ref_ignore) { [
         
     | 
| 
      
 135 
     | 
    
         
            +
                  :bootstrap_curl_options,
         
     | 
| 
      
 136 
     | 
    
         
            +
                  :bootstrap_wget_options,
         
     | 
| 
      
 137 
     | 
    
         
            +
                  :preserve_home,
         
     | 
| 
      
 138 
     | 
    
         
            +
                  :use_sudo,
         
     | 
| 
      
 139 
     | 
    
         
            +
                  :use_sudo_password,
         
     | 
| 
      
 140 
     | 
    
         
            +
                  :encrypt, # irrelevant during bootstrap
         
     | 
| 
      
 141 
     | 
    
         
            +
                  :fips, #until chef 12.7 is released
         
     | 
| 
      
 142 
     | 
    
         
            +
                ]}
         
     | 
| 
      
 143 
     | 
    
         
            +
                # win_ignore: Options in windows that aren't relevant to core.
         
     | 
| 
      
 144 
     | 
    
         
            +
                let(:win_ignore) { [
         
     | 
| 
      
 145 
     | 
    
         
            +
                  :auth_timeout,
         
     | 
| 
      
 146 
     | 
    
         
            +
                  :install_as_service,
         
     | 
| 
      
 147 
     | 
    
         
            +
                  :host_key_verification,  # Deprecated - remove this when the flag is removed.
         
     | 
| 
      
 148 
     | 
    
         
            +
                  :fips, #until chef 12.7 is released
         
     | 
| 
      
 149 
     | 
    
         
            +
                ] }
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
                include_examples 'compare_options'
         
     | 
| 
      
 152 
     | 
    
         
            +
              end
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
            end
         
     |