File tree Expand file tree Collapse file tree 3 files changed +101
-1
lines changed Expand file tree Collapse file tree 3 files changed +101
-1
lines changed Original file line number Diff line number Diff line change @@ -409,8 +409,40 @@ C:\\
409
409
410
410
Unacceptable input example:
411
411
412
+ # ### `Stdlib::Filesource`
413
+
414
+ Matches paths valid values for the source parameter of the puppet file type
415
+
416
+ Acceptable input example:
417
+
412
418
` ` ` 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
414
446
` ` `
415
447
416
448
# ### `Stdlib::Fqdn`
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
+ puppet://pm.example.com/modules/foo/bar.log
16
+ puppet://192.0.2.1/modules/foo/bar.log
17
+ /usr2/username/bin:/usr/local/bin:/usr/bin:.
18
+ C:/
19
+ C:\\
20
+ C:\\WINDOWS\\System32
21
+ C:/windows/system32
22
+ X:/foo/bar
23
+ X:\\foo\\bar
24
+ \\ \\host\\windows
25
+ //host/windows
26
+ /var/tmp
27
+ /var/opt/../lib/puppet
28
+ ] . each do |value |
29
+ describe value . inspect do
30
+ it { is_expected . to allow_value ( value ) }
31
+ end
32
+ end
33
+ end
34
+
35
+ describe 'invalid path handling' do
36
+ context 'garbage inputs' do
37
+ [
38
+ nil ,
39
+ [ nil ] ,
40
+ [ nil , nil ] ,
41
+ { 'foo' => 'bar' } ,
42
+ { } ,
43
+ '' ,
44
+ '*/Users//nope' ,
45
+ '\\Users/hc/wksp/stdlib' ,
46
+ 'C:noslashes' ,
47
+ '\\var\\tmp' ,
48
+ 'puppet:///foo/bar.log' ,
49
+ 'puppet:///pm.example.com/modules/foo/bar.log' ,
50
+ 'puppet://bob@pm.example.com/modules/foo/bar.log' ,
51
+ ] . each do |value |
52
+ describe value . inspect do
53
+ it { is_expected . not_to allow_value ( value ) }
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ 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:\/\/(([\w-]+\.?)+)?\/modules\/([^\/\0]+(\/)?)+$/,
8
+ ],
9
+ ]
You can’t perform that action at this time.
0 commit comments