Skip to content
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

(MODULES-8404) - Relax Stdlib::Filesource type #981

Merged
merged 1 commit into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions spec/type_aliases/filesource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,30 @@
if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
describe 'Stdlib::Filesource' do
describe 'valid handling' do
['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|
[
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh thanks for reformatting

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it creates noise, but it really was pretty hard to read as was.

'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',
'puppet:///a_custom_mount_point/foo/bar/foobar.conf',
].each do |value|
describe value.inspect do
it { is_expected.to allow_value(value) }
end
Expand All @@ -25,8 +46,6 @@
'\\Users/hc/wksp/stdlib',
'C:noslashes',
'\\var\\tmp',
'puppet:///foo/bar.log',
'puppet:///pm.example.com/modules/foo/bar.log',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first glance this might not look valid, but I can't see anything that says pm.example.com couldn't be a valid mount point. Unlikely and unusual, yes, but not technically invalid.

'puppet://bob@pm.example.com/modules/foo/bar.log',
].each do |value|
describe value.inspect do
Expand Down
2 changes: 1 addition & 1 deletion types/filesource.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
Stdlib::HTTPUrl,
Pattern[
/^file:\/\/\/([^\/\0]+(\/)?)+$/,
/^puppet:\/\/(([\w-]+\.?)+)?\/modules\/([^\/\0]+(\/)?)+$/,
/^puppet:\/\/(([\w-]+\.?)+)?\/([^\/\0]+(\/)?)+$/,
],
]