diff --git a/spec/type_aliases/http__method_spec.rb b/spec/type_aliases/http__method_spec.rb new file mode 100644 index 000000000..e80d02027 --- /dev/null +++ b/spec/type_aliases/http__method_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +describe 'Stdlib::Http::Method' do + describe 'valid HTTP Methods' do + [ + 'HEAD', + 'GET', + 'PUT', + 'DELETE', + 'TRACE', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'invalid path handling' do + context 'garbage inputs' do + [ + nil, + [nil], + [nil, nil], + { 'foo' => 'bar' }, + {}, + '', + 'https', + '199', + 600, + 1_000, + 'Ok', + 'get', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/http__status_spec.rb b/spec/type_aliases/http__status_spec.rb new file mode 100644 index 000000000..123612fc3 --- /dev/null +++ b/spec/type_aliases/http__status_spec.rb @@ -0,0 +1,38 @@ +require 'spec_helper' + +describe 'Stdlib::Http::Status' do + describe 'valid HTTP Status' do + [ + 200, + 302, + 404, + 418, + 503, + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'invalid path handling' do + context 'garbage inputs' do + [ + nil, + [nil], + [nil, nil], + { 'foo' => 'bar' }, + {}, + '', + 'https', + '199', + 600, + 1_000, + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/types/http/method.pp b/types/http/method.pp new file mode 100644 index 000000000..71fdf3c48 --- /dev/null +++ b/types/http/method.pp @@ -0,0 +1,42 @@ +# https://www.iana.org/assignments/http-methods/http-methods.xhtml +type Stdlib::Http::Method = 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', +] diff --git a/types/http/status.pp b/types/http/status.pp new file mode 100644 index 000000000..cc81e71e6 --- /dev/null +++ b/types/http/status.pp @@ -0,0 +1 @@ +type Stdlib::Http::Status = Integer[100, 599] diff --git a/types/httpstatus.pp b/types/httpstatus.pp index 146587be8..3385c9c62 100644 --- a/types/httpstatus.pp +++ b/types/httpstatus.pp @@ -1 +1 @@ -type Stdlib::HttpStatus = Integer[100, 599] +type Stdlib::HttpStatus = Stdlib::Http::Status