Skip to content

Commit

Permalink
Merge pull request redhat-openstack#275 from mhaskel/validate_order
Browse files Browse the repository at this point in the history
Add validation for order parameter
  • Loading branch information
hunner committed Feb 25, 2015
2 parents 2d60bcb + 2ca56da commit eb04c55
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions manifests/fragment.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
}
if !(is_string($order) or is_integer($order)) {
fail('$order is not a string or integer.')
} elsif $order =~ /[:\n\/]/ {
fail("Order cannot contain '/', ':', or '\n'.")
}
if $mode {
warning('The $mode parameter to concat::fragment is deprecated and has no effect')
Expand Down
28 changes: 28 additions & 0 deletions spec/unit/defines/concat_fragment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,34 @@
expect { should }.to raise_error(Puppet::Error, /is not a string or integer/)
end
end

context '123:456' do
let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
let(:params) {{ :order => '123:456', :target => '/etc/motd' }}

it 'should fail' do
expect { should }.to raise_error(Puppet::Error, /cannot contain/)
end
end
context '123/456' do
let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
let(:params) {{ :order => '123/456', :target => '/etc/motd' }}

it 'should fail' do
expect { should }.to raise_error(Puppet::Error, /cannot contain/)
end
end
context '123\n456' do
let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
let(:params) {{ :order => "123\n456", :target => '/etc/motd' }}

it 'should fail' do
expect { should }.to raise_error(Puppet::Error, /cannot contain/)
end
end
end # order =>

context 'more than one content source' do
Expand Down

0 comments on commit eb04c55

Please sign in to comment.