File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -413,6 +413,90 @@ Unacceptable input example:
413413/usr2/username/bin:/usr/local/bin:/usr/bin:.
414414` ` `
415415
416+ # ### `Stdlib::Port`
417+
418+ Matches a valid TCP/UDP Port number
419+
420+ Acceptable input examples:
421+
422+ ` ` ` shell
423+ 80
424+
425+ 443
426+
427+ 1337
428+
429+ 65000
430+ ` ` `
431+
432+ Unacceptable input example:
433+
434+ ` ` ` shell
435+ -1
436+
437+ 65536
438+
439+ ' 443'
440+
441+ ' https'
442+ ` ` ` `
443+
444+ # ### `Stdlib::Privilegedport`
445+
446+ Matches a valid TCP/UDP Pivlaged port i.e. < 1024
447+
448+ Acceptable input examples:
449+
450+ ` ` ` shell
451+ 80
452+
453+ 443
454+
455+ 1023
456+ ```
457+
458+ Unacceptable input example:
459+
460+ ``` shell
461+ -1
462+
463+ 1337
464+
465+ ' 443'
466+
467+ ' https'
468+ ```
469+
470+ #### ` Stdlib::Unprivilegedport `
471+
472+ Matches a valid TCP/UDP Pivlaged port i.e. >= 1024
473+
474+ Acceptable input examples:
475+
476+ ``` shell
477+ 1024
478+
479+ 1337
480+
481+ 65000
482+ ```
483+
484+ Unacceptable input example:
485+
486+ ``` shell
487+ -1
488+
489+ 80
490+
491+ 443
492+
493+ 1023
494+
495+ ' 443'
496+
497+ ' https'
498+ ```
499+
416500### Facts
417501
418502#### ` 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::port' , type : :class do
5+ describe 'valid ports' do
6+ [
7+ 80 ,
8+ 443 ,
9+ 1337 ,
10+ 65000
11+ ] . each do |value |
12+ describe value . inspect do
13+ let ( :params ) { { value : value } }
14+ it { is_expected . to compile }
15+ end
16+ end
17+ end
18+
19+ describe 'invalid path handling' do
20+ context 'garbage inputs' do
21+ [
22+ nil ,
23+ [ nil ] ,
24+ [ nil , nil ] ,
25+ { 'foo' => 'bar' } ,
26+ { } ,
27+ '' ,
28+ 'https' ,
29+ '443' ,
30+ -1 ,
31+ 65536
32+ ] . each do |value |
33+ describe value . inspect do
34+ let ( :params ) { { value : value } }
35+ it { is_expected . to compile . and_raise_error ( %r{parameter 'value' expects a Stdlib::Port} ) }
36+ end
37+ end
38+ end
39+ end
40+ end
41+ 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::privilegedport' , type : :class do
5+ describe 'valid ports' do
6+ [
7+ 80 ,
8+ 443 ,
9+ 1023
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 ] ,
23+ [ nil , nil ] ,
24+ { 'foo' => 'bar' } ,
25+ { } ,
26+ '' ,
27+ 'https' ,
28+ '443' ,
29+ -1 ,
30+ 1337 ,
31+ 1024
32+ ] . each do |value |
33+ describe value . inspect do
34+ let ( :params ) { { value : value } }
35+ it { is_expected . to compile . and_raise_error ( %r{parameter 'value' expects a Stdlib::Privilegedport} ) }
36+ end
37+ end
38+ end
39+ end
40+ end
41+ 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::unprivilegedport' , type : :class do
5+ describe 'valid unprivilegedport' do
6+ [
7+ 1024 ,
8+ 1337 ,
9+ 65000
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 ] ,
23+ [ nil , nil ] ,
24+ { 'foo' => 'bar' } ,
25+ { } ,
26+ '' ,
27+ 'https' ,
28+ '443' ,
29+ -1 ,
30+ 80 ,
31+ 443 ,
32+ 1023
33+ ] . each do |value |
34+ describe value . inspect do
35+ let ( :params ) { { value : value } }
36+ it { is_expected . to compile . and_raise_error ( %r{parameter 'value' expects a Stdlib::Unprivilegedport} ) }
37+ end
38+ end
39+ end
40+ end
41+ end
42+ end
Original file line number Diff line number Diff line change 1+ # Class to test the Stdlib::Port type alias
2+ class test::port (
3+ Stdlib::Port $value,
4+ ) {
5+ notice (" Success" )
6+ }
Original file line number Diff line number Diff line change 1+ # Class to test the Stdlib::Privilegedport type alias
2+ class test::privilegedport (
3+ Stdlib::Privilegedport $value,
4+ ) {
5+ notice (" Success" )
6+ }
Original file line number Diff line number Diff line change 1+ # Class to test the Stdlib::Unprivilegedport type alias
2+ class test::unprivilegedport (
3+ Stdlib::Unprivilegedport $value,
4+ ) {
5+ notice (" Success" )
6+ }
Original file line number Diff line number Diff line change 1+ type Stdlib::Port = Integer[0 , 65535 ]
Original file line number Diff line number Diff line change 1+ type Stdlib::Privilegedport = Integer[1 , 1023 ]
Original file line number Diff line number Diff line change 1+ type Stdlib::Unprivilegedport = Integer[1024 , 65535 ]
You can’t perform that action at this time.
0 commit comments