Skip to content

Commit 94e768f

Browse files
committed
change names
1 parent b0d99ad commit 94e768f

File tree

7 files changed

+204
-0
lines changed

7 files changed

+204
-0
lines changed

README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ Unacceptable input example:
413413
/usr2/username/bin:/usr/local/bin:/usr/bin:.
414414
```
415415

416+
<<<<<<< HEAD
416417
#### `Stdlib::Fqdn`
417418

418419
Matches paths on fully quallified domain name
@@ -463,6 +464,88 @@ Unacceptable input example:
463464
%.example.com
464465
465466
bob@example.com
467+
468+
#### `Stdlib::Port`
469+
470+
Matches a valid TCP/UDP Port number
471+
472+
Acceptable input examples:
473+
474+
```shell
475+
80
476+
477+
443
478+
479+
1337
480+
481+
65000
482+
```
483+
484+
Unacceptable input example:
485+
486+
-1
487+
488+
65536
489+
490+
'443'
491+
492+
'https'
493+
````
494+
495+
#### `Stdlib::Port::Privileged
496+
497+
Matches a valid TCP/UDP Pivlaged port i.e. < 1024
498+
499+
Acceptable input examples:
500+
501+
```shell
502+
80
503+
504+
443
505+
506+
1023
507+
```
508+
509+
Unacceptable input example:
510+
511+
```shell
512+
-1
513+
514+
1337
515+
516+
'443'
517+
518+
'https'
519+
```
520+
521+
#### `Stdlib::Port::Unprivileged`
522+
523+
Matches a valid TCP/UDP Pivlaged port i.e. >= 1024
524+
525+
Acceptable input examples:
526+
527+
```shell
528+
1024
529+
530+
1337
531+
532+
65000
533+
534+
```
535+
536+
Unacceptable input example:
537+
```shell
538+
-1
539+
540+
80
541+
542+
443
543+
544+
1023
545+
546+
'443'
547+
548+
'https'
466549
```
467550
468551
### Facts
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
require 'spec_helper'
2+
3+
if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
4+
describe 'Stdlib::Port::Privileged' do
5+
describe 'valid ports' do
6+
[
7+
80,
8+
443,
9+
1023,
10+
].each do |value|
11+
describe value.inspect do
12+
it { is_expected.to allow_value(value) }
13+
end
14+
end
15+
end
16+
17+
describe 'invalid path handling' do
18+
context 'garbage inputs' do
19+
[
20+
nil,
21+
[nil],
22+
[nil, nil],
23+
{ 'foo' => 'bar' },
24+
{},
25+
'',
26+
'https',
27+
'443',
28+
-1,
29+
1337,
30+
1024,
31+
].each do |value|
32+
describe value.inspect do
33+
it { is_expected.not_to allow_value(value) }
34+
end
35+
end
36+
end
37+
end
38+
end
39+
end
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
require 'spec_helper'
2+
3+
if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
4+
describe 'Stdlib::Port::Unprivileged' do
5+
describe 'valid unprivilegedport' do
6+
[
7+
1024,
8+
1337,
9+
65_000,
10+
].each do |value|
11+
describe value.inspect do
12+
it { is_expected.to allow_value(value) }
13+
end
14+
end
15+
end
16+
17+
describe 'invalid path handling' do
18+
context 'garbage inputs' do
19+
[
20+
nil,
21+
[nil],
22+
[nil, nil],
23+
{ 'foo' => 'bar' },
24+
{},
25+
'',
26+
'https',
27+
'443',
28+
-1,
29+
80,
30+
443,
31+
1023,
32+
].each do |value|
33+
describe value.inspect do
34+
it { is_expected.not_to allow_value(value) }
35+
end
36+
end
37+
end
38+
end
39+
end
40+
end

spec/type_aliases/port_spec.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
require 'spec_helper'
2+
3+
if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
4+
describe 'Stdlib::Port' do
5+
describe 'valid ports' do
6+
[
7+
80,
8+
443,
9+
1337,
10+
65_000,
11+
].each do |value|
12+
describe value.inspect do
13+
it { is_expected.to allow_value(value) }
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+
65_536,
31+
].each do |value|
32+
describe value.inspect do
33+
it { is_expected.not_to allow_value(value) }
34+
end
35+
end
36+
end
37+
end
38+
end
39+
end

types/port.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Stdlib::Port = Integer[0, 65535]

types/port/privileged.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Stdlib::Port::Privileged = Integer[1, 1023]

types/port/unprivileged.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Stdlib::Port::Unprivileged = Integer[1024, 65535]

0 commit comments

Comments
 (0)