Skip to content

Commit

Permalink
Update iis_vdir name to not require a trailing / (#363)
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Schuhmann <jmschu02@gmail.com>
  • Loading branch information
EasyAsABC123 authored May 16, 2017
1 parent 516d052 commit 3037029
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
10 changes: 7 additions & 3 deletions resources/vdir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
11 changes: 11 additions & 0 deletions test/cookbooks/test/recipes/vdir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
6 changes: 6 additions & 0 deletions test/integration/vdir/controls/vdir_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3037029

Please sign in to comment.