pandexio 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- 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 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