-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Class to test the Stdlib::Filesource type alias | ||
class test::filesource ( | ||
Stdlib::Filesource $value, | ||
) { | ||
notice('Success') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require 'spec_helper' | ||
|
||
if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 | ||
describe 'Stdlib::Filesource' do | ||
describe 'valid handling' do | ||
%w( | ||
https://hello.com | ||
https://notcreative.org | ||
https://canstillaccepthttps.co.uk | ||
http://anhttp.com | ||
http://runningoutofideas.gov | ||
file:///hello/bla | ||
file:///foo/bar.log | ||
puppet:///modules/foo/bar.log | ||
/usr2/username/bin:/usr/local/bin:/usr/bin:. | ||
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 |value| | ||
describe value.inspect do | ||
it { is_expected.to allow_value(value) } | ||
end | ||
end | ||
end | ||
|
||
describe 'invalid path handling' do | ||
context 'garbage inputs' do | ||
[ | ||
nil, | ||
[nil], | ||
[nil, nil], | ||
{ 'foo' => 'bar' }, | ||
{}, | ||
'', | ||
'*/Users//nope', | ||
'\\Users/hc/wksp/stdlib', | ||
'C:noslashes', | ||
'\\var\\tmp', | ||
'puppet:///foo/bar.log' | ||
].each do |value| | ||
describe value.inspect do | ||
it { is_expected.not_to allow_value(value) } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Validate the source parameter on file types | ||
type Stdlib::Filesource = Variant[ | ||
Stdlib::Absolutepath, | ||
Stdlib::HTTPUrl, | ||
Pattern[ | ||
/^file:\/\/\/([^\/\0]+(\/)?)+$/, | ||
/^puppet:\/\/\/modules\/([^\/\0]+(\/)?)+$/, | ||
], | ||
] |