restfulness 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +6 -5
- data/README.md +98 -80
- data/lib/restfulness.rb +3 -0
- data/lib/restfulness/dispatchers/rack.rb +1 -0
- data/lib/restfulness/headers/accept.rb +66 -0
- data/lib/restfulness/headers/media_type.rb +127 -0
- data/lib/restfulness/request.rb +43 -15
- data/lib/restfulness/version.rb +1 -1
- data/restfulness.gemspec +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/application_spec.rb +14 -14
- data/spec/unit/dispatcher_spec.rb +1 -1
- data/spec/unit/dispatchers/rack_spec.rb +21 -20
- data/spec/unit/exceptions_spec.rb +5 -5
- data/spec/unit/headers/accept_spec.rb +70 -0
- data/spec/unit/headers/media_type_spec.rb +262 -0
- data/spec/unit/http_authentication/basic_spec.rb +7 -7
- data/spec/unit/path_spec.rb +19 -19
- data/spec/unit/request_spec.rb +96 -44
- data/spec/unit/requests/authorization_header_spec.rb +8 -8
- data/spec/unit/requests/authorization_spec.rb +3 -3
- data/spec/unit/resource_spec.rb +28 -28
- data/spec/unit/resources/authentication_spec.rb +2 -2
- data/spec/unit/resources/events_spec.rb +1 -1
- data/spec/unit/response_spec.rb +53 -53
- data/spec/unit/route_spec.rb +24 -24
- data/spec/unit/router_spec.rb +29 -29
- data/spec/unit/sanitizer_spec.rb +9 -9
- metadata +13 -7
data/spec/unit/sanitizer_spec.rb
CHANGED
@@ -5,25 +5,25 @@ describe Restfulness::Sanitizer do
|
|
5
5
|
it 'does nothing when not given any sensitive params' do
|
6
6
|
subject = described_class::Hash.new()
|
7
7
|
input = {:password => 'ok', :nested => {:password => 'okay'}}
|
8
|
-
subject.sanitize(input).
|
8
|
+
expect(subject.sanitize(input)).to eq input
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'filters sensitive param and not others' do
|
12
12
|
subject = described_class::Hash.new(:password)
|
13
13
|
input = {:PASSword => 'supersecret', :user => 'billy'}
|
14
|
-
subject.sanitize(input).
|
14
|
+
expect(subject.sanitize(input)).to eq({:PASSword => described_class::SANITIZED, :user => 'billy'})
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'filters nested sensitive params and not others' do
|
18
18
|
subject = described_class::Hash.new(:password)
|
19
19
|
input = {:user => {:passWORD => 'supersecret', :user => 'billy'}}
|
20
|
-
subject.sanitize(input).
|
20
|
+
expect(subject.sanitize(input)).to eq({:user => {:passWORD => described_class::SANITIZED, :user => 'billy'}})
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'filters any parameter beginning with sensitive params (prefix)' do
|
24
24
|
subject = described_class::Hash.new(:password)
|
25
25
|
input = {:user => {:passWORD_confirmation => 'supersecret', :user => 'billy'}}
|
26
|
-
subject.sanitize(input).
|
26
|
+
expect(subject.sanitize(input)).to eq({:user => {:passWORD_confirmation => described_class::SANITIZED, :user => 'billy'}})
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -31,31 +31,31 @@ describe Restfulness::Sanitizer do
|
|
31
31
|
it 'does nothing when not given any sensitive params' do
|
32
32
|
subject = described_class::QueryString.new()
|
33
33
|
input = 'password=ok&other=false'
|
34
|
-
subject.sanitize(input).
|
34
|
+
expect(subject.sanitize(input)).to eq input
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'filters sensitive param and not others' do
|
38
38
|
subject = described_class::QueryString.new(:password)
|
39
39
|
input = 'PASSword=ok&other=false'
|
40
|
-
subject.sanitize(input).
|
40
|
+
expect(subject.sanitize(input)).to eq "PASSword=#{described_class::SANITIZED}&other=false"
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'filters nested (with index) sensitive params and not others' do
|
44
44
|
subject = described_class::QueryString.new(:password)
|
45
45
|
input = 'password[0]=what&PASSword[1]=secret&other=false'
|
46
|
-
subject.sanitize(input).
|
46
|
+
expect(subject.sanitize(input)).to eq "password[0]=#{described_class::SANITIZED}&PASSword[1]=#{described_class::SANITIZED}&other=false"
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'filters nested (no index) sensitive params and not others' do
|
50
50
|
subject = described_class::QueryString.new(:password)
|
51
51
|
input = 'password[]=what&password[]=secret&other=false'
|
52
|
-
subject.sanitize(input).
|
52
|
+
expect(subject.sanitize(input)).to eq "password[]=#{described_class::SANITIZED}&password[]=#{described_class::SANITIZED}&other=false"
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'filters any parameter beginning with sensitive params (prefix)' do
|
56
56
|
subject = described_class::QueryString.new(:password)
|
57
57
|
input = 'password_confirmation[]=what&password[]=secret&password=false'
|
58
|
-
subject.sanitize(input).
|
58
|
+
expect(subject.sanitize(input)).to eq "password_confirmation[]=#{described_class::SANITIZED}&password[]=#{described_class::SANITIZED}&password=#{described_class::SANITIZED}"
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restfulness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Lown
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: '0'
|
111
111
|
description: Simple REST server that focuses on resources instead of routes.
|
112
112
|
email:
|
113
113
|
- me@samlown.com
|
@@ -130,6 +130,8 @@ files:
|
|
130
130
|
- lib/restfulness/dispatcher.rb
|
131
131
|
- lib/restfulness/dispatchers/rack.rb
|
132
132
|
- lib/restfulness/exceptions.rb
|
133
|
+
- lib/restfulness/headers/accept.rb
|
134
|
+
- lib/restfulness/headers/media_type.rb
|
133
135
|
- lib/restfulness/http_authentication/basic.rb
|
134
136
|
- lib/restfulness/path.rb
|
135
137
|
- lib/restfulness/request.rb
|
@@ -150,6 +152,8 @@ files:
|
|
150
152
|
- spec/unit/dispatcher_spec.rb
|
151
153
|
- spec/unit/dispatchers/rack_spec.rb
|
152
154
|
- spec/unit/exceptions_spec.rb
|
155
|
+
- spec/unit/headers/accept_spec.rb
|
156
|
+
- spec/unit/headers/media_type_spec.rb
|
153
157
|
- spec/unit/http_authentication/basic_spec.rb
|
154
158
|
- spec/unit/path_spec.rb
|
155
159
|
- spec/unit/request_spec.rb
|
@@ -182,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
186
|
version: '0'
|
183
187
|
requirements: []
|
184
188
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.
|
189
|
+
rubygems_version: 2.4.6
|
186
190
|
signing_key:
|
187
191
|
specification_version: 4
|
188
192
|
summary: Use to create a powerful, yet simple REST API in your application.
|
@@ -192,6 +196,8 @@ test_files:
|
|
192
196
|
- spec/unit/dispatcher_spec.rb
|
193
197
|
- spec/unit/dispatchers/rack_spec.rb
|
194
198
|
- spec/unit/exceptions_spec.rb
|
199
|
+
- spec/unit/headers/accept_spec.rb
|
200
|
+
- spec/unit/headers/media_type_spec.rb
|
195
201
|
- spec/unit/http_authentication/basic_spec.rb
|
196
202
|
- spec/unit/path_spec.rb
|
197
203
|
- spec/unit/request_spec.rb
|