2012-03-07 20:52:30 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-06-01 13:21:59 +02:00
|
|
|
describe 'validate_absolute_path' do
|
|
|
|
describe 'signature validation' do
|
|
|
|
it { is_expected.not_to eq(nil) }
|
|
|
|
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
|
2012-08-09 23:33:10 +02:00
|
|
|
end
|
2012-03-07 20:52:30 +01:00
|
|
|
|
2015-06-01 13:21:59 +02:00
|
|
|
describe "valid paths handling" do
|
|
|
|
%w{
|
|
|
|
C:/
|
|
|
|
C:\\
|
|
|
|
C:\\WINDOWS\\System32
|
|
|
|
C:/windows/system32
|
|
|
|
X:/foo/bar
|
|
|
|
X:\\foo\\bar
|
|
|
|
\\\\host\\windows
|
|
|
|
//host/windows
|
|
|
|
/
|
|
|
|
/var/tmp
|
|
|
|
/var/opt/../lib/puppet
|
|
|
|
}.each do |path|
|
|
|
|
it { is_expected.to run.with_params(path) }
|
|
|
|
it { is_expected.to run.with_params(['/tmp', path]) }
|
2012-03-12 23:53:02 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-06-01 13:21:59 +02:00
|
|
|
describe 'invalid path handling' do
|
|
|
|
context 'garbage inputs' do
|
2012-03-12 23:53:02 +01:00
|
|
|
[
|
2012-03-07 20:52:30 +01:00
|
|
|
nil,
|
|
|
|
[ nil ],
|
2014-11-25 12:45:23 +01:00
|
|
|
[ nil, nil ],
|
2012-03-07 20:52:30 +01:00
|
|
|
{ 'foo' => 'bar' },
|
|
|
|
{ },
|
|
|
|
'',
|
2012-03-12 23:53:02 +01:00
|
|
|
].each do |path|
|
2015-06-01 13:21:59 +02:00
|
|
|
it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
|
|
|
|
it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
|
|
|
|
it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
|
2012-03-07 20:52:30 +01:00
|
|
|
end
|
|
|
|
end
|
2012-03-12 23:53:02 +01:00
|
|
|
|
2015-06-01 13:21:59 +02:00
|
|
|
context 'relative paths' do
|
|
|
|
%w{
|
|
|
|
relative1
|
|
|
|
.
|
|
|
|
..
|
|
|
|
./foo
|
|
|
|
../foo
|
|
|
|
etc/puppetlabs/puppet
|
|
|
|
opt/puppet/bin
|
|
|
|
relative\\windows
|
|
|
|
}.each do |path|
|
|
|
|
it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
|
|
|
|
it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
|
|
|
|
it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
|
2014-11-25 12:45:23 +01:00
|
|
|
end
|
2012-03-07 20:52:30 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-11-25 12:45:23 +01:00
|
|
|
|