Skip to content

Commit e588a1d

Browse files
b4ldrekohl
andcommitted
Stdlib::Http::Method: Add new type for http methods
This PR creates new new resources: * Stdlib::Http::Method for validating http methods * Stdlib::Http::Status This is just a copy of Stdlib::Httpstatus * make Stdlib::Httpstatus and alias to Stdlib::Http::Status Ideally we would deprecate Stdlib::Httpstatus in favour of Stdlib::Http::Status Co-authored-by: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
1 parent ef733aa commit e588a1d

File tree

6 files changed

+170
-2
lines changed

6 files changed

+170
-2
lines changed

REFERENCE.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,16 @@ OpenSSL.
281281
* [`Stdlib::Ensure::File::Directory`](#stdlibensurefiledirectory): Validate the ensure parameter of a "directory" file resource
282282
* [`Stdlib::Ensure::File::File`](#stdlibensurefilefile): Validate the ensure parameter of a "file" file resource
283283
* [`Stdlib::Ensure::File::Link`](#stdlibensurefilelink): Validate the ensure parameter of a "link" file resource
284+
* [`Stdlib::Ensure::Package`](#stdlibensurepackage): Validate the value of the ensure parameter for a package
284285
* [`Stdlib::Ensure::Service`](#stdlibensureservice): Validate the value of the ensure parameter of a service resource
285286
* [`Stdlib::Filemode`](#stdlibfilemode): Validate a file mode
286287
* [`Stdlib::Filesource`](#stdlibfilesource): Validate the source parameter on file types
287288
* [`Stdlib::Fqdn`](#stdlibfqdn): Validate a Fully Qualified Domain Name
288289
* [`Stdlib::HTTPSUrl`](#stdlibhttpsurl): Validate a HTTPS URL
289290
* [`Stdlib::HTTPUrl`](#stdlibhttpurl): Validate a HTTP(S) URL
290291
* [`Stdlib::Host`](#stdlibhost): Validate a host (FQDN or IP address)
292+
* [`Stdlib::Http::Method`](#stdlibhttpmethod): Valid HTTP method verbs
293+
* [`Stdlib::Http::Status`](#stdlibhttpstatus): A valid HTTP status code per RFC9110
291294
* [`Stdlib::HttpStatus`](#stdlibhttpstatus): Validate a HTTP status code
292295
* [`Stdlib::IP::Address`](#stdlibipaddress): Validate an IP address
293296
* [`Stdlib::IP::Address::Nosubnet`](#stdlibipaddressnosubnet): Validate an IP address without subnet
@@ -7819,6 +7822,16 @@ Alias of
78197822
Enum['link', 'absent']
78207823
```
78217824

7825+
### <a name="stdlibensurepackage"></a>`Stdlib::Ensure::Package`
7826+
7827+
Validate the value of the ensure parameter for a package
7828+
7829+
Alias of
7830+
7831+
```puppet
7832+
Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]]
7833+
```
7834+
78227835
### <a name="stdlibensureservice"></a>`Stdlib::Ensure::Service`
78237836

78247837
Validate the value of the ensure parameter of a service resource
@@ -7893,14 +7906,43 @@ Alias of
78937906
Variant[Stdlib::Fqdn, Stdlib::Compat::Ip_address]
78947907
```
78957908

7909+
### <a name="stdlibhttpmethod"></a>`Stdlib::Http::Method`
7910+
7911+
Valid HTTP method verbs
7912+
7913+
* **See also**
7914+
* https://www.iana.org/assignments/http-methods/http-methods.xhtml
7915+
7916+
Alias of
7917+
7918+
```puppet
7919+
Enum['ACL', 'BASELINE-CONTROL', 'BIND', 'CHECKIN', 'CHECKOUT', 'CONNECT', 'COPY', 'DELETE', 'GET', 'HEAD', 'LABEL', 'LINK', 'LOCK', 'MERGE', 'MKACTIVITY', 'MKCALENDAR', 'MKCOL', 'MKREDIRECTREF', 'MKWORKSPACE', 'MOVE', 'OPTIONS', 'ORDERPATCH', 'PATCH', 'POST', 'PRI', 'PROPFIND', 'PROPPATCH', 'PUT', 'REBIND', 'REPORT', 'SEARCH', 'TRACE', 'UNBIND', 'UNCHECKOUT', 'UNLINK', 'UNLOCK', 'UPDATE', 'UPDATEREDIRECTREF', 'VERSION-CONTROL']
7920+
```
7921+
7922+
### <a name="stdlibhttpstatus"></a>`Stdlib::Http::Status`
7923+
7924+
A valid HTTP status code per RFC9110
7925+
7926+
* **See also**
7927+
* https://httpwg.org/specs/rfc9110.html#overview.of.status.codes
7928+
7929+
Alias of
7930+
7931+
```puppet
7932+
Integer[100, 599]
7933+
```
7934+
78967935
### <a name="stdlibhttpstatus"></a>`Stdlib::HttpStatus`
78977936

78987937
Validate a HTTP status code
78997938

7939+
* **See also**
7940+
* Stdlib::Http::Status
7941+
79007942
Alias of
79017943

79027944
```puppet
7903-
Integer[100, 599]
7945+
Stdlib::Http::Status
79047946
```
79057947

79067948
### <a name="stdlibipaddress"></a>`Stdlib::IP::Address`
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
require 'spec_helper'
2+
3+
describe 'Stdlib::Http::Method' do
4+
describe 'valid HTTP Methods' do
5+
[
6+
'HEAD',
7+
'GET',
8+
'PUT',
9+
'DELETE',
10+
'TRACE',
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+
'199',
29+
600,
30+
1_000,
31+
'Ok',
32+
'get',
33+
].each do |value|
34+
describe value.inspect do
35+
it { is_expected.not_to allow_value(value) }
36+
end
37+
end
38+
end
39+
end
40+
end
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
require 'spec_helper'
2+
3+
describe 'Stdlib::Http::Status' do
4+
describe 'valid HTTP Status' do
5+
[
6+
200,
7+
302,
8+
404,
9+
418,
10+
503,
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+
'199',
29+
600,
30+
1_000,
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

types/http/method.pp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# @summary Valid HTTP method verbs
2+
# @see https://www.iana.org/assignments/http-methods/http-methods.xhtml
3+
type Stdlib::Http::Method = Enum[
4+
'ACL',
5+
'BASELINE-CONTROL',
6+
'BIND',
7+
'CHECKIN',
8+
'CHECKOUT',
9+
'CONNECT',
10+
'COPY',
11+
'DELETE',
12+
'GET',
13+
'HEAD',
14+
'LABEL',
15+
'LINK',
16+
'LOCK',
17+
'MERGE',
18+
'MKACTIVITY',
19+
'MKCALENDAR',
20+
'MKCOL',
21+
'MKREDIRECTREF',
22+
'MKWORKSPACE',
23+
'MOVE',
24+
'OPTIONS',
25+
'ORDERPATCH',
26+
'PATCH',
27+
'POST',
28+
'PRI',
29+
'PROPFIND',
30+
'PROPPATCH',
31+
'PUT',
32+
'REBIND',
33+
'REPORT',
34+
'SEARCH',
35+
'TRACE',
36+
'UNBIND',
37+
'UNCHECKOUT',
38+
'UNLINK',
39+
'UNLOCK',
40+
'UPDATE',
41+
'UPDATEREDIRECTREF',
42+
'VERSION-CONTROL',
43+
]

types/http/status.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @summary A valid HTTP status code per RFC9110
2+
# @see https://httpwg.org/specs/rfc9110.html#overview.of.status.codes
3+
type Stdlib::Http::Status = Integer[100, 599]

types/httpstatus.pp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# @summary Validate a HTTP status code
2-
type Stdlib::HttpStatus = Integer[100, 599]
2+
# @deprecated Use Stdlib::Http::Status
3+
# @see Stdlib::Http::Status
4+
type Stdlib::HttpStatus = Stdlib::Http::Status

0 commit comments

Comments
 (0)