From abf39269ea1709553c6089f0953a6cf8e5a30bed Mon Sep 17 00:00:00 2001 From: daveq <24652224+dave-q@users.noreply.github.com> Date: Thu, 15 Apr 2021 23:31:27 +0100 Subject: [PATCH] [GH-476] Allow specifying install method for internal windows_feature resources install resource refactored to do the feature name translation if required by just adding the helper method in the action_class. Also refactored the install resource to enable and start the W3WVC service since every other recipe in the cookbook used to call the default recipe that did that anyway starting the W3WVC is optional and defaults to false, so that the current behaviour of that resource that doesn't change for down stream users This makes a much cleaner implemenation, no helper module monkey patched into recipe, no extra resources and to all users of the cookbook there are no breaking changes just new options if desired. Added a unit test for all the mod recipes just to check they converge, I think this just gives some confidence things are breaking Spec tests for the install resource --- documentation/iis_install.md | 11 +- documentation/iis_manager.md | 12 +- libraries/windowsfeature_helper.rb | 42 ------ recipes/default.rb | 8 +- recipes/mod_application_initialization.rb | 10 +- recipes/mod_aspnet.rb | 13 +- recipes/mod_aspnet45.rb | 10 +- recipes/mod_auth_basic.rb | 9 +- recipes/mod_auth_digest.rb | 9 +- recipes/mod_auth_windows.rb | 9 +- recipes/mod_cgi.rb | 11 +- recipes/mod_compress_dynamic.rb | 11 +- recipes/mod_compress_static.rb | 11 +- recipes/mod_ftp.rb | 11 +- recipes/mod_iis6_metabase_compat.rb | 11 +- recipes/mod_isapi.rb | 11 +- recipes/mod_logging.rb | 11 +- recipes/mod_management.rb | 13 +- recipes/mod_security.rb | 11 +- recipes/mod_tracing.rb | 11 +- resources/install.rb | 44 +++++- resources/manager.rb | 7 +- spec/unit/recipes/default_spec.rb | 37 +++-- .../mod_application_initialization_spec.rb | 31 ++++ spec/unit/recipes/mod_aspnet45_spec.rb | 31 ++++ spec/unit/recipes/mod_aspnet_spec.rb | 31 ++++ spec/unit/recipes/mod_auth_anonymous_spec.rb | 31 ++++ spec/unit/recipes/mod_auth_basic_spec.rb | 31 ++++ spec/unit/recipes/mod_auth_digest_spec.rb | 31 ++++ spec/unit/recipes/mod_auth_windows_spec.rb | 31 ++++ spec/unit/recipes/mod_cgi_spec.rb | 31 ++++ .../unit/recipes/mod_compress_dynamic_spec.rb | 31 ++++ spec/unit/recipes/mod_compress_static_spec.rb | 31 ++++ spec/unit/recipes/mod_ftp_spec.rb | 31 ++++ spec/unit/recipes/mod_iis6_metabase_compat.rb | 31 ++++ spec/unit/recipes/mod_isapi_spec.rb | 31 ++++ spec/unit/recipes/mod_logging_spec.rb | 31 ++++ spec/unit/recipes/mod_management_spec.rb | 31 ++++ spec/unit/recipes/mod_security_spec.rb | 31 ++++ spec/unit/recipes/mod_tracing_spec.rb | 31 ++++ spec/unit/resources/install_spec.rb | 134 ++++++++++++++++++ 41 files changed, 823 insertions(+), 171 deletions(-) delete mode 100644 libraries/windowsfeature_helper.rb create mode 100644 spec/unit/recipes/mod_application_initialization_spec.rb create mode 100644 spec/unit/recipes/mod_aspnet45_spec.rb create mode 100644 spec/unit/recipes/mod_aspnet_spec.rb create mode 100644 spec/unit/recipes/mod_auth_anonymous_spec.rb create mode 100644 spec/unit/recipes/mod_auth_basic_spec.rb create mode 100644 spec/unit/recipes/mod_auth_digest_spec.rb create mode 100644 spec/unit/recipes/mod_auth_windows_spec.rb create mode 100644 spec/unit/recipes/mod_cgi_spec.rb create mode 100644 spec/unit/recipes/mod_compress_dynamic_spec.rb create mode 100644 spec/unit/recipes/mod_compress_static_spec.rb create mode 100644 spec/unit/recipes/mod_ftp_spec.rb create mode 100644 spec/unit/recipes/mod_iis6_metabase_compat.rb create mode 100644 spec/unit/recipes/mod_isapi_spec.rb create mode 100644 spec/unit/recipes/mod_logging_spec.rb create mode 100644 spec/unit/recipes/mod_management_spec.rb create mode 100644 spec/unit/recipes/mod_security_spec.rb create mode 100644 spec/unit/recipes/mod_tracing_spec.rb create mode 100644 spec/unit/resources/install_spec.rb diff --git a/documentation/iis_install.md b/documentation/iis_install.md index e8de376f..1d56191d 100644 --- a/documentation/iis_install.md +++ b/documentation/iis_install.md @@ -12,11 +12,12 @@ Simple resource to install the IIS feature ## Properties -| Name | Type | Required| Description | -| ----------------------- | -------- | -------- | ------------------------------------ | -| `source` | String | No | Source to install the features from. | -| `additional_components` | Array | No | Features of IIS to install | -| `install_method` | :windows_feature_dism, :windows_feature_powershell | No | install_method to be used to any windows_features resources. Default is :windows_feature_dism | +| Name | Type | Required| Description | +| ----------------------- | -------------- | -------- | ------------------------------------ | +| `source` | String | No | Source to install the features from. | +| `additional_components` | String,Array | No | Features of IIS to install | +| `install_method` | String, Symbol| No | install_method to be used to any windows_features resources. Default is :windows_feature_dism. Options are :windows_feature_dism, :windows_feature_powershell | +| `start_iis` | true, false | No | Controls whether the W3WVC service is enabled and started. Default is false ## Examples diff --git a/documentation/iis_manager.md b/documentation/iis_manager.md index 61c1eab5..014ff7a7 100644 --- a/documentation/iis_manager.md +++ b/documentation/iis_manager.md @@ -12,12 +12,12 @@ Configures the IIS Manager service ## Properties -| Name | Type | Default | Description | -| --------------------------- | ------------- | ------- | ------------------------------------ | -| `enable_remote_management` | true, false | `true` | If remote access allowed | -| `log_directory` | String | | Optional. The directory to write log files to | -| `port` | Integer | `8172` | The port the service listens on. | -| `install_method` | :windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd | `:windows_feature_dism` | Optional. install_method to be used to any windows_features resources | +| Name | Type | Default | Description | +| --------------------------- | --------------- | ------- | ------------------------------------ | +| `enable_remote_management` | true, false | `true` | If remote access allowed | +| `log_directory` | String | | Optional. The directory to write log files to | +| `port` | Integer | `8172` | The port the service listens on. | +| `install_method` | String, Symbol | `:windows_feature_dism` | Optional. install_method to be used to any windows_features resources. Valid options are :windows_feature_dism, :windows_feature_powershell | ## Examples diff --git a/libraries/windowsfeature_helper.rb b/libraries/windowsfeature_helper.rb deleted file mode 100644 index bd11d75f..00000000 --- a/libraries/windowsfeature_helper.rb +++ /dev/null @@ -1,42 +0,0 @@ -# -# Cookbook:: iis -# Library:: windowsfeature_helper -# -# Copyright:: 2017-2021, Chef Software, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -module IISCookbook - module WindowsFeatureHelper - def transform_feature_name(install_method, names) - if install_method.to_sym == :windows_feature_powershell - Array(names).map do |name| - cmd = "Get-WindowsFeature | Where-Object {$_.AdditionalInfo.InstallName -Eq '#{name}' -or $_.Name -eq '#{name}'} | Select -Expand Name" - result = powershell_out cmd - if result.stderr.empty? - next result.stdout.strip - else - Chef::Log.warn("Unable to translate feature #{name}") - Chef::Log.warn(result.stderr) - next name - end - end - else - names - end - end - end -end - -::Chef::DSL::Recipe.include(IISCookbook::WindowsFeatureHelper) diff --git a/recipes/default.rb b/recipes/default.rb index 7159261a..01af428f 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -21,10 +21,6 @@ iis_install 'install IIS' do additional_components node['iis']['components'] source node['iis']['source'] - install_method node['iis']['windows_feature_install_method']&.to_sym -end - -service 'iis' do - service_name 'W3SVC' - action [:enable, :start] + install_method node['iis']['windows_feature_install_method'] + start_iis true end diff --git a/recipes/mod_application_initialization.rb b/recipes/mod_application_initialization.rb index 7451a3d6..c390e5fa 100644 --- a/recipes/mod_application_initialization.rb +++ b/recipes/mod_application_initialization.rb @@ -18,9 +18,9 @@ # limitations under the License. # -include_recipe 'iis' -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, 'IIS-ApplicationInit') do - install_method install_method +iis_install 'install IIS, ApplicationInit' do + additional_components 'IIS-ApplicationInit' + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end diff --git a/recipes/mod_aspnet.rb b/recipes/mod_aspnet.rb index 3fd3e4d4..d7dd0b5f 100644 --- a/recipes/mod_aspnet.rb +++ b/recipes/mod_aspnet.rb @@ -18,14 +18,11 @@ # limitations under the License. # -include_recipe 'iis' include_recipe 'iis::mod_isapi' -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, %w(IIS-NetFxExtensibility IIS-ASPNET)) do - action :install - all !IISCookbook::Helper.older_than_windows2012? - source node['iis']['source'] unless node['iis']['source'].nil? - install_method install_method +iis_install 'install IIS, ASPNET' do + additional_components %w(IIS-NetFxExtensibility IIS-ASPNET) + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end diff --git a/recipes/mod_aspnet45.rb b/recipes/mod_aspnet45.rb index d6274063..b64be528 100644 --- a/recipes/mod_aspnet45.rb +++ b/recipes/mod_aspnet45.rb @@ -18,11 +18,11 @@ # limitations under the License. # -include_recipe 'iis' include_recipe 'iis::mod_isapi' -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, %w(NetFx4Extended-ASPNET45 IIS-NetFxExtensibility45 IIS-ASPNET45)) do - install_method install_method +iis_install 'install IIS, ASPNET45' do + additional_components %w(NetFx4Extended-ASPNET45 IIS-NetFxExtensibility45 IIS-ASPNET45) + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end diff --git a/recipes/mod_auth_basic.rb b/recipes/mod_auth_basic.rb index 744f293a..eed3c748 100644 --- a/recipes/mod_auth_basic.rb +++ b/recipes/mod_auth_basic.rb @@ -20,10 +20,11 @@ include_recipe 'iis' -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, 'IIS-BasicAuthentication') do - install_method install_method +iis_install 'install IIS, BasicAuth' do + additional_components 'IIS-BasicAuthentication' + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end iis_section 'unlocks basic authentication control in web.config' do diff --git a/recipes/mod_auth_digest.rb b/recipes/mod_auth_digest.rb index 6f85d059..5e95982c 100644 --- a/recipes/mod_auth_digest.rb +++ b/recipes/mod_auth_digest.rb @@ -20,10 +20,11 @@ include_recipe 'iis' -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, 'IIS-DigestAuthentication') do - install_method install_method +iis_install 'install IIS, DigestAuth' do + additional_components 'IIS-DigestAuthentication' + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end iis_section 'unlocks digest authentication control in web.config' do diff --git a/recipes/mod_auth_windows.rb b/recipes/mod_auth_windows.rb index fc18cdc7..13d489b9 100644 --- a/recipes/mod_auth_windows.rb +++ b/recipes/mod_auth_windows.rb @@ -20,10 +20,11 @@ include_recipe 'iis' -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, 'IIS-WindowsAuthentication') do - install_method install_method +iis_install 'install IIS, WindowsAuth' do + additional_components 'IIS-WindowsAuthentication' + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end iis_section 'unlocks windows authentication control in web.config' do diff --git a/recipes/mod_cgi.rb b/recipes/mod_cgi.rb index c84b7d03..9ad03336 100644 --- a/recipes/mod_cgi.rb +++ b/recipes/mod_cgi.rb @@ -18,10 +18,9 @@ # limitations under the License. # -include_recipe 'iis' - -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, 'IIS-CGI') do - install_method install_method +iis_install 'install IIS, CGI' do + additional_components 'IIS-CGI' + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end diff --git a/recipes/mod_compress_dynamic.rb b/recipes/mod_compress_dynamic.rb index 186d5c1d..440898ce 100644 --- a/recipes/mod_compress_dynamic.rb +++ b/recipes/mod_compress_dynamic.rb @@ -18,10 +18,9 @@ # limitations under the License. # -include_recipe 'iis' - -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, 'IIS-HttpCompressionDynamic') do - install_method install_method +iis_install 'install IIS, HttpCompressionDynamic' do + additional_components 'IIS-HttpCompressionDynamic' + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end diff --git a/recipes/mod_compress_static.rb b/recipes/mod_compress_static.rb index 79328ea5..9ff3e4aa 100644 --- a/recipes/mod_compress_static.rb +++ b/recipes/mod_compress_static.rb @@ -18,10 +18,9 @@ # limitations under the License. # -include_recipe 'iis' - -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, 'IIS-HttpCompressionStatic') do - install_method install_method +iis_install 'install IIS, HttpCompressionStatic' do + additional_components 'IIS-HttpCompressionStatic' + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end diff --git a/recipes/mod_ftp.rb b/recipes/mod_ftp.rb index 0546318f..d82bc895 100644 --- a/recipes/mod_ftp.rb +++ b/recipes/mod_ftp.rb @@ -18,10 +18,9 @@ # limitations under the License. # -include_recipe 'iis' - -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, %w(IIS-FTPServer IIS-FTPSvc IIS-FTPExtensibility)) do - install_method install_method +iis_install 'install IIS, FTP' do + additional_components %w(IIS-FTPServer IIS-FTPSvc IIS-FTPExtensibility) + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end diff --git a/recipes/mod_iis6_metabase_compat.rb b/recipes/mod_iis6_metabase_compat.rb index 3475ee6e..d012cb90 100644 --- a/recipes/mod_iis6_metabase_compat.rb +++ b/recipes/mod_iis6_metabase_compat.rb @@ -18,10 +18,9 @@ # limitations under the License. # -include_recipe 'iis' - -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, %w(IIS-IIS6ManagementCompatibility IIS-Metabase)) do - install_method install_method +iis_install 'install IIS, Compatability, Metabase' do + additional_components %w(IIS-IIS6ManagementCompatibility IIS-Metabase) + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end diff --git a/recipes/mod_isapi.rb b/recipes/mod_isapi.rb index 9fe60750..c3f1e609 100644 --- a/recipes/mod_isapi.rb +++ b/recipes/mod_isapi.rb @@ -18,10 +18,9 @@ # limitations under the License. # -include_recipe 'iis' - -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, %w(IIS-ISAPIFilter IIS-ISAPIExtensions)) do - install_method install_method +iis_install 'install IIS, ISAPI' do + additional_components %w(IIS-ISAPIFilter IIS-ISAPIExtensions) + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end diff --git a/recipes/mod_logging.rb b/recipes/mod_logging.rb index 3654c137..f01e589f 100644 --- a/recipes/mod_logging.rb +++ b/recipes/mod_logging.rb @@ -18,10 +18,9 @@ # limitations under the License. # -include_recipe 'iis' - -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, 'IIS-CustomLogging') do - install_method install_method +iis_install 'install IIS, CustomLogging' do + additional_components 'IIS-CustomLogging' + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end diff --git a/recipes/mod_management.rb b/recipes/mod_management.rb index d48bdadb..6abb6f8a 100644 --- a/recipes/mod_management.rb +++ b/recipes/mod_management.rb @@ -18,12 +18,9 @@ # limitations under the License. # -include_recipe 'iis' - -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, %w(IIS-ManagementConsole IIS-ManagementService)) do - action :install - all !IISCookbook::Helper.older_than_windows2012? - install_method install_method +iis_install 'install IIS, Management' do + additional_components %w(IIS-ManagementConsole IIS-ManagementService) + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end diff --git a/recipes/mod_security.rb b/recipes/mod_security.rb index 870108cd..6843a4a8 100644 --- a/recipes/mod_security.rb +++ b/recipes/mod_security.rb @@ -18,10 +18,9 @@ # limitations under the License. # -include_recipe 'iis' - -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, %w(IIS-URLAuthorization IIS-RequestFiltering IIS-IPSecurity)) do - install_method install_method +iis_install 'install IIS, Security' do + additional_components %w(IIS-URLAuthorization IIS-RequestFiltering IIS-IPSecurity) + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end diff --git a/recipes/mod_tracing.rb b/recipes/mod_tracing.rb index 4e849359..1494527e 100644 --- a/recipes/mod_tracing.rb +++ b/recipes/mod_tracing.rb @@ -18,10 +18,9 @@ # limitations under the License. # -include_recipe 'iis' - -install_method = node['iis']['windows_feature_install_method']&.to_sym - -windows_feature transform_feature_name(install_method, 'IIS-HttpTracing') do - install_method install_method +iis_install 'install IIS, Tracing' do + additional_components 'IIS-HttpTracing' + source node['iis']['source'] + install_method node['iis']['windows_feature_install_method'] + start_iis true end diff --git a/resources/install.rb b/resources/install.rb index b4d597fb..eb05b209 100644 --- a/resources/install.rb +++ b/resources/install.rb @@ -18,14 +18,26 @@ # include IISCookbook::Helper -include IISCookbook::WindowsFeatureHelper property :source, String -property :additional_components, Array, default: [] -property :install_method, Symbol, required: false, equal_to: [:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd], default: :windows_feature_dism +property :additional_components, [Array, String], + coerce: proc { |c| Array(c) }, + default: [] +property :install_method, [String, Symbol], + required: false, + coerce: proc { |i| i.to_sym }, + equal_to: [:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd], + default: :windows_feature_dism +property :start_iis, [true, false], default: false action :install do - features_to_install = transform_feature_name(new_resource.install_method, ['IIS-WebServerRole'].concat(new_resource.additional_components)) + features = ['IIS-WebServerRole'].concat(new_resource.additional_components) + + features_to_install = if new_resource.install_method == :windows_feature_powershell + powershell_feature_name(features) + else + features + end windows_feature 'Install IIS and additional components' do feature_name features_to_install @@ -34,4 +46,28 @@ source new_resource.source unless new_resource.source.nil? install_method new_resource.install_method end + + service 'iis' do + service_name 'W3SVC' + action [:enable, :start] + only_if { new_resource.start_iis } + end +end + +action_class do + def powershell_feature_name(names) + Array(names).map do |name| + # This will search for the powershell format (Name) of the feature name, by the both the install name or Name, meaning + # that it doesnt care if you pass the powershell format or dism format, it will return the powershell format + cmd = "Get-WindowsFeature | Where-Object {$_.AdditionalInfo.InstallName -Eq '#{name}' -or $_.Name -eq '#{name}'} | Select -Expand Name" + result = powershell_out cmd + if result.stderr.to_s.empty? + next result.stdout.strip + else + Chef::Log.warn("Unable to translate feature #{name}") + Chef::Log.warn(result.stderr) + next name + end + end + end end diff --git a/resources/manager.rb b/resources/manager.rb index 03e13f16..95bf34b0 100644 --- a/resources/manager.rb +++ b/resources/manager.rb @@ -22,12 +22,17 @@ property :enable_remote_management, [true, false], default: true property :log_directory, String property :port, Integer, default: 8172 -property :install_method, Symbol, required: false, equal_to: [:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd], default: :windows_feature_dism +property :install_method, [Symbol, String], + required: false, + coerce: proc { |m| m.to_sym }, + equal_to: [:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd], + default: :windows_feature_dism action :config do iis_install 'Web-Mgmt-Service' do additional_components ['IIS-ManagementService'] install_method new_resource.install_method + start_iis false end # properties stored in the registry diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index e1f24a58..42fba806 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -26,16 +26,13 @@ end.converge(described_recipe) end + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + it 'installs windows feature foobar' do expect(chef_run).to install_iis_install('install IIS').with(additional_components: ['foobar']) end - - # This does not currently get passed through correctly and needs a total rewrite to the test file - # it 'installs windows feature foobar with source' do - # chef_run.node.override['iis']['source'] = 'somesource' - # chef_run.converge(described_recipe) - # expect(chef_run).to install_iis_install('install IIS').with(source: 'somesource') - # end end context 'When all attributes are default, on an unspecified platform' do @@ -46,14 +43,6 @@ it 'converges successfully' do expect { chef_run }.to_not raise_error end - - it 'enables iis service with name W3WVC' do - expect(chef_run).to enable_service('iis').with(service_name: 'W3SVC') - end - - it 'starts iis service with name W3WVC' do - expect(chef_run).to start_service('iis').with(service_name: 'W3SVC') - end end [:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd].each do |method| @@ -69,4 +58,22 @@ end end end + + context 'When source provided, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new do |node| + node.override['iis']['source'] = 'somesource' + end.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + + it 'installs features with source' do + chef_run.node.override['iis']['source'] = 'somesource' + chef_run.converge(described_recipe) + expect(chef_run).to install_iis_install('install IIS').with(source: 'somesource') + end + end end diff --git a/spec/unit/recipes/mod_application_initialization_spec.rb b/spec/unit/recipes/mod_application_initialization_spec.rb new file mode 100644 index 00000000..33a19958 --- /dev/null +++ b/spec/unit/recipes/mod_application_initialization_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_application_initialization +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_application_initialization' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_aspnet45_spec.rb b/spec/unit/recipes/mod_aspnet45_spec.rb new file mode 100644 index 00000000..82ecde4a --- /dev/null +++ b/spec/unit/recipes/mod_aspnet45_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_aspnet45 +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_aspnet45' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_aspnet_spec.rb b/spec/unit/recipes/mod_aspnet_spec.rb new file mode 100644 index 00000000..d2c2bbcd --- /dev/null +++ b/spec/unit/recipes/mod_aspnet_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_aspnet +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_aspnet' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_auth_anonymous_spec.rb b/spec/unit/recipes/mod_auth_anonymous_spec.rb new file mode 100644 index 00000000..e4bb0264 --- /dev/null +++ b/spec/unit/recipes/mod_auth_anonymous_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_auth_anonymous +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_auth_anonymous' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_auth_basic_spec.rb b/spec/unit/recipes/mod_auth_basic_spec.rb new file mode 100644 index 00000000..20cda1b1 --- /dev/null +++ b/spec/unit/recipes/mod_auth_basic_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_auth_basic +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_auth_basic' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_auth_digest_spec.rb b/spec/unit/recipes/mod_auth_digest_spec.rb new file mode 100644 index 00000000..98b11191 --- /dev/null +++ b/spec/unit/recipes/mod_auth_digest_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_auth_digest +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_auth_digest' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_auth_windows_spec.rb b/spec/unit/recipes/mod_auth_windows_spec.rb new file mode 100644 index 00000000..4f765e6f --- /dev/null +++ b/spec/unit/recipes/mod_auth_windows_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_auth_windows +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_auth_windows' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_cgi_spec.rb b/spec/unit/recipes/mod_cgi_spec.rb new file mode 100644 index 00000000..2ad99f56 --- /dev/null +++ b/spec/unit/recipes/mod_cgi_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_cgi +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_cgi' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_compress_dynamic_spec.rb b/spec/unit/recipes/mod_compress_dynamic_spec.rb new file mode 100644 index 00000000..d934e325 --- /dev/null +++ b/spec/unit/recipes/mod_compress_dynamic_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_compress_dynamic +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_compress_dynamic' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_compress_static_spec.rb b/spec/unit/recipes/mod_compress_static_spec.rb new file mode 100644 index 00000000..85d82ac9 --- /dev/null +++ b/spec/unit/recipes/mod_compress_static_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_compress_static +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_compress_static' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_ftp_spec.rb b/spec/unit/recipes/mod_ftp_spec.rb new file mode 100644 index 00000000..36634ef5 --- /dev/null +++ b/spec/unit/recipes/mod_ftp_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_ftp +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_ftp' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_iis6_metabase_compat.rb b/spec/unit/recipes/mod_iis6_metabase_compat.rb new file mode 100644 index 00000000..1f8cd9ac --- /dev/null +++ b/spec/unit/recipes/mod_iis6_metabase_compat.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_iis6_metabase_compat +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_iis6_metabase_compat' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_isapi_spec.rb b/spec/unit/recipes/mod_isapi_spec.rb new file mode 100644 index 00000000..75f98bcb --- /dev/null +++ b/spec/unit/recipes/mod_isapi_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_isapi +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_isapi' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_logging_spec.rb b/spec/unit/recipes/mod_logging_spec.rb new file mode 100644 index 00000000..33545607 --- /dev/null +++ b/spec/unit/recipes/mod_logging_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_logging +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_logging' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_management_spec.rb b/spec/unit/recipes/mod_management_spec.rb new file mode 100644 index 00000000..61c2ef43 --- /dev/null +++ b/spec/unit/recipes/mod_management_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_management +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_management' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_security_spec.rb b/spec/unit/recipes/mod_security_spec.rb new file mode 100644 index 00000000..3e87c9f5 --- /dev/null +++ b/spec/unit/recipes/mod_security_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_tracing +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_tracing' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/recipes/mod_tracing_spec.rb b/spec/unit/recipes/mod_tracing_spec.rb new file mode 100644 index 00000000..5533579a --- /dev/null +++ b/spec/unit/recipes/mod_tracing_spec.rb @@ -0,0 +1,31 @@ +# +# Cookbook:: iis +# Spec:: mod_security +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'iis::mod_security' do + context 'when all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + end +end diff --git a/spec/unit/resources/install_spec.rb b/spec/unit/resources/install_spec.rb new file mode 100644 index 00000000..f8f289fc --- /dev/null +++ b/spec/unit/resources/install_spec.rb @@ -0,0 +1,134 @@ +# +# Cookbook:: iis +# Spec:: install +# +# Copyright:: 2015-2021, Chef Software, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'ostruct' +require 'spec_helper' + +describe 'iis_install' do + step_into :iis_install + context 'When no additional iis components provided, on an unspecified platform' do + recipe do + iis_install 'Just iis' + end + + it 'installs windows feature IIS' do + expect(chef_run).to install_windows_feature('Install IIS and additional components') + .with(feature_name: ['IIS-WebServerRole']) + .with(install_method: :windows_feature_dism) + end + end + + context 'When install_mode is powershell, on an unspecified platform' do + shell_out = OpenStruct.new + shell_out.strerr = '' + shell_out.stdout = 'WebServer' + stubs_for_provider('iis_install[Just iis powershell]') do |provider| + allow(provider).to receive_shell_out().and_return(shell_out) + end + recipe do + iis_install 'Just iis powershell' do + install_method :windows_feature_powershell + end + end + + it 'installs windows feature IIS' do + expect(chef_run).to install_windows_feature('Install IIS and additional components') + .with(feature_name: ['WebServer']) + .with(install_method: :windows_feature_powershell) + end + end + + context 'When install_mode is powershell as a string, on an unspecified platform' do + shell_out = OpenStruct.new + shell_out.strerr = '' + shell_out.stdout = 'WebServer' + stubs_for_provider('iis_install[Just iis powershell]') do |provider| + allow(provider).to receive_shell_out().and_return(shell_out) + end + recipe do + iis_install 'Just iis powershell' do + install_method 'windows_feature_powershell' + end + end + + it 'installs windows feature IIS' do + expect(chef_run).to install_windows_feature('Install IIS and additional components') + .with(feature_name: ['WebServer']) + .with(install_method: :windows_feature_powershell) + end + end + + context 'When start_iis is true' do + recipe do + iis_install 'Just iis' do + start_iis true + end + end + + it 'enables iis service with name W3WVC' do + expect(chef_run).to enable_service('iis').with(service_name: 'W3SVC') + end + + it 'starts iis service with name W3WVC' do + expect(chef_run).to start_service('iis').with(service_name: 'W3SVC') + end + end + + context 'When single additional component specified, on an unspecified platform' do + recipe do + iis_install 'IIs and Foobar' do + additional_components 'foobar' + end + end + + it 'installs iis and additional component' do + expect(chef_run).to install_windows_feature('Install IIS and additional components') + .with(feature_name: %w(IIS-WebServerRole foobar)) + end + end + + context 'When multiple additional components specified, on an unspecified platform' do + recipe do + iis_install 'IIs and Foobar' do + additional_components %w(foo bar) + end + end + + it 'installs iis and additional component' do + expect(chef_run).to install_windows_feature('Install IIS and additional components') + .with(feature_name: %w(IIS-WebServerRole foo bar)) + end + end + + context 'When source provided, on an unspecified platform' do + recipe do + iis_install 'just iis' do + source 'somesource' + end + end + + it 'converges successfully' do + expect { chef_run }.to_not raise_error + end + + it 'installs features with source' do + expect(chef_run).to install_windows_feature('Install IIS and additional components') + .with(source: 'somesource') + end + end +end