pandexio 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +78 -78
- data/Rakefile +8 -8
- data/lib/pandexio.rb +155 -155
- data/lib/request.rb +24 -24
- 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 +296 -296
- data/test/test_query_string_signing.rb +368 -368
- metadata +7 -9
@@ -1,369 +1,369 @@
|
|
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 and email_address contains uppercase and lowercase characters" 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
|
-
end
|
78
|
-
|
79
|
-
it "returns the correct algorithm as a query parameter" do
|
80
|
-
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
81
|
-
end
|
82
|
-
it "returns the correct credential as a query parameter" do
|
83
|
-
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
84
|
-
end
|
85
|
-
it "returns the correct signed_headers value as a query parameter" do
|
86
|
-
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
87
|
-
end
|
88
|
-
it "returns the correct signature as a query parameter" do
|
89
|
-
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "6ab83c6a331ba2d684d2557f1e415f3aee86bee105da1f5ad1bc4cc1cdf42f1a"
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "when using query string signing mechanism and email_address contains only lowercase characters" do
|
95
|
-
|
96
|
-
before do
|
97
|
-
normalized_request = Pandexio::Request.new(
|
98
|
-
:method => "PUT",
|
99
|
-
:path => "/asdf/qwer/1234/title",
|
100
|
-
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
101
|
-
:headers => { "sample" => "example", "Host" => "localhost" },
|
102
|
-
:payload => "testing")
|
103
|
-
|
104
|
-
signing_options = Pandexio::SigningOptions.new(
|
105
|
-
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
106
|
-
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
107
|
-
:domain_id => "1234567890",
|
108
|
-
:domain_key => "asdfjklqwerzxcv",
|
109
|
-
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
110
|
-
:expires => 90,
|
111
|
-
:originator => "QueryStringSigningTest",
|
112
|
-
:email_address => "anonymous",
|
113
|
-
:display_name => "Anonymous")
|
114
|
-
|
115
|
-
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
116
|
-
end
|
117
|
-
|
118
|
-
it "returns the correct algorithm as a query parameter" do
|
119
|
-
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
120
|
-
end
|
121
|
-
it "returns the correct credential as a query parameter" do
|
122
|
-
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
123
|
-
end
|
124
|
-
it "returns the correct signed_headers value as a query parameter" do
|
125
|
-
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
126
|
-
end
|
127
|
-
it "returns the correct signature as a query parameter" do
|
128
|
-
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "4a8516231d42bf673e0660cebd81112f9540994856b2173daf2829b4897e3ada"
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
describe "when using query string signing mechanism and email_address contains only uppercase characters" do
|
134
|
-
|
135
|
-
before do
|
136
|
-
normalized_request = Pandexio::Request.new(
|
137
|
-
:method => "PUT",
|
138
|
-
:path => "/asdf/qwer/1234/title",
|
139
|
-
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
140
|
-
:headers => { "sample" => "example", "Host" => "localhost" },
|
141
|
-
:payload => "testing")
|
142
|
-
|
143
|
-
signing_options = Pandexio::SigningOptions.new(
|
144
|
-
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
145
|
-
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
146
|
-
:domain_id => "1234567890",
|
147
|
-
:domain_key => "asdfjklqwerzxcv",
|
148
|
-
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
149
|
-
:expires => 90,
|
150
|
-
:originator => "QueryStringSigningTest",
|
151
|
-
:email_address => "ANONYMOUS",
|
152
|
-
:display_name => "Anonymous")
|
153
|
-
|
154
|
-
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
155
|
-
end
|
156
|
-
|
157
|
-
it "returns the correct algorithm as a query parameter" do
|
158
|
-
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
159
|
-
end
|
160
|
-
it "returns the correct credential as a query parameter" do
|
161
|
-
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
162
|
-
end
|
163
|
-
it "returns the correct signed_headers value as a query parameter" do
|
164
|
-
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
165
|
-
end
|
166
|
-
it "returns the correct signature as a query parameter" do
|
167
|
-
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "8d549c05c925b92b609f9746be57acf944cdb13749de084d3d21daebb91b0c0a"
|
168
|
-
end
|
169
|
-
|
170
|
-
end
|
171
|
-
|
172
|
-
describe "when using query string signing mechanism and display_name contains spaces" do
|
173
|
-
|
174
|
-
before do
|
175
|
-
normalized_request = Pandexio::Request.new(
|
176
|
-
:method => "PUT",
|
177
|
-
:path => "/asdf/qwer/1234/title",
|
178
|
-
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
179
|
-
:headers => { "sample" => "example", "Host" => "localhost" },
|
180
|
-
:payload => "testing")
|
181
|
-
|
182
|
-
signing_options = Pandexio::SigningOptions.new(
|
183
|
-
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
184
|
-
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
185
|
-
:domain_id => "1234567890",
|
186
|
-
:domain_key => "asdfjklqwerzxcv",
|
187
|
-
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
188
|
-
:expires => 90,
|
189
|
-
:originator => "QueryStringSigningTest",
|
190
|
-
:email_address => "Anonymous",
|
191
|
-
:display_name => "A. Anonymous")
|
192
|
-
|
193
|
-
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
194
|
-
end
|
195
|
-
|
196
|
-
it "returns the correct algorithm as a query parameter" do
|
197
|
-
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
198
|
-
end
|
199
|
-
it "returns the correct credential as a query parameter" do
|
200
|
-
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
201
|
-
end
|
202
|
-
it "returns the correct signed_headers value as a query parameter" do
|
203
|
-
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
204
|
-
end
|
205
|
-
it "returns the correct signature as a query parameter" do
|
206
|
-
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "bcc1e6b33cd7f84316dc9cfd428a1d9161fd575de55d7e86008fb33664f43ac7"
|
207
|
-
end
|
208
|
-
|
209
|
-
end
|
210
|
-
|
211
|
-
describe "when using query string signing mechanism and display_name contains non-ASCII characters" do
|
212
|
-
|
213
|
-
before do
|
214
|
-
normalized_request = Pandexio::Request.new(
|
215
|
-
:method => "PUT",
|
216
|
-
:path => "/asdf/qwer/1234/title",
|
217
|
-
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
218
|
-
:headers => { "sample" => "example", "Host" => "localhost" },
|
219
|
-
:payload => "testing")
|
220
|
-
|
221
|
-
signing_options = Pandexio::SigningOptions.new(
|
222
|
-
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
223
|
-
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
224
|
-
:domain_id => "1234567890",
|
225
|
-
:domain_key => "asdfjklqwerzxcv",
|
226
|
-
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
227
|
-
:expires => 90,
|
228
|
-
:originator => "QueryStringSigningTest",
|
229
|
-
:email_address => "Anonymous",
|
230
|
-
:display_name => "á Anonymous")
|
231
|
-
|
232
|
-
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
233
|
-
end
|
234
|
-
|
235
|
-
it "returns the correct algorithm as a query parameter" do
|
236
|
-
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
237
|
-
end
|
238
|
-
it "returns the correct credential as a query parameter" do
|
239
|
-
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
240
|
-
end
|
241
|
-
it "returns the correct signed_headers value as a query parameter" do
|
242
|
-
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
243
|
-
end
|
244
|
-
it "returns the correct signature as a query parameter" do
|
245
|
-
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "1f008f205bff02f7a62c2bf9f630f9506c794524f51a37ce4140c1587ad90616"
|
246
|
-
end
|
247
|
-
|
248
|
-
end
|
249
|
-
|
250
|
-
describe "when using query string signing mechanism and path contains spaces" do
|
251
|
-
|
252
|
-
before do
|
253
|
-
normalized_request = Pandexio::Request.new(
|
254
|
-
:method => "PUT",
|
255
|
-
:path => "/asdf/qwer/1234/title and description",
|
256
|
-
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
257
|
-
:headers => { "sample" => "example", "Host" => "localhost" },
|
258
|
-
:payload => "testing")
|
259
|
-
|
260
|
-
signing_options = Pandexio::SigningOptions.new(
|
261
|
-
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
262
|
-
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
263
|
-
:domain_id => "1234567890",
|
264
|
-
:domain_key => "asdfjklqwerzxcv",
|
265
|
-
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
266
|
-
:expires => 90,
|
267
|
-
:originator => "QueryStringSigningTest",
|
268
|
-
:email_address => "Anonymous",
|
269
|
-
:display_name => "Anonymous")
|
270
|
-
|
271
|
-
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
272
|
-
end
|
273
|
-
|
274
|
-
it "returns the correct algorithm as a query parameter" do
|
275
|
-
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
276
|
-
end
|
277
|
-
it "returns the correct credential as a query parameter" do
|
278
|
-
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
279
|
-
end
|
280
|
-
it "returns the correct signed_headers value as a query parameter" do
|
281
|
-
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
282
|
-
end
|
283
|
-
it "returns the correct signature as a query parameter" do
|
284
|
-
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "9cbd539d41fe31394b11b848970cc127b514dadb9d52223c4dcab5089a86ae44"
|
285
|
-
end
|
286
|
-
|
287
|
-
end
|
288
|
-
|
289
|
-
describe "when using query string signing mechanism and payload contains non-ASCII characters" do
|
290
|
-
|
291
|
-
before do
|
292
|
-
normalized_request = Pandexio::Request.new(
|
293
|
-
:method => "PUT",
|
294
|
-
:path => "/asdf/qwer/1234/title",
|
295
|
-
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
296
|
-
:headers => { "sample" => "example", "Host" => "localhost" },
|
297
|
-
:payload => "testing á")
|
298
|
-
|
299
|
-
signing_options = Pandexio::SigningOptions.new(
|
300
|
-
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
301
|
-
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
302
|
-
:domain_id => "1234567890",
|
303
|
-
:domain_key => "asdfjklqwerzxcv",
|
304
|
-
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
305
|
-
:expires => 90,
|
306
|
-
:originator => "QueryStringSigningTest",
|
307
|
-
:email_address => "Anonymous",
|
308
|
-
:display_name => "Anonymous")
|
309
|
-
|
310
|
-
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
311
|
-
end
|
312
|
-
|
313
|
-
it "returns the correct algorithm as a query parameter" do
|
314
|
-
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
315
|
-
end
|
316
|
-
it "returns the correct credential as a query parameter" do
|
317
|
-
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
318
|
-
end
|
319
|
-
it "returns the correct signed_headers value as a query parameter" do
|
320
|
-
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
321
|
-
end
|
322
|
-
it "returns the correct signature as a query parameter" do
|
323
|
-
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "5155764a11094d8bfe4ebca3b0c87e8547636bd5391948fd2f2f2afa634ffabb"
|
324
|
-
end
|
325
|
-
|
326
|
-
end
|
327
|
-
|
328
|
-
describe "when using query string signing mechanism and attributes include profile image" do
|
329
|
-
|
330
|
-
before do
|
331
|
-
normalized_request = Pandexio::Request.new(
|
332
|
-
:method => "PUT",
|
333
|
-
:path => "/asdf/qwer/1234/title",
|
334
|
-
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
335
|
-
:headers => { "sample" => "example", "Host" => "localhost" },
|
336
|
-
:payload => "testing")
|
337
|
-
|
338
|
-
signing_options = Pandexio::SigningOptions.new(
|
339
|
-
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
340
|
-
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
341
|
-
:domain_id => "1234567890",
|
342
|
-
:domain_key => "asdfjklqwerzxcv",
|
343
|
-
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
344
|
-
:expires => 90,
|
345
|
-
:originator => "QueryStringSigningTest",
|
346
|
-
:email_address => "Anonymous",
|
347
|
-
:display_name => "Anonymous",
|
348
|
-
:profile_image => "abcdefg")
|
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 "ead72d2e09c2a74b9712178f43eb68eed1c3877b206b221507eb8a1a82b67c77"
|
364
|
-
end
|
365
|
-
|
366
|
-
end
|
367
|
-
|
368
|
-
end
|
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 and email_address contains uppercase and lowercase characters" 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
|
+
end
|
78
|
+
|
79
|
+
it "returns the correct algorithm as a query parameter" do
|
80
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
81
|
+
end
|
82
|
+
it "returns the correct credential as a query parameter" do
|
83
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
84
|
+
end
|
85
|
+
it "returns the correct signed_headers value as a query parameter" do
|
86
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
87
|
+
end
|
88
|
+
it "returns the correct signature as a query parameter" do
|
89
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "6ab83c6a331ba2d684d2557f1e415f3aee86bee105da1f5ad1bc4cc1cdf42f1a"
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "when using query string signing mechanism and email_address contains only lowercase characters" do
|
95
|
+
|
96
|
+
before do
|
97
|
+
normalized_request = Pandexio::Request.new(
|
98
|
+
:method => "PUT",
|
99
|
+
:path => "/asdf/qwer/1234/title",
|
100
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
101
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
102
|
+
:payload => "testing")
|
103
|
+
|
104
|
+
signing_options = Pandexio::SigningOptions.new(
|
105
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
106
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
107
|
+
:domain_id => "1234567890",
|
108
|
+
:domain_key => "asdfjklqwerzxcv",
|
109
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
110
|
+
:expires => 90,
|
111
|
+
:originator => "QueryStringSigningTest",
|
112
|
+
:email_address => "anonymous",
|
113
|
+
:display_name => "Anonymous")
|
114
|
+
|
115
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "returns the correct algorithm as a query parameter" do
|
119
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
120
|
+
end
|
121
|
+
it "returns the correct credential as a query parameter" do
|
122
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
123
|
+
end
|
124
|
+
it "returns the correct signed_headers value as a query parameter" do
|
125
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
126
|
+
end
|
127
|
+
it "returns the correct signature as a query parameter" do
|
128
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "4a8516231d42bf673e0660cebd81112f9540994856b2173daf2829b4897e3ada"
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "when using query string signing mechanism and email_address contains only uppercase characters" do
|
134
|
+
|
135
|
+
before do
|
136
|
+
normalized_request = Pandexio::Request.new(
|
137
|
+
:method => "PUT",
|
138
|
+
:path => "/asdf/qwer/1234/title",
|
139
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
140
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
141
|
+
:payload => "testing")
|
142
|
+
|
143
|
+
signing_options = Pandexio::SigningOptions.new(
|
144
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
145
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
146
|
+
:domain_id => "1234567890",
|
147
|
+
:domain_key => "asdfjklqwerzxcv",
|
148
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
149
|
+
:expires => 90,
|
150
|
+
:originator => "QueryStringSigningTest",
|
151
|
+
:email_address => "ANONYMOUS",
|
152
|
+
:display_name => "Anonymous")
|
153
|
+
|
154
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "returns the correct algorithm as a query parameter" do
|
158
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
159
|
+
end
|
160
|
+
it "returns the correct credential as a query parameter" do
|
161
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
162
|
+
end
|
163
|
+
it "returns the correct signed_headers value as a query parameter" do
|
164
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
165
|
+
end
|
166
|
+
it "returns the correct signature as a query parameter" do
|
167
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "8d549c05c925b92b609f9746be57acf944cdb13749de084d3d21daebb91b0c0a"
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
describe "when using query string signing mechanism and display_name contains spaces" do
|
173
|
+
|
174
|
+
before do
|
175
|
+
normalized_request = Pandexio::Request.new(
|
176
|
+
:method => "PUT",
|
177
|
+
:path => "/asdf/qwer/1234/title",
|
178
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
179
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
180
|
+
:payload => "testing")
|
181
|
+
|
182
|
+
signing_options = Pandexio::SigningOptions.new(
|
183
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
184
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
185
|
+
:domain_id => "1234567890",
|
186
|
+
:domain_key => "asdfjklqwerzxcv",
|
187
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
188
|
+
:expires => 90,
|
189
|
+
:originator => "QueryStringSigningTest",
|
190
|
+
:email_address => "Anonymous",
|
191
|
+
:display_name => "A. Anonymous")
|
192
|
+
|
193
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
194
|
+
end
|
195
|
+
|
196
|
+
it "returns the correct algorithm as a query parameter" do
|
197
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
198
|
+
end
|
199
|
+
it "returns the correct credential as a query parameter" do
|
200
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
201
|
+
end
|
202
|
+
it "returns the correct signed_headers value as a query parameter" do
|
203
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
204
|
+
end
|
205
|
+
it "returns the correct signature as a query parameter" do
|
206
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "bcc1e6b33cd7f84316dc9cfd428a1d9161fd575de55d7e86008fb33664f43ac7"
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
describe "when using query string signing mechanism and display_name contains non-ASCII characters" do
|
212
|
+
|
213
|
+
before do
|
214
|
+
normalized_request = Pandexio::Request.new(
|
215
|
+
:method => "PUT",
|
216
|
+
:path => "/asdf/qwer/1234/title",
|
217
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
218
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
219
|
+
:payload => "testing")
|
220
|
+
|
221
|
+
signing_options = Pandexio::SigningOptions.new(
|
222
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
223
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
224
|
+
:domain_id => "1234567890",
|
225
|
+
:domain_key => "asdfjklqwerzxcv",
|
226
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
227
|
+
:expires => 90,
|
228
|
+
:originator => "QueryStringSigningTest",
|
229
|
+
:email_address => "Anonymous",
|
230
|
+
:display_name => "á Anonymous")
|
231
|
+
|
232
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
233
|
+
end
|
234
|
+
|
235
|
+
it "returns the correct algorithm as a query parameter" do
|
236
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
237
|
+
end
|
238
|
+
it "returns the correct credential as a query parameter" do
|
239
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
240
|
+
end
|
241
|
+
it "returns the correct signed_headers value as a query parameter" do
|
242
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
243
|
+
end
|
244
|
+
it "returns the correct signature as a query parameter" do
|
245
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "1f008f205bff02f7a62c2bf9f630f9506c794524f51a37ce4140c1587ad90616"
|
246
|
+
end
|
247
|
+
|
248
|
+
end
|
249
|
+
|
250
|
+
describe "when using query string signing mechanism and path contains spaces" do
|
251
|
+
|
252
|
+
before do
|
253
|
+
normalized_request = Pandexio::Request.new(
|
254
|
+
:method => "PUT",
|
255
|
+
:path => "/asdf/qwer/1234/title and description",
|
256
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
257
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
258
|
+
:payload => "testing")
|
259
|
+
|
260
|
+
signing_options = Pandexio::SigningOptions.new(
|
261
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
262
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
263
|
+
:domain_id => "1234567890",
|
264
|
+
:domain_key => "asdfjklqwerzxcv",
|
265
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
266
|
+
:expires => 90,
|
267
|
+
:originator => "QueryStringSigningTest",
|
268
|
+
:email_address => "Anonymous",
|
269
|
+
:display_name => "Anonymous")
|
270
|
+
|
271
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
272
|
+
end
|
273
|
+
|
274
|
+
it "returns the correct algorithm as a query parameter" do
|
275
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
276
|
+
end
|
277
|
+
it "returns the correct credential as a query parameter" do
|
278
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
279
|
+
end
|
280
|
+
it "returns the correct signed_headers value as a query parameter" do
|
281
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
282
|
+
end
|
283
|
+
it "returns the correct signature as a query parameter" do
|
284
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "9cbd539d41fe31394b11b848970cc127b514dadb9d52223c4dcab5089a86ae44"
|
285
|
+
end
|
286
|
+
|
287
|
+
end
|
288
|
+
|
289
|
+
describe "when using query string signing mechanism and payload contains non-ASCII characters" do
|
290
|
+
|
291
|
+
before do
|
292
|
+
normalized_request = Pandexio::Request.new(
|
293
|
+
:method => "PUT",
|
294
|
+
:path => "/asdf/qwer/1234/title",
|
295
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
296
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
297
|
+
:payload => "testing á")
|
298
|
+
|
299
|
+
signing_options = Pandexio::SigningOptions.new(
|
300
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
301
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
302
|
+
:domain_id => "1234567890",
|
303
|
+
:domain_key => "asdfjklqwerzxcv",
|
304
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
305
|
+
:expires => 90,
|
306
|
+
:originator => "QueryStringSigningTest",
|
307
|
+
:email_address => "Anonymous",
|
308
|
+
:display_name => "Anonymous")
|
309
|
+
|
310
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
311
|
+
end
|
312
|
+
|
313
|
+
it "returns the correct algorithm as a query parameter" do
|
314
|
+
@authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
|
315
|
+
end
|
316
|
+
it "returns the correct credential as a query parameter" do
|
317
|
+
@authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
|
318
|
+
end
|
319
|
+
it "returns the correct signed_headers value as a query parameter" do
|
320
|
+
@authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
|
321
|
+
end
|
322
|
+
it "returns the correct signature as a query parameter" do
|
323
|
+
@authorized_request.query_parameters["X-Pdx-Signature"].must_equal "5155764a11094d8bfe4ebca3b0c87e8547636bd5391948fd2f2f2afa634ffabb"
|
324
|
+
end
|
325
|
+
|
326
|
+
end
|
327
|
+
|
328
|
+
describe "when using query string signing mechanism and attributes include profile image" do
|
329
|
+
|
330
|
+
before do
|
331
|
+
normalized_request = Pandexio::Request.new(
|
332
|
+
:method => "PUT",
|
333
|
+
:path => "/asdf/qwer/1234/title",
|
334
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
335
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
336
|
+
:payload => "testing")
|
337
|
+
|
338
|
+
signing_options = Pandexio::SigningOptions.new(
|
339
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
340
|
+
:mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
|
341
|
+
:domain_id => "1234567890",
|
342
|
+
:domain_key => "asdfjklqwerzxcv",
|
343
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
344
|
+
:expires => 90,
|
345
|
+
:originator => "QueryStringSigningTest",
|
346
|
+
:email_address => "Anonymous",
|
347
|
+
:display_name => "Anonymous",
|
348
|
+
:profile_image => "abcdefg")
|
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 "ead72d2e09c2a74b9712178f43eb68eed1c3877b206b221507eb8a1a82b67c77"
|
364
|
+
end
|
365
|
+
|
366
|
+
end
|
367
|
+
|
368
|
+
end
|
369
369
|
end
|