File tree Expand file tree Collapse file tree 7 files changed +161
-0
lines changed Expand file tree Collapse file tree 7 files changed +161
-0
lines changed Original file line number Diff line number Diff line change @@ -413,6 +413,58 @@ Unacceptable input example:
413
413
/usr2/username/bin:/usr/local/bin:/usr/bin:.
414
414
` ` `
415
415
416
+ # ### `Stdlib::Fqdn`
417
+
418
+ Matches paths on fully quallified domain name
419
+
420
+ Acceptable input example:
421
+
422
+ ` ` ` shell
423
+ localhost
424
+
425
+ example.com
426
+
427
+ www.example.com
428
+ ` ` `
429
+
430
+ Unacceptable input example:
431
+
432
+ ` ` ` shell
433
+ ' www www.example.com'
434
+
435
+ 2001:DB8::1
436
+ ` ` `
437
+
438
+ # ### `Stdlib::Host`
439
+
440
+ Matches a valid host which could be a valid ipv4, ipv6 or fqdn
441
+
442
+ Acceptable input example:
443
+
444
+ ` ` ` shell
445
+ localhost
446
+
447
+ example.com
448
+
449
+ www.example.com
450
+
451
+ 2001:0db8::1
452
+
453
+ 192.0.2.1
454
+ ` ` `
455
+
456
+ Unacceptable input example:
457
+
458
+ ` ` ` shell
459
+ ' www www.example.com'
460
+
461
+ 2001:0d8
462
+
463
+ %.example.com
464
+
465
+ bob@example.com
466
+ ` ` `
467
+
416
468
# ## Facts
417
469
418
470
# ### `package_provider`
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::fqdn' , type : :class do
5
+ describe 'valid handling' do
6
+ %w(
7
+ example
8
+ example.com
9
+ www.example.com
10
+ ) . each do |value |
11
+ describe value . inspect do
12
+ let ( :params ) { { value : value } }
13
+ it { is_expected . to compile }
14
+ end
15
+ end
16
+ end
17
+
18
+ describe 'invalid path handling' do
19
+ context 'garbage inputs' do
20
+ [
21
+ [ nil ] ,
22
+ [ nil , nil ] ,
23
+ { 'foo' => 'bar' } ,
24
+ { } ,
25
+ '' ,
26
+ '2001:DB8::1' ,
27
+ 'www www.example.com'
28
+ ] . each do |value |
29
+ describe value . inspect do
30
+ let ( :params ) { { value : value } }
31
+ it { is_expected . to compile . and_raise_error ( %r{parameter 'value' expects a match for Stdlib::Fqdn} ) }
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
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::host' , type : :class do
5
+ describe 'valid handling' do
6
+ %w(
7
+ example
8
+ example.com
9
+ www.example.com
10
+ 2001:0db8:85a3:0000:0000:8a2e:0370:7334
11
+ fa76:8765:34ac:0823:ab76:eee9:0987:1111
12
+ 2001:0db8::1
13
+ 224.0.0.0
14
+ 255.255.255.255
15
+ 0.0.0.0
16
+ 192.88.99.0
17
+ ) . each do |value |
18
+ describe value . inspect do
19
+ let ( :params ) { { value : value } }
20
+ it { is_expected . to compile }
21
+ end
22
+ end
23
+ end
24
+
25
+ describe 'invalid handling' do
26
+ context 'garbage inputs' do
27
+ [
28
+ [ nil ] ,
29
+ [ nil , nil ] ,
30
+ { 'foo' => 'bar' } ,
31
+ { } ,
32
+ '' ,
33
+ 'www www.example.com' ,
34
+ 'bob@example.com' ,
35
+ '%.example.com' ,
36
+ '2001:0d8'
37
+ ] . each do |value |
38
+ describe value . inspect do
39
+ let ( :params ) { { value : value } }
40
+ if Puppet ::Util ::Package . versioncmp ( Puppet . version , '5.0.0' ) >= 0
41
+ it do
42
+ is_expected . to compile . and_raise_error (
43
+ %r{parameter 'value' expects a Stdlib::Host}
44
+ )
45
+ end
46
+ else
47
+ it do
48
+ is_expected . to compile . and_raise_error (
49
+ %r{parameter 'value' expects a match for Variant}
50
+ )
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
Original file line number Diff line number Diff line change
1
+ # Class to test the Stdlib::Fqdn type alias
2
+ class test::fqdn (
3
+ Stdlib::Fqdn $value,
4
+ ) {
5
+ notice (' Success' )
6
+ }
Original file line number Diff line number Diff line change
1
+ # Class to test the Stdlib::Host type alias
2
+ class test::host (
3
+ Stdlib::Host $value,
4
+ ) {
5
+ notice (' Success' )
6
+ }
Original file line number Diff line number Diff line change
1
+ type Stdlib::Fqdn = Pattern[/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/]
Original file line number Diff line number Diff line change
1
+ type Stdlib::Host = Variant[Stdlib::Fqdn, Stdlib::Compat::Ip_address]
You can’t perform that action at this time.
0 commit comments