api-auth 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +10 -44
- data/.rubocop.yml +102 -0
- data/.travis.yml +1 -0
- data/Appraisals +8 -0
- data/CHANGELOG.md +8 -1
- data/Gemfile +3 -0
- data/README.md +33 -5
- data/VERSION +1 -1
- data/api_auth.gemspec +17 -17
- data/gemfiles/rails_23.gemfile +3 -0
- data/gemfiles/rails_30.gemfile +3 -0
- data/gemfiles/rails_31.gemfile +5 -0
- data/gemfiles/rails_32.gemfile +5 -0
- data/gemfiles/rails_4.gemfile +2 -0
- data/gemfiles/rails_41.gemfile +2 -0
- data/gemfiles/rails_42.gemfile +2 -0
- data/lib/api-auth.rb +1 -1
- data/lib/api_auth/base.rb +21 -25
- data/lib/api_auth/errors.rb +4 -3
- data/lib/api_auth/headers.rb +11 -27
- data/lib/api_auth/helpers.rb +2 -6
- data/lib/api_auth/railtie.rb +5 -50
- data/lib/api_auth/request_drivers/action_controller.rb +7 -13
- data/lib/api_auth/request_drivers/action_dispatch.rb +0 -6
- data/lib/api_auth/request_drivers/curb.rb +8 -14
- data/lib/api_auth/request_drivers/faraday.rb +11 -21
- data/lib/api_auth/request_drivers/httpi.rb +8 -14
- data/lib/api_auth/request_drivers/net_http.rb +8 -14
- data/lib/api_auth/request_drivers/rack.rb +10 -16
- data/lib/api_auth/request_drivers/rest_client.rb +9 -15
- data/spec/api_auth_spec.rb +90 -88
- data/spec/headers_spec.rb +69 -84
- data/spec/helpers_spec.rb +7 -9
- data/spec/railtie_spec.rb +42 -72
- data/spec/request_drivers/action_controller_spec.rb +53 -55
- data/spec/request_drivers/action_dispatch_spec.rb +52 -55
- data/spec/request_drivers/curb_spec.rb +25 -28
- data/spec/request_drivers/faraday_spec.rb +54 -56
- data/spec/request_drivers/httpi_spec.rb +42 -48
- data/spec/request_drivers/net_http_spec.rb +51 -53
- data/spec/request_drivers/rack_spec.rb +58 -60
- data/spec/request_drivers/rest_client_spec.rb +86 -89
- data/spec/spec_helper.rb +9 -9
- metadata +4 -11
- data/Gemfile.lock +0 -115
- data/gemfiles/rails_23.gemfile.lock +0 -70
- data/gemfiles/rails_30.gemfile.lock +0 -92
- data/gemfiles/rails_31.gemfile.lock +0 -98
- data/gemfiles/rails_32.gemfile.lock +0 -97
- data/gemfiles/rails_4.gemfile.lock +0 -94
- data/gemfiles/rails_41.gemfile.lock +0 -98
- data/gemfiles/rails_42.gemfile.lock +0 -115
@@ -1,19 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ApiAuth::RequestDrivers::NetHttpRequest do
|
4
|
+
let(:timestamp) { Time.now.utc.httpdate }
|
4
5
|
|
5
|
-
let(:
|
6
|
+
let(:request_path) { '/resource.xml?foo=bar&bar=foo' }
|
6
7
|
|
7
|
-
let(:
|
8
|
-
|
9
|
-
let(:request_headers){
|
8
|
+
let(:request_headers) do
|
10
9
|
{
|
11
|
-
'Authorization'
|
10
|
+
'Authorization' => 'APIAuth 1044:12345',
|
12
11
|
'content-md5' => '1B2M2Y8AsgTpgAmY7PhCfg==',
|
13
12
|
'content-type' => 'text/plain',
|
14
13
|
'date' => timestamp
|
15
14
|
}
|
16
|
-
|
15
|
+
end
|
17
16
|
|
18
17
|
let(:request) do
|
19
18
|
net_http_request = Net::HTTP::Put.new(request_path, request_headers)
|
@@ -21,175 +20,174 @@ describe ApiAuth::RequestDrivers::NetHttpRequest do
|
|
21
20
|
net_http_request
|
22
21
|
end
|
23
22
|
|
24
|
-
subject(:driven_request){ ApiAuth::RequestDrivers::NetHttpRequest.new(request) }
|
23
|
+
subject(:driven_request) { ApiAuth::RequestDrivers::NetHttpRequest.new(request) }
|
25
24
|
|
26
|
-
describe
|
27
|
-
describe
|
28
|
-
it
|
25
|
+
describe 'getting headers correctly' do
|
26
|
+
describe '#content_type' do
|
27
|
+
it 'gets the content_type' do
|
29
28
|
expect(driven_request.content_type).to eq('text/plain')
|
30
29
|
end
|
31
30
|
|
32
|
-
it
|
33
|
-
request = Net::HTTP::Put::Multipart.new(
|
34
|
-
|
31
|
+
it 'gets multipart content_type' do
|
32
|
+
request = Net::HTTP::Put::Multipart.new('/resource.xml?foo=bar&bar=foo',
|
33
|
+
'file' => UploadIO.new(File.new('spec/fixtures/upload.png'), 'image/png', 'upload.png'))
|
35
34
|
driven_request = ApiAuth::RequestDrivers::NetHttpRequest.new(request)
|
36
35
|
expect(driven_request.content_type).to match 'multipart/form-data; boundary='
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
|
-
it
|
39
|
+
it 'gets the content_md5' do
|
41
40
|
expect(driven_request.content_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
|
42
41
|
end
|
43
42
|
|
44
|
-
it
|
43
|
+
it 'gets the request_uri' do
|
45
44
|
expect(driven_request.request_uri).to eq('/resource.xml?foo=bar&bar=foo')
|
46
45
|
end
|
47
46
|
|
48
|
-
it
|
47
|
+
it 'gets the timestamp' do
|
49
48
|
expect(driven_request.timestamp).to eq(timestamp)
|
50
49
|
end
|
51
50
|
|
52
|
-
it
|
51
|
+
it 'gets the authorization_header' do
|
53
52
|
expect(driven_request.authorization_header).to eq('APIAuth 1044:12345')
|
54
53
|
end
|
55
54
|
|
56
|
-
describe
|
57
|
-
it
|
55
|
+
describe '#calculated_md5' do
|
56
|
+
it 'calculates md5 from the body' do
|
58
57
|
expect(driven_request.calculated_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
|
59
58
|
end
|
60
59
|
|
61
|
-
it
|
60
|
+
it 'treats no body as empty string' do
|
62
61
|
request.body = nil
|
63
62
|
expect(driven_request.calculated_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
|
64
63
|
end
|
65
64
|
|
66
|
-
it
|
65
|
+
it 'calculates correctly for multipart content' do
|
67
66
|
request.body = nil
|
68
67
|
request.body_stream = File.new('spec/fixtures/upload.png')
|
69
68
|
expect(driven_request.calculated_md5).to eq('k4U8MTA3RHDcewBzymVNEQ==')
|
70
69
|
end
|
71
70
|
end
|
72
71
|
|
73
|
-
describe
|
74
|
-
context
|
75
|
-
let(:request){ Net::HTTP::Put.new(request_path, request_headers) }
|
72
|
+
describe 'http_method' do
|
73
|
+
context 'when put request' do
|
74
|
+
let(:request) { Net::HTTP::Put.new(request_path, request_headers) }
|
76
75
|
|
77
|
-
it
|
76
|
+
it 'returns upcased put' do
|
78
77
|
expect(driven_request.http_method).to eq('PUT')
|
79
78
|
end
|
80
79
|
end
|
81
80
|
|
82
|
-
context
|
83
|
-
let(:request){ Net::HTTP::Get.new(request_path, request_headers) }
|
81
|
+
context 'when get request' do
|
82
|
+
let(:request) { Net::HTTP::Get.new(request_path, request_headers) }
|
84
83
|
|
85
|
-
it
|
84
|
+
it 'returns upcased get' do
|
86
85
|
expect(driven_request.http_method).to eq('GET')
|
87
86
|
end
|
88
87
|
end
|
89
88
|
end
|
90
89
|
end
|
91
90
|
|
92
|
-
describe
|
93
|
-
let(:request_headers)
|
91
|
+
describe 'setting headers correctly' do
|
92
|
+
let(:request_headers) do
|
94
93
|
{
|
95
94
|
'content-type' => 'text/plain'
|
96
95
|
}
|
97
|
-
|
96
|
+
end
|
98
97
|
|
99
98
|
let(:request) do
|
100
99
|
Net::HTTP::Put.new(request_path, request_headers)
|
101
100
|
end
|
102
101
|
|
103
|
-
describe
|
104
|
-
context
|
102
|
+
describe '#populate_content_md5' do
|
103
|
+
context 'when request type has no body' do
|
105
104
|
let(:request) do
|
106
105
|
Net::HTTP::Get.new(request_path, request_headers)
|
107
106
|
end
|
108
107
|
|
109
108
|
it "doesn't populate content-md5" do
|
110
109
|
driven_request.populate_content_md5
|
111
|
-
expect(request[
|
110
|
+
expect(request['Content-MD5']).to be_nil
|
112
111
|
end
|
113
112
|
end
|
114
113
|
|
115
|
-
context
|
114
|
+
context 'when request type has a body' do
|
116
115
|
let(:request) do
|
117
116
|
net_http_request = Net::HTTP::Put.new(request_path, request_headers)
|
118
117
|
net_http_request.body = "hello\nworld"
|
119
118
|
net_http_request
|
120
119
|
end
|
121
120
|
|
122
|
-
it
|
121
|
+
it 'populates content-md5' do
|
123
122
|
driven_request.populate_content_md5
|
124
|
-
expect(request[
|
123
|
+
expect(request['Content-MD5']).to eq('kZXQvrKoieG+Be1rsZVINw==')
|
125
124
|
end
|
126
125
|
|
127
|
-
it
|
126
|
+
it 'refreshes the cached headers' do
|
128
127
|
driven_request.populate_content_md5
|
129
128
|
expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
|
130
129
|
end
|
131
130
|
end
|
132
131
|
end
|
133
132
|
|
134
|
-
describe
|
133
|
+
describe '#set_date' do
|
135
134
|
before do
|
136
135
|
allow(Time).to receive_message_chain(:now, :utc, :httpdate).and_return(timestamp)
|
137
136
|
end
|
138
137
|
|
139
|
-
it
|
138
|
+
it 'sets the date header of the request' do
|
140
139
|
driven_request.set_date
|
141
140
|
expect(request['DATE']).to eq(timestamp)
|
142
141
|
end
|
143
142
|
|
144
|
-
it
|
143
|
+
it 'refreshes the cached headers' do
|
145
144
|
driven_request.set_date
|
146
145
|
expect(driven_request.timestamp).to eq(timestamp)
|
147
146
|
end
|
148
147
|
end
|
149
148
|
|
150
|
-
describe
|
151
|
-
it
|
149
|
+
describe '#set_auth_header' do
|
150
|
+
it 'sets the auth header' do
|
152
151
|
driven_request.set_auth_header('APIAuth 1044:54321')
|
153
152
|
expect(request['Authorization']).to eq('APIAuth 1044:54321')
|
154
153
|
end
|
155
154
|
end
|
156
155
|
end
|
157
156
|
|
158
|
-
describe
|
159
|
-
context
|
157
|
+
describe 'md5_mismatch?' do
|
158
|
+
context 'when request type has no body' do
|
160
159
|
let(:request) do
|
161
160
|
Net::HTTP::Get.new(request_path, request_headers)
|
162
161
|
end
|
163
162
|
|
164
|
-
|
165
|
-
it "is false" do
|
163
|
+
it 'is false' do
|
166
164
|
expect(driven_request.md5_mismatch?).to be false
|
167
165
|
end
|
168
166
|
end
|
169
167
|
|
170
|
-
context
|
168
|
+
context 'when request type has a body' do
|
171
169
|
let(:request) do
|
172
170
|
net_http_request = Net::HTTP::Put.new(request_path, request_headers)
|
173
171
|
net_http_request.body = "hello\nworld"
|
174
172
|
net_http_request
|
175
173
|
end
|
176
174
|
|
177
|
-
context
|
175
|
+
context 'when calculated matches sent' do
|
178
176
|
before do
|
179
|
-
request[
|
177
|
+
request['Content-MD5'] = 'kZXQvrKoieG+Be1rsZVINw=='
|
180
178
|
end
|
181
179
|
|
182
|
-
it
|
180
|
+
it 'is false' do
|
183
181
|
expect(driven_request.md5_mismatch?).to be false
|
184
182
|
end
|
185
183
|
end
|
186
184
|
|
187
185
|
context "when calculated doesn't match sent" do
|
188
186
|
before do
|
189
|
-
request[
|
187
|
+
request['Content-MD5'] = '3'
|
190
188
|
end
|
191
189
|
|
192
|
-
it
|
190
|
+
it 'is true' do
|
193
191
|
expect(driven_request.md5_mismatch?).to be true
|
194
192
|
end
|
195
193
|
end
|
@@ -1,19 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ApiAuth::RequestDrivers::RackRequest do
|
4
|
+
let(:timestamp) { Time.now.utc.httpdate }
|
4
5
|
|
5
|
-
let(:
|
6
|
+
let(:request_path) { '/resource.xml?foo=bar&bar=foo' }
|
6
7
|
|
7
|
-
let(:
|
8
|
-
|
9
|
-
let(:request_headers){
|
8
|
+
let(:request_headers) do
|
10
9
|
{
|
11
|
-
'Authorization'
|
10
|
+
'Authorization' => 'APIAuth 1044:12345',
|
12
11
|
'Content-MD5' => '1B2M2Y8AsgTpgAmY7PhCfg==',
|
13
12
|
'Content-Type' => 'text/plain',
|
14
13
|
'Date' => timestamp
|
15
14
|
}
|
16
|
-
|
15
|
+
end
|
17
16
|
|
18
17
|
let(:request) do
|
19
18
|
Rack::Request.new(
|
@@ -25,35 +24,35 @@ describe ApiAuth::RequestDrivers::RackRequest do
|
|
25
24
|
)
|
26
25
|
end
|
27
26
|
|
28
|
-
subject(:driven_request){ ApiAuth::RequestDrivers::RackRequest.new(request) }
|
27
|
+
subject(:driven_request) { ApiAuth::RequestDrivers::RackRequest.new(request) }
|
29
28
|
|
30
|
-
describe
|
31
|
-
it
|
29
|
+
describe 'getting headers correctly' do
|
30
|
+
it 'gets the content_type' do
|
32
31
|
expect(driven_request.content_type).to eq('text/plain')
|
33
32
|
end
|
34
33
|
|
35
|
-
it
|
34
|
+
it 'gets the content_md5' do
|
36
35
|
expect(driven_request.content_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
|
37
36
|
end
|
38
37
|
|
39
|
-
it
|
38
|
+
it 'gets the request_uri' do
|
40
39
|
expect(driven_request.request_uri).to eq('/resource.xml?foo=bar&bar=foo')
|
41
40
|
end
|
42
41
|
|
43
|
-
it
|
42
|
+
it 'gets the timestamp' do
|
44
43
|
expect(driven_request.timestamp).to eq(timestamp)
|
45
44
|
end
|
46
45
|
|
47
|
-
it
|
46
|
+
it 'gets the authorization_header' do
|
48
47
|
expect(driven_request.authorization_header).to eq('APIAuth 1044:12345')
|
49
48
|
end
|
50
49
|
|
51
|
-
describe
|
52
|
-
it
|
50
|
+
describe '#calculated_md5' do
|
51
|
+
it 'calculates md5 from the body' do
|
53
52
|
expect(driven_request.calculated_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
|
54
53
|
end
|
55
54
|
|
56
|
-
it
|
55
|
+
it 'treats no body as empty string' do
|
57
56
|
request = Rack::Request.new(
|
58
57
|
Rack::MockRequest.env_for(
|
59
58
|
request_path,
|
@@ -65,8 +64,8 @@ describe ApiAuth::RequestDrivers::RackRequest do
|
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
68
|
-
describe
|
69
|
-
context
|
67
|
+
describe 'http_method' do
|
68
|
+
context 'when put request' do
|
70
69
|
let(:request) do
|
71
70
|
Rack::Request.new(
|
72
71
|
Rack::MockRequest.env_for(
|
@@ -76,12 +75,12 @@ describe ApiAuth::RequestDrivers::RackRequest do
|
|
76
75
|
)
|
77
76
|
end
|
78
77
|
|
79
|
-
it
|
78
|
+
it 'returns upcased put' do
|
80
79
|
expect(driven_request.http_method).to eq('PUT')
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|
84
|
-
context
|
83
|
+
context 'when get request' do
|
85
84
|
let(:request) do
|
86
85
|
Rack::Request.new(
|
87
86
|
Rack::MockRequest.env_for(
|
@@ -91,22 +90,22 @@ describe ApiAuth::RequestDrivers::RackRequest do
|
|
91
90
|
)
|
92
91
|
end
|
93
92
|
|
94
|
-
it
|
93
|
+
it 'returns upcased get' do
|
95
94
|
expect(driven_request.http_method).to eq('GET')
|
96
95
|
end
|
97
96
|
end
|
98
97
|
end
|
99
98
|
end
|
100
99
|
|
101
|
-
describe
|
102
|
-
let(:request_headers)
|
100
|
+
describe 'setting headers correctly' do
|
101
|
+
let(:request_headers) do
|
103
102
|
{
|
104
103
|
'content-type' => 'text/plain'
|
105
104
|
}
|
106
|
-
|
105
|
+
end
|
107
106
|
|
108
|
-
describe
|
109
|
-
context
|
107
|
+
describe '#populate_content_md5' do
|
108
|
+
context 'when getting' do
|
110
109
|
let(:request) do
|
111
110
|
Rack::Request.new(
|
112
111
|
Rack::MockRequest.env_for(
|
@@ -118,11 +117,11 @@ describe ApiAuth::RequestDrivers::RackRequest do
|
|
118
117
|
|
119
118
|
it "doesn't populate content-md5" do
|
120
119
|
driven_request.populate_content_md5
|
121
|
-
expect(request.env[
|
120
|
+
expect(request.env['Content-MD5']).to be_nil
|
122
121
|
end
|
123
122
|
end
|
124
123
|
|
125
|
-
context
|
124
|
+
context 'when posting' do
|
126
125
|
let(:request) do
|
127
126
|
Rack::Request.new(
|
128
127
|
Rack::MockRequest.env_for(
|
@@ -133,18 +132,18 @@ describe ApiAuth::RequestDrivers::RackRequest do
|
|
133
132
|
)
|
134
133
|
end
|
135
134
|
|
136
|
-
it
|
135
|
+
it 'populates content-md5' do
|
137
136
|
driven_request.populate_content_md5
|
138
|
-
expect(request.env[
|
137
|
+
expect(request.env['Content-MD5']).to eq('kZXQvrKoieG+Be1rsZVINw==')
|
139
138
|
end
|
140
139
|
|
141
|
-
it
|
140
|
+
it 'refreshes the cached headers' do
|
142
141
|
driven_request.populate_content_md5
|
143
142
|
expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
|
144
143
|
end
|
145
144
|
end
|
146
145
|
|
147
|
-
context
|
146
|
+
context 'when putting' do
|
148
147
|
let(:request) do
|
149
148
|
Rack::Request.new(
|
150
149
|
Rack::MockRequest.env_for(
|
@@ -155,18 +154,18 @@ describe ApiAuth::RequestDrivers::RackRequest do
|
|
155
154
|
)
|
156
155
|
end
|
157
156
|
|
158
|
-
it
|
157
|
+
it 'populates content-md5' do
|
159
158
|
driven_request.populate_content_md5
|
160
|
-
expect(request.env[
|
159
|
+
expect(request.env['Content-MD5']).to eq('kZXQvrKoieG+Be1rsZVINw==')
|
161
160
|
end
|
162
161
|
|
163
|
-
it
|
162
|
+
it 'refreshes the cached headers' do
|
164
163
|
driven_request.populate_content_md5
|
165
164
|
expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
|
166
165
|
end
|
167
166
|
end
|
168
167
|
|
169
|
-
context
|
168
|
+
context 'when deleting' do
|
170
169
|
let(:request) do
|
171
170
|
Rack::Request.new(
|
172
171
|
Rack::MockRequest.env_for(
|
@@ -178,38 +177,37 @@ describe ApiAuth::RequestDrivers::RackRequest do
|
|
178
177
|
|
179
178
|
it "doesn't populate content-md5" do
|
180
179
|
driven_request.populate_content_md5
|
181
|
-
expect(request.env[
|
180
|
+
expect(request.env['Content-MD5']).to be_nil
|
182
181
|
end
|
183
182
|
end
|
184
|
-
|
185
183
|
end
|
186
184
|
|
187
|
-
describe
|
185
|
+
describe '#set_date' do
|
188
186
|
before do
|
189
187
|
allow(Time).to receive_message_chain(:now, :utc, :httpdate).and_return(timestamp)
|
190
188
|
end
|
191
189
|
|
192
|
-
it
|
190
|
+
it 'sets the date header of the request' do
|
193
191
|
driven_request.set_date
|
194
192
|
expect(request.env['DATE']).to eq(timestamp)
|
195
193
|
end
|
196
194
|
|
197
|
-
it
|
195
|
+
it 'refreshes the cached headers' do
|
198
196
|
driven_request.set_date
|
199
197
|
expect(driven_request.timestamp).to eq(timestamp)
|
200
198
|
end
|
201
199
|
end
|
202
200
|
|
203
|
-
describe
|
204
|
-
it
|
201
|
+
describe '#set_auth_header' do
|
202
|
+
it 'sets the auth header' do
|
205
203
|
driven_request.set_auth_header('APIAuth 1044:54321')
|
206
204
|
expect(request.env['Authorization']).to eq('APIAuth 1044:54321')
|
207
205
|
end
|
208
206
|
end
|
209
207
|
end
|
210
208
|
|
211
|
-
describe
|
212
|
-
context
|
209
|
+
describe 'md5_mismatch?' do
|
210
|
+
context 'when getting' do
|
213
211
|
let(:request) do
|
214
212
|
Rack::Request.new(
|
215
213
|
Rack::MockRequest.env_for(
|
@@ -219,12 +217,12 @@ describe ApiAuth::RequestDrivers::RackRequest do
|
|
219
217
|
)
|
220
218
|
end
|
221
219
|
|
222
|
-
it
|
220
|
+
it 'is false' do
|
223
221
|
expect(driven_request.md5_mismatch?).to be false
|
224
222
|
end
|
225
223
|
end
|
226
224
|
|
227
|
-
context
|
225
|
+
context 'when posting' do
|
228
226
|
let(:request) do
|
229
227
|
Rack::Request.new(
|
230
228
|
Rack::MockRequest.env_for(
|
@@ -235,28 +233,28 @@ describe ApiAuth::RequestDrivers::RackRequest do
|
|
235
233
|
)
|
236
234
|
end
|
237
235
|
|
238
|
-
context
|
236
|
+
context 'when calculated matches sent' do
|
239
237
|
before do
|
240
|
-
request.env[
|
238
|
+
request.env['Content-MD5'] = 'kZXQvrKoieG+Be1rsZVINw=='
|
241
239
|
end
|
242
240
|
|
243
|
-
it
|
241
|
+
it 'is false' do
|
244
242
|
expect(driven_request.md5_mismatch?).to be false
|
245
243
|
end
|
246
244
|
end
|
247
245
|
|
248
246
|
context "when calculated doesn't match sent" do
|
249
247
|
before do
|
250
|
-
request.env[
|
248
|
+
request.env['Content-MD5'] = '3'
|
251
249
|
end
|
252
250
|
|
253
|
-
it
|
251
|
+
it 'is true' do
|
254
252
|
expect(driven_request.md5_mismatch?).to be true
|
255
253
|
end
|
256
254
|
end
|
257
255
|
end
|
258
256
|
|
259
|
-
context
|
257
|
+
context 'when putting' do
|
260
258
|
let(:request) do
|
261
259
|
Rack::Request.new(
|
262
260
|
Rack::MockRequest.env_for(
|
@@ -267,28 +265,28 @@ describe ApiAuth::RequestDrivers::RackRequest do
|
|
267
265
|
)
|
268
266
|
end
|
269
267
|
|
270
|
-
context
|
268
|
+
context 'when calculated matches sent' do
|
271
269
|
before do
|
272
|
-
request.env[
|
270
|
+
request.env['Content-MD5'] = 'kZXQvrKoieG+Be1rsZVINw=='
|
273
271
|
end
|
274
272
|
|
275
|
-
it
|
273
|
+
it 'is false' do
|
276
274
|
expect(driven_request.md5_mismatch?).to be false
|
277
275
|
end
|
278
276
|
end
|
279
277
|
|
280
278
|
context "when calculated doesn't match sent" do
|
281
279
|
before do
|
282
|
-
request.env[
|
280
|
+
request.env['Content-MD5'] = '3'
|
283
281
|
end
|
284
282
|
|
285
|
-
it
|
283
|
+
it 'is true' do
|
286
284
|
expect(driven_request.md5_mismatch?).to be true
|
287
285
|
end
|
288
286
|
end
|
289
287
|
end
|
290
288
|
|
291
|
-
context
|
289
|
+
context 'when deleting' do
|
292
290
|
let(:request) do
|
293
291
|
Rack::Request.new(
|
294
292
|
Rack::MockRequest.env_for(
|
@@ -298,7 +296,7 @@ describe ApiAuth::RequestDrivers::RackRequest do
|
|
298
296
|
)
|
299
297
|
end
|
300
298
|
|
301
|
-
it
|
299
|
+
it 'is false' do
|
302
300
|
expect(driven_request.md5_mismatch?).to be false
|
303
301
|
end
|
304
302
|
end
|