Skip to content

Commit b4ebf99

Browse files
committed
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
1 parent 57b339a commit b4ebf99

File tree

4 files changed

+125
-0
lines changed

4 files changed

+125
-0
lines changed

Diff for: spec/type_aliases/http__method_spec.rb

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
require 'spec_helper'
2+
3+
if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
4+
describe 'Stdlib::Http::Method' do
5+
describe 'valid HTTP Methods' do
6+
[
7+
'HEAD',
8+
'GET',
9+
'PUT',
10+
'DELETE',
11+
'TRACE',
12+
].each do |value|
13+
describe value.inspect do
14+
it { is_expected.to allow_value(value) }
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+
'199',
30+
600,
31+
1_000,
32+
'Ok',
33+
'get',
34+
].each do |value|
35+
describe value.inspect do
36+
it { is_expected.not_to allow_value(value) }
37+
end
38+
end
39+
end
40+
end
41+
end
42+
end

Diff for: spec/type_aliases/http__status_spec.rb

+40
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::Http::Status' do
5+
describe 'valid HTTP Status' do
6+
[
7+
200,
8+
302,
9+
404,
10+
418,
11+
503,
12+
].each do |value|
13+
describe value.inspect do
14+
it { is_expected.to allow_value(value) }
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+
'199',
30+
600,
31+
1_000,
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

Diff for: types/http/method.pp

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

Diff for: types/http/status.pp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Stdlib::Http::Status = Integer[100, 599]

0 commit comments

Comments
 (0)