From 4a78188541027d74b44a912e9483755dcc9fd35c Mon Sep 17 00:00:00 2001 From: Luis Fernandez Alvarez Date: Wed, 3 Jun 2015 12:07:31 +0200 Subject: [PATCH] (MODULES-2094) Extend regexp to remove parenthesis on safe names (MODULES-2094) Adds acceptance tests for special characters --- manifests/fragment.pp | 2 +- manifests/init.pp | 2 +- spec/acceptance/concat_spec.rb | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 9cfae6613..0c64acefb 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -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, diff --git a/manifests/init.pp b/manifests/init.pp index 46d4896d1..e481fc098 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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 { diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index c281954b7..fd130fed1 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -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