Skip to content

Commit

Permalink
(MODULES-2094) Extend regexp to remove parenthesis on safe names
Browse files Browse the repository at this point in the history
(MODULES-2094) Adds acceptance tests for special characters
  • Loading branch information
Luis Fernandez Alvarez authored and bmjen committed Jun 4, 2015
1 parent 1869563 commit 4a78188
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion manifests/fragment.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
fail("Can't use 'source' and 'content' at the same time")
}

$safe_target_name = regsubst($target, '[/:\n\s]', '_', 'GM')
$safe_target_name = regsubst($target, '[/:\n\s\(\)]', '_', 'GM')

concat_fragment { $name:
tag => $safe_target_name,
Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
warning('The $force parameter to concat is deprecated and has no effect.')
}

$safe_name = regsubst($name, '[/:\n\s]', '_', 'G')
$safe_name = regsubst($name, '[/:\n\s\(\)]', '_', 'G')
$default_warn_message = "# This file is managed by Puppet. DO NOT EDIT.\n"

case $warn {
Expand Down
32 changes: 32 additions & 0 deletions spec/acceptance/concat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,37 @@
it { should_not be_file }
end
end
context 'works when set to present with path that has special characters' do
before(:all) do
pp = <<-EOS
file { '#{basedir}':
ensure => directory,
}
EOS
apply_manifest(pp)
end
pp="
concat { 'file(a:b)':
ensure => present,
path => '#{basedir}/file(a:b)',
mode => '0644',
}
concat::fragment { '1':
target => 'file(a:b)',
content => '1',
order => '01',
}
"

it_behaves_like 'successfully_applied', pp

describe file("#{basedir}/file(a:b)") do
it { should be_file }
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
should be_mode 644
}
its(:content) { should match '1' }
end
end
end
end

0 comments on commit 4a78188

Please sign in to comment.