Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update iis_vdir name to not require a trailing / #363

Merged
merged 1 commit into from
May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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