pandexio 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +78 -78
- data/Rakefile +8 -8
- data/lib/pandexio.rb +14 -155
- data/lib/request.rb +24 -24
- data/lib/scope.rb +13 -0
- data/lib/scope_patterns.rb +7 -0
- data/lib/signer.rb +192 -0
- data/lib/signing_algorithms.rb +36 -36
- data/lib/signing_attributes.rb +21 -21
- data/lib/signing_mechanisms.rb +16 -16
- data/lib/signing_options.rb +29 -29
- data/test/test_header_signing.rb +327 -296
- data/test/test_query_string_signing.rb +408 -368
- data/test/test_scope.rb +37 -0
- data/test/test_scope_patterns.rb +56 -0
- data/test/test_signer.rb +112 -0
- metadata +15 -7
- checksums.yaml +0 -7
@@ -1,369 +1,409 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
require_relative '../lib/pandexio.rb'
|
5
|
-
|
6
|
-
describe Pandexio do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require_relative '../lib/pandexio.rb'
|
5
|
+
|
6
|
+
describe Pandexio do
|
7
|
+
describe "#to_authorized_request" do
|
8
|
+
|
9
|
+
describe "when using query string signing mechanism to generate a new authorized_request from a given normalized_request" do
|
10
|
+
|
11
|
+
before do
|
12
|
+
@normalized_request = Pandexio::Request.new(
|
13
|
+
:method => "PUT",
|
14
|
+
:path => "/asdf/qwer/1234/title",
|
15
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
16
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
17
|
+
:payload => "testing")
|
18
|
+
|
19
|
+
signing_options = Pandexio::SigningOptions.new(
|
20
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
21
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
22
|
+
:domain_id => "1234567890",
|
23
|
+
:domain_key => "asdfjklqwerzxcv",
|
24
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
25
|
+
:expires => 90,
|
26
|
+
:originator => "QueryStringSigningTest",
|
27
|
+
:email_address => "Anonymous",
|
28
|
+
:display_name => "Anonymous")
|
29
|
+
|
30
|
+
@authorized_request = Pandexio::to_authorized_request(@normalized_request, signing_options)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "does not modify the normalized_request method" do
|
34
|
+
@normalized_request.method.must_equal "PUT"
|
35
|
+
end
|
36
|
+
it "does not modify the normalized_request path" do
|
37
|
+
@normalized_request.path.must_equal "/asdf/qwer/1234/title"
|
38
|
+
end
|
39
|
+
it "does not modify the normalized_request query_parameters" do
|
40
|
+
@normalized_request.query_parameters.count.must_equal 2
|
41
|
+
@normalized_request.query_parameters["nonce"].must_equal "987654321"
|
42
|
+
@normalized_request.query_parameters["Baseline"].must_equal "5"
|
43
|
+
end
|
44
|
+
it "does not modify the normalized_request headers" do
|
45
|
+
@normalized_request.headers.count.must_equal 2
|
46
|
+
@normalized_request.headers["sample"].must_equal "example"
|
47
|
+
@normalized_request.headers["Host"].must_equal "localhost"
|
48
|
+
end
|
49
|
+
it "does not modify the normalized_request payload" do
|
50
|
+
@normalized_request.payload.must_equal "testing"
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "when using query string signing mechanism to sign an authorized_request" do
|
56
|
+
|
57
|
+
before do
|
58
|
+
normalized_request = Pandexio::Request.new(
|
59
|
+
:method => "PUT",
|
60
|
+
:path => "/asdf/qwer/1234/title",
|
61
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
62
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
63
|
+
:payload => "testing")
|
64
|
+
|
65
|
+
signing_options = Pandexio::SigningOptions.new(
|
66
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
67
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
68
|
+
:domain_id => "1234567890",
|
69
|
+
:domain_key => "asdfjklqwerzxcv",
|
70
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
71
|
+
:expires => 90,
|
72
|
+
:originator => "QueryStringSigningTest",
|
73
|
+
:email_address => "Anonymous",
|
74
|
+
:display_name => "Anonymous")
|
75
|
+
|
76
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
77
|
+
@authorized_request = Pandexio::to_authorized_request(@authorized_request, signing_options)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "returns the correct algorithm as a query parameter" do
|
81
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
82
|
+
end
|
83
|
+
it "returns the correct credential as a query parameter" do
|
84
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
85
|
+
end
|
86
|
+
it "returns the correct signed_headers value as a query parameter" do
|
87
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
88
|
+
end
|
89
|
+
it "returns the correct signature as a query parameter" do
|
90
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "6ab83c6a331ba2d684d2557f1e415f3aee86bee105da1f5ad1bc4cc1cdf42f1a"
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "when using query string signing mechanism and email_address contains uppercase and lowercase characters" do
|
96
|
+
|
97
|
+
before do
|
98
|
+
normalized_request = Pandexio::Request.new(
|
99
|
+
:method => "PUT",
|
100
|
+
:path => "/asdf/qwer/1234/title",
|
101
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
102
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
103
|
+
:payload => "testing")
|
104
|
+
|
105
|
+
signing_options = Pandexio::SigningOptions.new(
|
106
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
107
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
108
|
+
:domain_id => "1234567890",
|
109
|
+
:domain_key => "asdfjklqwerzxcv",
|
110
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
111
|
+
:expires => 90,
|
112
|
+
:originator => "QueryStringSigningTest",
|
113
|
+
:email_address => "Anonymous",
|
114
|
+
:display_name => "Anonymous")
|
115
|
+
|
116
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "returns the correct algorithm as a query parameter" do
|
120
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
121
|
+
end
|
122
|
+
it "returns the correct credential as a query parameter" do
|
123
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
124
|
+
end
|
125
|
+
it "returns the correct signed_headers value as a query parameter" do
|
126
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
127
|
+
end
|
128
|
+
it "returns the correct signature as a query parameter" do
|
129
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "6ab83c6a331ba2d684d2557f1e415f3aee86bee105da1f5ad1bc4cc1cdf42f1a"
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "when using query string signing mechanism and email_address contains only lowercase characters" do
|
135
|
+
|
136
|
+
before do
|
137
|
+
normalized_request = Pandexio::Request.new(
|
138
|
+
:method => "PUT",
|
139
|
+
:path => "/asdf/qwer/1234/title",
|
140
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
141
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
142
|
+
:payload => "testing")
|
143
|
+
|
144
|
+
signing_options = Pandexio::SigningOptions.new(
|
145
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
146
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
147
|
+
:domain_id => "1234567890",
|
148
|
+
:domain_key => "asdfjklqwerzxcv",
|
149
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
150
|
+
:expires => 90,
|
151
|
+
:originator => "QueryStringSigningTest",
|
152
|
+
:email_address => "anonymous",
|
153
|
+
:display_name => "Anonymous")
|
154
|
+
|
155
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
156
|
+
end
|
157
|
+
|
158
|
+
it "returns the correct algorithm as a query parameter" do
|
159
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
160
|
+
end
|
161
|
+
it "returns the correct credential as a query parameter" do
|
162
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
163
|
+
end
|
164
|
+
it "returns the correct signed_headers value as a query parameter" do
|
165
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
166
|
+
end
|
167
|
+
it "returns the correct signature as a query parameter" do
|
168
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "4a8516231d42bf673e0660cebd81112f9540994856b2173daf2829b4897e3ada"
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
describe "when using query string signing mechanism and email_address contains only uppercase characters" do
|
174
|
+
|
175
|
+
before do
|
176
|
+
normalized_request = Pandexio::Request.new(
|
177
|
+
:method => "PUT",
|
178
|
+
:path => "/asdf/qwer/1234/title",
|
179
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
180
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
181
|
+
:payload => "testing")
|
182
|
+
|
183
|
+
signing_options = Pandexio::SigningOptions.new(
|
184
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
185
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
186
|
+
:domain_id => "1234567890",
|
187
|
+
:domain_key => "asdfjklqwerzxcv",
|
188
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
189
|
+
:expires => 90,
|
190
|
+
:originator => "QueryStringSigningTest",
|
191
|
+
:email_address => "ANONYMOUS",
|
192
|
+
:display_name => "Anonymous")
|
193
|
+
|
194
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
195
|
+
end
|
196
|
+
|
197
|
+
it "returns the correct algorithm as a query parameter" do
|
198
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
199
|
+
end
|
200
|
+
it "returns the correct credential as a query parameter" do
|
201
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
202
|
+
end
|
203
|
+
it "returns the correct signed_headers value as a query parameter" do
|
204
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
205
|
+
end
|
206
|
+
it "returns the correct signature as a query parameter" do
|
207
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "8d549c05c925b92b609f9746be57acf944cdb13749de084d3d21daebb91b0c0a"
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
describe "when using query string signing mechanism and display_name contains spaces" do
|
213
|
+
|
214
|
+
before do
|
215
|
+
normalized_request = Pandexio::Request.new(
|
216
|
+
:method => "PUT",
|
217
|
+
:path => "/asdf/qwer/1234/title",
|
218
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
219
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
220
|
+
:payload => "testing")
|
221
|
+
|
222
|
+
signing_options = Pandexio::SigningOptions.new(
|
223
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
224
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
225
|
+
:domain_id => "1234567890",
|
226
|
+
:domain_key => "asdfjklqwerzxcv",
|
227
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
228
|
+
:expires => 90,
|
229
|
+
:originator => "QueryStringSigningTest",
|
230
|
+
:email_address => "Anonymous",
|
231
|
+
:display_name => "A. Anonymous")
|
232
|
+
|
233
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
234
|
+
end
|
235
|
+
|
236
|
+
it "returns the correct algorithm as a query parameter" do
|
237
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
238
|
+
end
|
239
|
+
it "returns the correct credential as a query parameter" do
|
240
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
241
|
+
end
|
242
|
+
it "returns the correct signed_headers value as a query parameter" do
|
243
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
244
|
+
end
|
245
|
+
it "returns the correct signature as a query parameter" do
|
246
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "bcc1e6b33cd7f84316dc9cfd428a1d9161fd575de55d7e86008fb33664f43ac7"
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
250
|
+
|
251
|
+
describe "when using query string signing mechanism and display_name contains non-ASCII characters" do
|
252
|
+
|
253
|
+
before do
|
254
|
+
normalized_request = Pandexio::Request.new(
|
255
|
+
:method => "PUT",
|
256
|
+
:path => "/asdf/qwer/1234/title",
|
257
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
258
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
259
|
+
:payload => "testing")
|
260
|
+
|
261
|
+
signing_options = Pandexio::SigningOptions.new(
|
262
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
263
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
264
|
+
:domain_id => "1234567890",
|
265
|
+
:domain_key => "asdfjklqwerzxcv",
|
266
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
267
|
+
:expires => 90,
|
268
|
+
:originator => "QueryStringSigningTest",
|
269
|
+
:email_address => "Anonymous",
|
270
|
+
:display_name => "á Anonymous")
|
271
|
+
|
272
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
273
|
+
end
|
274
|
+
|
275
|
+
it "returns the correct algorithm as a query parameter" do
|
276
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
277
|
+
end
|
278
|
+
it "returns the correct credential as a query parameter" do
|
279
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
280
|
+
end
|
281
|
+
it "returns the correct signed_headers value as a query parameter" do
|
282
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
283
|
+
end
|
284
|
+
it "returns the correct signature as a query parameter" do
|
285
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "1f008f205bff02f7a62c2bf9f630f9506c794524f51a37ce4140c1587ad90616"
|
286
|
+
end
|
287
|
+
|
288
|
+
end
|
289
|
+
|
290
|
+
describe "when using query string signing mechanism and path contains spaces" do
|
291
|
+
|
292
|
+
before do
|
293
|
+
normalized_request = Pandexio::Request.new(
|
294
|
+
:method => "PUT",
|
295
|
+
:path => "/asdf/qwer/1234/title and description",
|
296
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
297
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
298
|
+
:payload => "testing")
|
299
|
+
|
300
|
+
signing_options = Pandexio::SigningOptions.new(
|
301
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
302
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
303
|
+
:domain_id => "1234567890",
|
304
|
+
:domain_key => "asdfjklqwerzxcv",
|
305
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
306
|
+
:expires => 90,
|
307
|
+
:originator => "QueryStringSigningTest",
|
308
|
+
:email_address => "Anonymous",
|
309
|
+
:display_name => "Anonymous")
|
310
|
+
|
311
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
312
|
+
end
|
313
|
+
|
314
|
+
it "returns the correct algorithm as a query parameter" do
|
315
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
316
|
+
end
|
317
|
+
it "returns the correct credential as a query parameter" do
|
318
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
319
|
+
end
|
320
|
+
it "returns the correct signed_headers value as a query parameter" do
|
321
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
322
|
+
end
|
323
|
+
it "returns the correct signature as a query parameter" do
|
324
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "9cbd539d41fe31394b11b848970cc127b514dadb9d52223c4dcab5089a86ae44"
|
325
|
+
end
|
326
|
+
|
327
|
+
end
|
328
|
+
|
329
|
+
describe "when using query string signing mechanism and payload contains non-ASCII characters" do
|
330
|
+
|
331
|
+
before do
|
332
|
+
normalized_request = Pandexio::Request.new(
|
333
|
+
:method => "PUT",
|
334
|
+
:path => "/asdf/qwer/1234/title",
|
335
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
336
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
337
|
+
:payload => "testing á")
|
338
|
+
|
339
|
+
signing_options = Pandexio::SigningOptions.new(
|
340
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
341
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
342
|
+
:domain_id => "1234567890",
|
343
|
+
:domain_key => "asdfjklqwerzxcv",
|
344
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
345
|
+
:expires => 90,
|
346
|
+
:originator => "QueryStringSigningTest",
|
347
|
+
:email_address => "Anonymous",
|
348
|
+
:display_name => "Anonymous")
|
349
|
+
|
350
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
351
|
+
end
|
352
|
+
|
353
|
+
it "returns the correct algorithm as a query parameter" do
|
354
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
355
|
+
end
|
356
|
+
it "returns the correct credential as a query parameter" do
|
357
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
358
|
+
end
|
359
|
+
it "returns the correct signed_headers value as a query parameter" do
|
360
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
361
|
+
end
|
362
|
+
it "returns the correct signature as a query parameter" do
|
363
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "5155764a11094d8bfe4ebca3b0c87e8547636bd5391948fd2f2f2afa634ffabb"
|
364
|
+
end
|
365
|
+
|
366
|
+
end
|
367
|
+
|
368
|
+
describe "when using query string signing mechanism and attributes include profile image" do
|
369
|
+
|
370
|
+
before do
|
371
|
+
normalized_request = Pandexio::Request.new(
|
372
|
+
:method => "PUT",
|
373
|
+
:path => "/asdf/qwer/1234/title",
|
374
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
375
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
376
|
+
:payload => "testing")
|
377
|
+
|
378
|
+
signing_options = Pandexio::SigningOptions.new(
|
379
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
380
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
381
|
+
:domain_id => "1234567890",
|
382
|
+
:domain_key => "asdfjklqwerzxcv",
|
383
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
384
|
+
:expires => 90,
|
385
|
+
:originator => "QueryStringSigningTest",
|
386
|
+
:email_address => "Anonymous",
|
387
|
+
:display_name => "Anonymous",
|
388
|
+
:profile_image => "abcdefg")
|
389
|
+
|
390
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
391
|
+
end
|
392
|
+
|
393
|
+
it "returns the correct algorithm as a query parameter" do
|
394
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
395
|
+
end
|
396
|
+
it "returns the correct credential as a query parameter" do
|
397
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
398
|
+
end
|
399
|
+
it "returns the correct signed_headers value as a query parameter" do
|
400
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
401
|
+
end
|
402
|
+
it "returns the correct signature as a query parameter" do
|
403
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "ead72d2e09c2a74b9712178f43eb68eed1c3877b206b221507eb8a1a82b67c77"
|
404
|
+
end
|
405
|
+
|
406
|
+
end
|
407
|
+
|
408
|
+
end
|
369
409
|
end
|