From 40f8b40f969946b29f331ec688dc4d238d574e14 Mon Sep 17 00:00:00 2001 From: Justin Schuhmann Date: Mon, 15 May 2017 23:16:09 -0400 Subject: [PATCH] Update iis_vdir name to not require a trailing / Signed-off-by: Justin Schuhmann --- resources/vdir.rb | 10 +++++++--- test/cookbooks/test/recipes/vdir.rb | 11 +++++++++++ test/integration/vdir/controls/vdir_spec.rb | 6 ++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/resources/vdir.rb b/resources/vdir.rb index 54df3c46..0971a7ca 100644 --- a/resources/vdir.rb +++ b/resources/vdir.rb @@ -34,7 +34,7 @@ default_action :add load_current_value do |desired| - name application_cleanname(desired.name) + name application_cleanname(desired.name).end_with?('/') ? application_cleanname(desired.name) : application_cleanname(desired.name) + '/' path desired.path cmd = shell_out("#{appcmd(node)} list vdir \"#{name.chomp('/') + path}\"") Chef::Log.debug("#{desired} list vdir command output: #{cmd.stdout}") @@ -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:\"#{vdir_identifier}\"" 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,10 @@ action_class.class_eval do def application_identifier - new_resource.name.chomp('/') + new_resource.path + vdir_identifier.chomp('/') + new_resource.path + end + + def vdir_identifier + new_resource.name.end_with?('/') ? new_resource.name : new_resource.name + '/' end end diff --git a/test/cookbooks/test/recipes/vdir.rb b/test/cookbooks/test/recipes/vdir.rb index cc681377..2d37de2f 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']}\\foo" do + recursive true +end + iis_pool 'DefaultAppPool' do pipeline_mode :Classic action :add @@ -47,3 +51,10 @@ allow_sub_dir_config false action [:add, :config] end + +iis_vdir 'Creating vDir /foo for Sitename' do + name 'Default Web Site' + path '/foo' + physical_path "#{node['iis']['docroot']}\\foo" + action [:add, :config] +end diff --git a/test/integration/vdir/controls/vdir_spec.rb b/test/integration/vdir/controls/vdir_spec.rb index 31441797..39f0fbeb 100644 --- a/test/integration/vdir/controls/vdir_spec.rb +++ b/test/integration/vdir/controls/vdir_spec.rb @@ -19,3 +19,9 @@ it { should have_logon_method('ClearText') } it { should have_allow_sub_dir_config(false) } end + +describe iis_vdir('Default Web Site', '/foo') do + it { should exist } + it { should have_path('/foo') } + it { should have_physical_path('C:\\inetpub\\wwwroot\\foo') } +end