File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -409,8 +409,40 @@ C:\\
409409
410410Unacceptable input example:
411411
412+ # ### `Stdlib::Filesource`
413+
414+ Matches paths valid values for the source parameter of the puppet file type
415+
416+ Acceptable input example:
417+
412418` ` ` shell
413- /usr2/username/bin:/usr/local/bin:/usr/bin:.
419+ http://example.com
420+
421+ https://example.com
422+
423+ file:///hello/bla
424+
425+ /usr2/username/bin
426+
427+ C:\f oo\b ar
428+
429+ /var/opt/../lib/puppet
430+
431+ puppet:///modules/foo/bar.log
432+ ` ` `
433+
434+ Unacceptable input example:
435+
436+ ` ` ` shell
437+ * /Users//nope
438+
439+ \U sers/hc/wksp/stdlib
440+
441+ C:noslashes
442+
443+ puppet:///foo/bar.log
444+
445+ ftp://ftp.example.com
414446` ` `
415447
416448# ## Facts
Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ if Puppet ::Util ::Package . versioncmp ( Puppet . version , '4.5.0' ) >= 0
4+ describe 'Stdlib::Filesource' do
5+ describe 'valid handling' do
6+ %w[
7+ https://hello.com
8+ https://notcreative.org
9+ https://canstillaccepthttps.co.uk
10+ http://anhttp.com
11+ http://runningoutofideas.gov
12+ file:///hello/bla
13+ file:///foo/bar.log
14+ puppet:///modules/foo/bar.log
15+ /usr2/username/bin:/usr/local/bin:/usr/bin:.
16+ C:/
17+ C:\\
18+ C:\\WINDOWS\\System32
19+ C:/windows/system32
20+ X:/foo/bar
21+ X:\\foo\\bar
22+ \\ \\host\\windows
23+ //host/windows
24+ /var/tmp
25+ /var/opt/../lib/puppet
26+ ] . each do |value |
27+ describe value . inspect do
28+ it { is_expected . to allow_value ( value ) }
29+ end
30+ end
31+ end
32+
33+ describe 'invalid path handling' do
34+ context 'garbage inputs' do
35+ [
36+ nil ,
37+ [ nil ] ,
38+ [ nil , nil ] ,
39+ { 'foo' => 'bar' } ,
40+ { } ,
41+ '' ,
42+ '*/Users//nope' ,
43+ '\\Users/hc/wksp/stdlib' ,
44+ 'C:noslashes' ,
45+ '\\var\\tmp' ,
46+ 'puppet:///foo/bar.log' ,
47+ ] . each do |value |
48+ describe value . inspect do
49+ it { is_expected . not_to allow_value ( value ) }
50+ end
51+ end
52+ end
53+ end
54+ end
55+ end
Original file line number Diff line number Diff line change 1+ # Validate the source parameter on file types
2+ type Stdlib::Filesource = Variant[
3+ Stdlib::Absolutepath,
4+ Stdlib::HTTPUrl,
5+ Pattern[
6+ /^file :\/\/\/([^\/\0]+(\/)?)+$/,
7+ /^puppet:\/\/\/modules\/([^\/\0]+(\/)?)+$/,
8+ ],
9+ ]
You can’t perform that action at this time.
0 commit comments