File tree Expand file tree Collapse file tree 4 files changed +117
-1
lines changed Expand file tree Collapse file tree 4 files changed +117
-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
# ## 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 'test::filesource' , type : :class 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
+ let ( :params ) { { value : value } }
29
+ it { is_expected . to compile }
30
+ end
31
+ end
32
+ end
33
+
34
+ describe 'invalid path handling' do
35
+ context 'garbage inputs' do
36
+ [
37
+ nil ,
38
+ [ nil ] ,
39
+ [ nil , nil ] ,
40
+ { 'foo' => 'bar' } ,
41
+ { } ,
42
+ '' ,
43
+ '*/Users//nope' ,
44
+ '\\Users/hc/wksp/stdlib' ,
45
+ 'C:noslashes' ,
46
+ '\\var\\tmp' ,
47
+ 'puppet:///foo/bar.log'
48
+ ] . each do |value |
49
+ describe value . inspect do
50
+ let ( :params ) { { value : value } }
51
+ if Puppet ::Util ::Package . versioncmp ( Puppet . version , '5.0.0' ) >= 0
52
+ it do
53
+ is_expected . to compile . and_raise_error (
54
+ %r{parameter 'value' expects a Stdlib::Filesource}
55
+ )
56
+ end
57
+ else
58
+ it do
59
+ is_expected . to compile . and_raise_error (
60
+ %r{parameter 'value' expects a match for Variant}
61
+ )
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
Original file line number Diff line number Diff line change
1
+ # Class to test the Stdlib::Filesource type alias
2
+ class test::filesource (
3
+ Stdlib::Filesource $value,
4
+ ) {
5
+ notice (' Success' )
6
+ }
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