From 08974a449531692542b514e2188e0b3026f537e8 Mon Sep 17 00:00:00 2001 From: fdzedzy Date: Fri, 12 May 2017 14:11:34 -0400 Subject: [PATCH 01/10] Fixing pool name spaces bug Signed-off-by: fdzedzy --- resources/pool.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/pool.rb b/resources/pool.rb index efaaf526..b2e58678 100644 --- a/resources/pool.rb +++ b/resources/pool.rb @@ -86,7 +86,7 @@ load_current_value do |desired| name desired.name - cmd = shell_out("#{appcmd(node)} list apppool #{desired.name}") + cmd = shell_out("#{appcmd(node)} list apppool \"#{desired.name}\"") # APPPOOL "DefaultAppPool" (MgdVersion:v2.0,MgdMode:Integrated,state:Started) Chef::Log.debug("#{desired} list apppool command output: #{cmd.stdout}") unless cmd.stderr.empty? From b7b49753872b43f7605486d28e7b8dcb6b679e30 Mon Sep 17 00:00:00 2001 From: fdzedzy Date: Fri, 12 May 2017 14:44:15 -0400 Subject: [PATCH 02/10] setting pool test to have space in name Signed-off-by: fdzedzy --- test/cookbooks/test/recipes/pool.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cookbooks/test/recipes/pool.rb b/test/cookbooks/test/recipes/pool.rb index b9c2d4e7..551e8b81 100644 --- a/test/cookbooks/test/recipes/pool.rb +++ b/test/cookbooks/test/recipes/pool.rb @@ -29,7 +29,7 @@ action [:add, :config, :stop] end -iis_pool 'testapppool' do +iis_pool 'test apppool' do thirty_two_bit false runtime_version '4.0' pipeline_mode :Integrated From 91b2f819f72e0d8670b347d6b46b7a00a7f234cb Mon Sep 17 00:00:00 2001 From: Justin Schuhmann Date: Fri, 12 May 2017 15:41:41 -0400 Subject: [PATCH 03/10] Fix tests for iis_pool Signed-off-by: Justin Schuhmann --- test/cookbooks/test/recipes/pool.rb | 9 ++++++++- test/integration/pool/controls/pool_spec.rb | 11 ++++++++++- test/integration/pool/libraries/iis_pool.rb | 16 ++++++++-------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/test/cookbooks/test/recipes/pool.rb b/test/cookbooks/test/recipes/pool.rb index 89779880..27945c8b 100644 --- a/test/cookbooks/test/recipes/pool.rb +++ b/test/cookbooks/test/recipes/pool.rb @@ -34,7 +34,7 @@ action [:add, :config, :stop] end -iis_pool 'test apppool' do +iis_pool 'testapppool' do thirty_two_bit false runtime_version '4.0' pipeline_mode :Integrated @@ -48,3 +48,10 @@ iis_pool 'test_start' do action [:start] end + +iis_pool 'My App Pool' do + runtime_version '4.0.30319' + thirty_two_bit true + pipeline_mode :Integrated + action [:add, :config, :start] +end diff --git a/test/integration/pool/controls/pool_spec.rb b/test/integration/pool/controls/pool_spec.rb index 704dc02d..ec2f7d8e 100644 --- a/test/integration/pool/controls/pool_spec.rb +++ b/test/integration/pool/controls/pool_spec.rb @@ -26,7 +26,7 @@ it { should have_name('testapppool') } its('start_mode') { should eq 'OnDemand' } its('identity_type') { should eq 'SpecificUser' } - its('username') { should contain '\\vagrant' } + its('username') { should include('\\vagrant') } its('password') { should eq 'vagrant' } end @@ -36,3 +36,12 @@ its('managed_pipeline_mode') { should eq 'Classic' } it { should have_name('test_start') } end + +describe iis_pool('My App Pool') do + it { should exist } + it { should be_running } + it { should be_enable_32bit_app_on_win64 } + its('managed_runtime_version') { should eq 'v4.0.30319' } + its('managed_pipeline_mode') { should eq 'Integrated' } + it { should have_name('My App Pool') } +end diff --git a/test/integration/pool/libraries/iis_pool.rb b/test/integration/pool/libraries/iis_pool.rb index e06e0f40..37b4b08d 100644 --- a/test/integration/pool/libraries/iis_pool.rb +++ b/test/integration/pool/libraries/iis_pool.rb @@ -132,21 +132,21 @@ def initialize(inspec) # want to populate everything using one powershell command here and spit it out as json def iis_pool(pool_name) - command = "Import-Module WebAdministration; Get-Item IIS:\\AppPools\\#{pool_name} | Select-Object name, queueLength, autoStart, enable32BitAppOnWin64, managedRuntimeVersion, managedRuntimeLoader, enableConfigurationOverride, managedPipelineMode, passAnonymousToken, startMode, state, ItemXPath | ConvertTo-Json" + command = "Import-Module WebAdministration; Get-Item \"IIS:\\AppPools\\#{pool_name}\" | Select-Object name, queueLength, autoStart, enable32BitAppOnWin64, managedRuntimeVersion, managedRuntimeLoader, enableConfigurationOverride, managedPipelineMode, passAnonymousToken, startMode, state, ItemXPath | ConvertTo-Json" cmd = @inspec.command(command) - command_process_model = "(Get-Item IIS:\\AppPools\\#{pool_name}).processModel | Select-Object identityType, userName, password, loadUserProfile, setProfileEnvironment, logonType, manualGroupMembership, idleTimeout, idleTimeoutAction, maxProcesses, shutdownTimeLimit, startupTimeLimit, pingingEnabled, pingInterval, pingResponseTime, logEventOnProcessModel | ConvertTo-Json" + command_process_model = "(Get-Item \"IIS:\\AppPools\\#{pool_name}\").processModel | Select-Object identityType, userName, password, loadUserProfile, setProfileEnvironment, logonType, manualGroupMembership, idleTimeout, idleTimeoutAction, maxProcesses, shutdownTimeLimit, startupTimeLimit, pingingEnabled, pingInterval, pingResponseTime, logEventOnProcessModel | ConvertTo-Json" cmd_process_model = @inspec.command(command_process_model) - command_recycling = "(Get-Item IIS:\\AppPools\\#{pool_name}).recycling | Select-Object disallowOverlappingRotation, disallowRotationOnConfigChange, logEventOnRecycle | ConvertTo-Json" + command_recycling = "(Get-Item \"IIS:\\AppPools\\#{pool_name}\").recycling | Select-Object disallowOverlappingRotation, disallowRotationOnConfigChange, logEventOnRecycle | ConvertTo-Json" cmd_recycling = @inspec.command(command_recycling) - command_recycling_periodic_restart = "(Get-Item IIS:\\AppPools\\#{pool_name}).recycling.periodicRestart | Select-Object memory, privateMemory, requests, time | ConvertTo-Json" + command_recycling_periodic_restart = "(Get-Item \"IIS:\\AppPools\\#{pool_name}\").recycling.periodicRestart | Select-Object memory, privateMemory, requests, time | ConvertTo-Json" cmd_recycling_periodic_restart = @inspec.command(command_recycling_periodic_restart) - command_recycling_period_restart_schedule = "(Get-Item IIS:\\AppPools\\#{pool_name}).recycling.periodicRestart.schedule | Select-Object Collection | ConvertTo-Json" + command_recycling_period_restart_schedule = "(Get-Item \"IIS:\\AppPools\\#{pool_name}\").recycling.periodicRestart.schedule | Select-Object Collection | ConvertTo-Json" cmd_recycling_period_restart_schedule = @inspec.command(command_recycling_period_restart_schedule) - command_failing = "(Get-Item IIS:\\AppPools\\#{pool_name}).failure | Select-Object loadBalancerCapabilities, orphanWorkerProcess, orphanActionExe, orphanActionParams, rapidFailProtection, rapidFailProtectionInterval, rapidFailProtectionMaxCrashes, autoShudownExe, autoShutdownParams | ConvertTo-Json" + command_failing = "(Get-Item \"IIS:\\AppPools\\#{pool_name}\").failure | Select-Object loadBalancerCapabilities, orphanWorkerProcess, orphanActionExe, orphanActionParams, rapidFailProtection, rapidFailProtectionInterval, rapidFailProtectionMaxCrashes, autoShudownExe, autoShutdownParams | ConvertTo-Json" cmd_failing = @inspec.command(command_failing) - command_cpu = "(Get-Item IIS:\\AppPools\\#{pool_name}).cpu | Select-Object limit, action, resetInterval, smpAffinitized, smpProcessorAffinityMask, smpProcessorAffinityMask2, processorGroup, numaNodeAssignment, numaNodeAffinityMode | ConvertTo-Json" + command_cpu = "(Get-Item \"IIS:\\AppPools\\#{pool_name}\").cpu | Select-Object limit, action, resetInterval, smpAffinitized, smpProcessorAffinityMask, smpProcessorAffinityMask2, processorGroup, numaNodeAssignment, numaNodeAffinityMode | ConvertTo-Json" cmd_cpu = @inspec.command(command_cpu) - command_worker_processes = "(Get-Item IIS:\\AppPools\\#{pool_name}).workerProcesses | Select-Object Collection | ConvertTo-Json" + command_worker_processes = "(Get-Item \"IIS:\\AppPools\\#{pool_name}\").workerProcesses | Select-Object Collection | ConvertTo-Json" cmd_worker_processes = @inspec.command(command_worker_processes) begin From 4e901621c732aaabb579c5e72d13931f95c54eb9 Mon Sep 17 00:00:00 2001 From: fdzedzy Date: Mon, 15 May 2017 11:39:43 -0400 Subject: [PATCH 04/10] Refactor vdir name to site_name Signed-off-by: fdzedzy --- README.md | 2 +- resources/vdir.rb | 14 +++++++------- test/cookbooks/test/recipes/vdir.rb | 15 +++++++++++++++ test/integration/vdir/controls/vdir_spec.rb | 14 +++++++++++++- test/integration/vdir/libraries/iis_vdir.rb | 21 +++++++++++++++------ 5 files changed, 51 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 37ccb4de..d9c5878b 100644 --- a/README.md +++ b/README.md @@ -397,7 +397,7 @@ Allows easy management of IIS virtual directories (i.e. vdirs). #### Attribute Parameters -- `name`: name attribute. Specifies the value of the name attribute. This is the name of the website or site + application you are adding it to. +- `site_name`: name attribute. This is the name of the website or site + application you are adding it to. - `path`: The virtual directory path on the site. - `physical_path`: The physical path of the virtual directory on the disk. - `username`: (optional) The username required to logon to the physical_path. If set to "" will clear username and password. diff --git a/resources/vdir.rb b/resources/vdir.rb index 54df3c46..71b6632c 100644 --- a/resources/vdir.rb +++ b/resources/vdir.rb @@ -23,7 +23,7 @@ include Opscode::IIS::Helper include Opscode::IIS::Processors -property :name, String, name_property: true +property :site_name, String, name_property: true property :path, String property :physical_path, String property :username, String @@ -34,17 +34,17 @@ default_action :add load_current_value do |desired| - name application_cleanname(desired.name) + site_name application_cleanname(desired.site_name) path desired.path - cmd = shell_out("#{appcmd(node)} list vdir \"#{name.chomp('/') + path}\"") + cmd = shell_out("#{appcmd(node)} list vdir \"#{site_name.chomp('/') + path}\"") Chef::Log.debug("#{desired} list vdir command output: #{cmd.stdout}") if cmd.stderr.empty? # VDIR "Testfu Site/Content/Test" - result = cmd.stdout.match(/^VDIR\s\"#{Regexp.escape(name.chomp('/') + path)}\"/) + result = cmd.stdout.match(/^VDIR\s\"#{Regexp.escape(site_name.chomp('/') + path)}\"/) Chef::Log.debug("#{desired} current_resource match output: #{result}") unless result.nil? - cmd = shell_out("#{appcmd(node)} list vdir \"#{name.chomp('/') + path}\" /config:* /xml") + cmd = shell_out("#{appcmd(node)} list vdir \"#{site_name.chomp('/') + path}\" /config:* /xml") if cmd.stderr.empty? xml = cmd.stdout doc = Document.new(xml) @@ -63,7 +63,7 @@ action :add do if !@current_resource.physical_path converge_by "Created the VDIR - \"#{new_resource}\"" do - cmd = "#{appcmd(node)} add vdir /app.name:\"#{new_resource.name}\"" + cmd = "#{appcmd(node)} add vdir /app.name:\"#{new_resource.site_name}\"" cmd << " /path:\"#{new_resource.path}\"" cmd << " /physicalPath:\"#{windows_cleanpath(new_resource.physical_path)}\"" cmd << " /userName:\"#{new_resource.username}\"" if new_resource.username @@ -125,6 +125,6 @@ action_class.class_eval do def application_identifier - new_resource.name.chomp('/') + new_resource.path + new_resource.site_name.chomp('/') + new_resource.path end end diff --git a/test/cookbooks/test/recipes/vdir.rb b/test/cookbooks/test/recipes/vdir.rb index cc681377..fd52a421 100644 --- a/test/cookbooks/test/recipes/vdir.rb +++ b/test/cookbooks/test/recipes/vdir.rb @@ -26,6 +26,10 @@ recursive true end +directory "#{node['iis']['docroot']}\\vdir_test2" do + recursive true +end + iis_pool 'DefaultAppPool' do pipeline_mode :Classic action :add @@ -47,3 +51,14 @@ allow_sub_dir_config false action [:add, :config] end + +iis_vdir 'vdir_test2' do + site_name 'Default Web Site/' + path '/vdir_test2' + physical_path "#{node['iis']['docroot']}\\vdir_test2" + username 'vagrant' + password 'vagrant' + logon_method :ClearText + allow_sub_dir_config false + action [:add, :config] +end diff --git a/test/integration/vdir/controls/vdir_spec.rb b/test/integration/vdir/controls/vdir_spec.rb index 31441797..c77307ce 100644 --- a/test/integration/vdir/controls/vdir_spec.rb +++ b/test/integration/vdir/controls/vdir_spec.rb @@ -10,7 +10,7 @@ its ('startmode') { should eq 'Auto' } end -describe iis_vdir('Default Web Site', '/vdir_test') do +describe iis_vdir('/vdir_test', 'Default Web Site') do it { should exist } it { should have_path('/vdir_test') } it { should have_physical_path('C:\\inetpub\\wwwroot\\vdir_test') } @@ -19,3 +19,15 @@ it { should have_logon_method('ClearText') } it { should have_allow_sub_dir_config(false) } end + +describe iis_vdir('/vdir_test2', 'vdir_test2') do + it { should exist } + it { should have_site_name('Default Web Site') } + it { should have_path('/vdir_test2') } + it { should have_physical_path('C:\\inetpub\\wwwroot\\vdir_test2') } + it { should have_username('vagrant') } + it { should have_password('vagrant') } + it { should have_logon_method('ClearText') } + it { should have_allow_sub_dir_config(false) } +end + diff --git a/test/integration/vdir/libraries/iis_vdir.rb b/test/integration/vdir/libraries/iis_vdir.rb index d4fb4a04..5c74d9c5 100644 --- a/test/integration/vdir/libraries/iis_vdir.rb +++ b/test/integration/vdir/libraries/iis_vdir.rb @@ -29,9 +29,9 @@ class IisVdir < Inspec.resource(1) end " - def initialize(name, path) - @name = name + def initialize(path, site_name) @path = path + @site_name = site_name @cache = nil @vdir_provider = VdirProvider.new(inspec) @@ -40,6 +40,10 @@ def initialize(name, path) skip_resource 'The `iis_vdir` resource is not supported on your OS.' unless inspec.os.windows? end + def site_name + iis_vdir[:site_name] + end + def path iis_vdir[:path] end @@ -68,6 +72,10 @@ def exists? !iis_vdir[:path].empty? end + def has_site_name?(site_name) + iis_vdir[:site_name] == site_name + end + def has_path?(path) iis_vdir[:path] == path end @@ -93,12 +101,12 @@ def has_allow_sub_dir_config?(allow) end def to_s - "iis_vdir '#{@name}#{@path}'" + "iis_vdir '#{@site_name}#{@path}'" end def iis_vdir return @cache unless @cache.nil? - @cache = @vdir_provider.iis_vdir(@name, @path) unless @vdir_provider.nil? + @cache = @vdir_provider.iis_vdir(@site_name, @path) unless @vdir_provider.nil? end end @@ -110,8 +118,8 @@ def initialize(inspec) end # want to populate everything using one powershell command here and spit it out as json - def iis_vdir(name, path) - command = "Import-Module WebAdministration; Get-WebVirtualDirectory -Site \"#{name}\" -Name \"#{path}\" | Select-Object path, physicalPath, userName, password, logonMethod, allowSubDirConfig, PSPath, ItemXPath | ConvertTo-Json" + def iis_vdir(path, site_name) + command = "Import-Module WebAdministration; Get-WebVirtualDirectory -Site \"#{site_name}\" -Name \"#{path}\" | Select-Object path, physicalPath, userName, password, logonMethod, allowSubDirConfig, PSPath, ItemXPath | ConvertTo-Json" cmd = @inspec.command(command) begin @@ -123,6 +131,7 @@ def iis_vdir(name, path) # map our values to a hash table { + site_name: site_name, path: vdir['path'], physical_path: vdir['physicalPath'], username: vdir['userName'], From 08164b4a24463b3638bd6e987c6cd028cea47714 Mon Sep 17 00:00:00 2001 From: fdzedzy Date: Mon, 15 May 2017 13:44:48 -0400 Subject: [PATCH 05/10] Update to tests Signed-off-by: fdzedzy --- test/cookbooks/test/recipes/vdir.rb | 11 ----------- test/integration/vdir/controls/vdir_spec.rb | 12 ------------ test/integration/vdir/libraries/iis_vdir.rb | 2 +- 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/test/cookbooks/test/recipes/vdir.rb b/test/cookbooks/test/recipes/vdir.rb index fd52a421..27fc34d7 100644 --- a/test/cookbooks/test/recipes/vdir.rb +++ b/test/cookbooks/test/recipes/vdir.rb @@ -51,14 +51,3 @@ allow_sub_dir_config false action [:add, :config] end - -iis_vdir 'vdir_test2' do - site_name 'Default Web Site/' - path '/vdir_test2' - physical_path "#{node['iis']['docroot']}\\vdir_test2" - username 'vagrant' - password 'vagrant' - logon_method :ClearText - allow_sub_dir_config false - action [:add, :config] -end diff --git a/test/integration/vdir/controls/vdir_spec.rb b/test/integration/vdir/controls/vdir_spec.rb index c77307ce..3650808d 100644 --- a/test/integration/vdir/controls/vdir_spec.rb +++ b/test/integration/vdir/controls/vdir_spec.rb @@ -19,15 +19,3 @@ it { should have_logon_method('ClearText') } it { should have_allow_sub_dir_config(false) } end - -describe iis_vdir('/vdir_test2', 'vdir_test2') do - it { should exist } - it { should have_site_name('Default Web Site') } - it { should have_path('/vdir_test2') } - it { should have_physical_path('C:\\inetpub\\wwwroot\\vdir_test2') } - it { should have_username('vagrant') } - it { should have_password('vagrant') } - it { should have_logon_method('ClearText') } - it { should have_allow_sub_dir_config(false) } -end - diff --git a/test/integration/vdir/libraries/iis_vdir.rb b/test/integration/vdir/libraries/iis_vdir.rb index 5c74d9c5..52fab84e 100644 --- a/test/integration/vdir/libraries/iis_vdir.rb +++ b/test/integration/vdir/libraries/iis_vdir.rb @@ -132,7 +132,7 @@ def iis_vdir(path, site_name) # map our values to a hash table { site_name: site_name, - path: vdir['path'], + path: path, physical_path: vdir['physicalPath'], username: vdir['userName'], password: vdir['password'], From f22d8d4289e5bc2f3b560e1f0848eb3e412cfb0d Mon Sep 17 00:00:00 2001 From: fdzedzy Date: Mon, 15 May 2017 13:54:50 -0400 Subject: [PATCH 06/10] Cleaning up testing code Signed-off-by: fdzedzy --- test/cookbooks/test/recipes/vdir.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/cookbooks/test/recipes/vdir.rb b/test/cookbooks/test/recipes/vdir.rb index 27fc34d7..cc681377 100644 --- a/test/cookbooks/test/recipes/vdir.rb +++ b/test/cookbooks/test/recipes/vdir.rb @@ -26,10 +26,6 @@ recursive true end -directory "#{node['iis']['docroot']}\\vdir_test2" do - recursive true -end - iis_pool 'DefaultAppPool' do pipeline_mode :Classic action :add From 86252b3335b9c29f544355bfb7f0aae10957e6db Mon Sep 17 00:00:00 2001 From: fdzedzy Date: Mon, 15 May 2017 15:07:35 -0400 Subject: [PATCH 07/10] Fixing unit tests Signed-off-by: fdzedzy --- test/integration/vdir/libraries/iis_vdir.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/vdir/libraries/iis_vdir.rb b/test/integration/vdir/libraries/iis_vdir.rb index 52fab84e..45dbc328 100644 --- a/test/integration/vdir/libraries/iis_vdir.rb +++ b/test/integration/vdir/libraries/iis_vdir.rb @@ -106,7 +106,7 @@ def to_s def iis_vdir return @cache unless @cache.nil? - @cache = @vdir_provider.iis_vdir(@site_name, @path) unless @vdir_provider.nil? + @cache = @vdir_provider.iis_vdir(@path, @site_name) unless @vdir_provider.nil? end end From 5dea20104505b3068e29e10b0bb5f5d481b52650 Mon Sep 17 00:00:00 2001 From: fdzedzy Date: Tue, 16 May 2017 07:52:22 -0400 Subject: [PATCH 08/10] changing site_name to application_name Signed-off-by: fdzedzy --- resources/vdir.rb | 14 ++++++------- test/integration/vdir/libraries/iis_vdir.rb | 22 ++++++++++----------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/resources/vdir.rb b/resources/vdir.rb index 71b6632c..24b4b31c 100644 --- a/resources/vdir.rb +++ b/resources/vdir.rb @@ -23,7 +23,7 @@ include Opscode::IIS::Helper include Opscode::IIS::Processors -property :site_name, String, name_property: true +property :application_name, String, name_property: true property :path, String property :physical_path, String property :username, String @@ -34,17 +34,17 @@ default_action :add load_current_value do |desired| - site_name application_cleanname(desired.site_name) + application_name application_cleanname(desired.application_name) path desired.path - cmd = shell_out("#{appcmd(node)} list vdir \"#{site_name.chomp('/') + path}\"") + cmd = shell_out("#{appcmd(node)} list vdir \"#{application_name.chomp('/') + path}\"") Chef::Log.debug("#{desired} list vdir command output: #{cmd.stdout}") if cmd.stderr.empty? # VDIR "Testfu Site/Content/Test" - result = cmd.stdout.match(/^VDIR\s\"#{Regexp.escape(site_name.chomp('/') + path)}\"/) + result = cmd.stdout.match(/^VDIR\s\"#{Regexp.escape(application_name.chomp('/') + path)}\"/) Chef::Log.debug("#{desired} current_resource match output: #{result}") unless result.nil? - cmd = shell_out("#{appcmd(node)} list vdir \"#{site_name.chomp('/') + path}\" /config:* /xml") + cmd = shell_out("#{appcmd(node)} list vdir \"#{application_name.chomp('/') + path}\" /config:* /xml") if cmd.stderr.empty? xml = cmd.stdout doc = Document.new(xml) @@ -63,7 +63,7 @@ action :add do if !@current_resource.physical_path converge_by "Created the VDIR - \"#{new_resource}\"" do - cmd = "#{appcmd(node)} add vdir /app.name:\"#{new_resource.site_name}\"" + cmd = "#{appcmd(node)} add vdir /app.name:\"#{new_resource.application_name}\"" cmd << " /path:\"#{new_resource.path}\"" cmd << " /physicalPath:\"#{windows_cleanpath(new_resource.physical_path)}\"" cmd << " /userName:\"#{new_resource.username}\"" if new_resource.username @@ -125,6 +125,6 @@ action_class.class_eval do def application_identifier - new_resource.site_name.chomp('/') + new_resource.path + new_resource.application_name.chomp('/') + new_resource.path end end diff --git a/test/integration/vdir/libraries/iis_vdir.rb b/test/integration/vdir/libraries/iis_vdir.rb index 45dbc328..4a216eef 100644 --- a/test/integration/vdir/libraries/iis_vdir.rb +++ b/test/integration/vdir/libraries/iis_vdir.rb @@ -29,9 +29,9 @@ class IisVdir < Inspec.resource(1) end " - def initialize(path, site_name) + def initialize(path, application_name) @path = path - @site_name = site_name + @application_name = application_name @cache = nil @vdir_provider = VdirProvider.new(inspec) @@ -40,8 +40,8 @@ def initialize(path, site_name) skip_resource 'The `iis_vdir` resource is not supported on your OS.' unless inspec.os.windows? end - def site_name - iis_vdir[:site_name] + def application_name + iis_vdir[:application_name] end def path @@ -72,8 +72,8 @@ def exists? !iis_vdir[:path].empty? end - def has_site_name?(site_name) - iis_vdir[:site_name] == site_name + def has_application_name?(application_name) + iis_vdir[:application_name] == application_name end def has_path?(path) @@ -101,12 +101,12 @@ def has_allow_sub_dir_config?(allow) end def to_s - "iis_vdir '#{@site_name}#{@path}'" + "iis_vdir '#{@application_name}#{@path}'" end def iis_vdir return @cache unless @cache.nil? - @cache = @vdir_provider.iis_vdir(@path, @site_name) unless @vdir_provider.nil? + @cache = @vdir_provider.iis_vdir(@path, @application_name) unless @vdir_provider.nil? end end @@ -118,8 +118,8 @@ def initialize(inspec) end # want to populate everything using one powershell command here and spit it out as json - def iis_vdir(path, site_name) - command = "Import-Module WebAdministration; Get-WebVirtualDirectory -Site \"#{site_name}\" -Name \"#{path}\" | Select-Object path, physicalPath, userName, password, logonMethod, allowSubDirConfig, PSPath, ItemXPath | ConvertTo-Json" + def iis_vdir(path, application_name) + command = "Import-Module WebAdministration; Get-WebVirtualDirectory -Site \"#{application_name}\" -Name \"#{path}\" | Select-Object path, physicalPath, userName, password, logonMethod, allowSubDirConfig, PSPath, ItemXPath | ConvertTo-Json" cmd = @inspec.command(command) begin @@ -131,7 +131,7 @@ def iis_vdir(path, site_name) # map our values to a hash table { - site_name: site_name, + application_name: application_name, path: path, physical_path: vdir['physicalPath'], username: vdir['userName'], From c019cc52588346d3fdb6f5778169805424271beb Mon Sep 17 00:00:00 2001 From: fdzedzy Date: Tue, 16 May 2017 08:22:05 -0400 Subject: [PATCH 09/10] Fixing unit test Signed-off-by: fdzedzy --- test/cookbooks/test/recipes/vdir.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cookbooks/test/recipes/vdir.rb b/test/cookbooks/test/recipes/vdir.rb index 2d37de2f..ecfd397e 100644 --- a/test/cookbooks/test/recipes/vdir.rb +++ b/test/cookbooks/test/recipes/vdir.rb @@ -53,7 +53,7 @@ end iis_vdir 'Creating vDir /foo for Sitename' do - name 'Default Web Site' + application_name 'Default Web Site' path '/foo' physical_path "#{node['iis']['docroot']}\\foo" action [:add, :config] From 70674d85194a75e1272bac345bac05c6075e59ce Mon Sep 17 00:00:00 2001 From: fdzedzy Date: Tue, 16 May 2017 08:49:43 -0400 Subject: [PATCH 10/10] Switching order of properties in spec to pass unit tests Signed-off-by: fdzedzy --- test/integration/vdir/controls/vdir_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/vdir/controls/vdir_spec.rb b/test/integration/vdir/controls/vdir_spec.rb index 02116398..58be7f26 100644 --- a/test/integration/vdir/controls/vdir_spec.rb +++ b/test/integration/vdir/controls/vdir_spec.rb @@ -20,7 +20,7 @@ it { should have_allow_sub_dir_config(false) } end -describe iis_vdir('Default Web Site', '/foo') do +describe iis_vdir('/foo', 'Default Web Site') do it { should exist } it { should have_path('/foo') } it { should have_physical_path('C:\\inetpub\\wwwroot\\foo') }