-
Notifications
You must be signed in to change notification settings - Fork 579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Stdlib::Filesource #841
Changes from all commits
41247cc
dd28f77
608d27b
3f7a243
f852ba3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
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 | ||
puppet://pm.example.com/modules/foo/bar.log | ||
puppet://192.0.2.1/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', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @binford2k This is actually valid though? https://puppet.com/docs/puppet/5.5/file_serving.html#whats-a-mount-point-in-a-puppet-uri There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that should be valid. |
||
'puppet:///pm.example.com/modules/foo/bar.log', | ||
'puppet://[email protected]/modules/foo/bar.log', | ||
].each do |value| | ||
describe value.inspect do | ||
it { is_expected.not_to allow_value(value) } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
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:\/\/(([\w-]+\.?)+)?\/modules\/([^\/\0]+(\/)?)+$/, | ||
], | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also test
puppet://someserver/modules/foo/bar.log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@binford2k thanks for the pointer i didn't see that varient in the docs. Have updeated the type pattern and spec tests