Skip to content

Commit 4a78188

Browse files
luisfdezbmjen
authored andcommitted
(MODULES-2094) Extend regexp to remove parenthesis on safe names
(MODULES-2094) Adds acceptance tests for special characters
1 parent 1869563 commit 4a78188

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

manifests/fragment.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
fail("Can't use 'source' and 'content' at the same time")
4545
}
4646

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

4949
concat_fragment { $name:
5050
tag => $safe_target_name,

manifests/init.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
warning('The $force parameter to concat is deprecated and has no effect.')
7777
}
7878

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

8282
case $warn {

spec/acceptance/concat_spec.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,37 @@
149149
it { should_not be_file }
150150
end
151151
end
152+
context 'works when set to present with path that has special characters' do
153+
before(:all) do
154+
pp = <<-EOS
155+
file { '#{basedir}':
156+
ensure => directory,
157+
}
158+
EOS
159+
apply_manifest(pp)
160+
end
161+
pp="
162+
concat { 'file(a:b)':
163+
ensure => present,
164+
path => '#{basedir}/file(a:b)',
165+
mode => '0644',
166+
}
167+
concat::fragment { '1':
168+
target => 'file(a:b)',
169+
content => '1',
170+
order => '01',
171+
}
172+
"
173+
174+
it_behaves_like 'successfully_applied', pp
175+
176+
describe file("#{basedir}/file(a:b)") do
177+
it { should be_file }
178+
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
179+
should be_mode 644
180+
}
181+
its(:content) { should match '1' }
182+
end
183+
end
152184
end
153185
end

0 commit comments

Comments
 (0)