pandexio 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,321 +1,323 @@
1
- require 'minitest/autorun'
2
- require_relative '../lib/pandexio.rb'
3
-
4
- describe Pandexio do
5
- describe "#to_authorized_request" do
6
-
7
- describe "when using query string signing mechanism and email_address contains uppercase and lowercase characters" do
8
-
9
- before do
10
- normalized_request = Pandexio::Request.new(
11
- :method => "PUT",
12
- :path => "/asdf/qwer/1234/title",
13
- :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
14
- :headers => { "sample" => "example", "Host" => "localhost" },
15
- :payload => "testing")
16
-
17
- signing_options = Pandexio::SigningOptions.new(
18
- :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
19
- :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
20
- :domain_id => "1234567890",
21
- :domain_key => "asdfjklqwerzxcv",
22
- :date => Time.utc(2014, 11, 21, 13, 43, 15),
23
- :expires => 90,
24
- :originator => "QueryStringSigningTest",
25
- :email_address => "Anonymous",
26
- :display_name => "Anonymous")
27
-
28
- @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
29
- end
30
-
31
- it "returns the correct algorithm as a query parameter" do
32
- @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
33
- end
34
- it "returns the correct credential as a query parameter" do
35
- @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
36
- end
37
- it "returns the correct signed_headers value as a query parameter" do
38
- @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
39
- end
40
- it "returns the correct signature as a query parameter" do
41
- @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "6ab83c6a331ba2d684d2557f1e415f3aee86bee105da1f5ad1bc4cc1cdf42f1a"
42
- end
43
-
44
- end
45
-
46
- describe "when using query string signing mechanism and email_address contains only lowercase characters" do
47
-
48
- before do
49
- normalized_request = Pandexio::Request.new(
50
- :method => "PUT",
51
- :path => "/asdf/qwer/1234/title",
52
- :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
53
- :headers => { "sample" => "example", "Host" => "localhost" },
54
- :payload => "testing")
55
-
56
- signing_options = Pandexio::SigningOptions.new(
57
- :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
58
- :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
59
- :domain_id => "1234567890",
60
- :domain_key => "asdfjklqwerzxcv",
61
- :date => Time.utc(2014, 11, 21, 13, 43, 15),
62
- :expires => 90,
63
- :originator => "QueryStringSigningTest",
64
- :email_address => "anonymous",
65
- :display_name => "Anonymous")
66
-
67
- @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
68
- end
69
-
70
- it "returns the correct algorithm as a query parameter" do
71
- @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
72
- end
73
- it "returns the correct credential as a query parameter" do
74
- @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
75
- end
76
- it "returns the correct signed_headers value as a query parameter" do
77
- @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
78
- end
79
- it "returns the correct signature as a query parameter" do
80
- @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "4a8516231d42bf673e0660cebd81112f9540994856b2173daf2829b4897e3ada"
81
- end
82
-
83
- end
84
-
85
- describe "when using query string signing mechanism and email_address contains only uppercase characters" do
86
-
87
- before do
88
- normalized_request = Pandexio::Request.new(
89
- :method => "PUT",
90
- :path => "/asdf/qwer/1234/title",
91
- :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
92
- :headers => { "sample" => "example", "Host" => "localhost" },
93
- :payload => "testing")
94
-
95
- signing_options = Pandexio::SigningOptions.new(
96
- :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
97
- :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
98
- :domain_id => "1234567890",
99
- :domain_key => "asdfjklqwerzxcv",
100
- :date => Time.utc(2014, 11, 21, 13, 43, 15),
101
- :expires => 90,
102
- :originator => "QueryStringSigningTest",
103
- :email_address => "ANONYMOUS",
104
- :display_name => "Anonymous")
105
-
106
- @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
107
- end
108
-
109
- it "returns the correct algorithm as a query parameter" do
110
- @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
111
- end
112
- it "returns the correct credential as a query parameter" do
113
- @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
114
- end
115
- it "returns the correct signed_headers value as a query parameter" do
116
- @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
117
- end
118
- it "returns the correct signature as a query parameter" do
119
- @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "8d549c05c925b92b609f9746be57acf944cdb13749de084d3d21daebb91b0c0a"
120
- end
121
-
122
- end
123
-
124
- describe "when using query string signing mechanism and display_name contains spaces" do
125
-
126
- before do
127
- normalized_request = Pandexio::Request.new(
128
- :method => "PUT",
129
- :path => "/asdf/qwer/1234/title",
130
- :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
131
- :headers => { "sample" => "example", "Host" => "localhost" },
132
- :payload => "testing")
133
-
134
- signing_options = Pandexio::SigningOptions.new(
135
- :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
136
- :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
137
- :domain_id => "1234567890",
138
- :domain_key => "asdfjklqwerzxcv",
139
- :date => Time.utc(2014, 11, 21, 13, 43, 15),
140
- :expires => 90,
141
- :originator => "QueryStringSigningTest",
142
- :email_address => "Anonymous",
143
- :display_name => "A. Anonymous")
144
-
145
- @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
146
- end
147
-
148
- it "returns the correct algorithm as a query parameter" do
149
- @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
150
- end
151
- it "returns the correct credential as a query parameter" do
152
- @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
153
- end
154
- it "returns the correct signed_headers value as a query parameter" do
155
- @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
156
- end
157
- it "returns the correct signature as a query parameter" do
158
- @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "bcc1e6b33cd7f84316dc9cfd428a1d9161fd575de55d7e86008fb33664f43ac7"
159
- end
160
-
161
- end
162
-
163
- describe "when using query string signing mechanism and display_name contains non-ASCII characters" do
164
-
165
- before do
166
- normalized_request = Pandexio::Request.new(
167
- :method => "PUT",
168
- :path => "/asdf/qwer/1234/title",
169
- :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
170
- :headers => { "sample" => "example", "Host" => "localhost" },
171
- :payload => "testing")
172
-
173
- signing_options = Pandexio::SigningOptions.new(
174
- :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
175
- :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
176
- :domain_id => "1234567890",
177
- :domain_key => "asdfjklqwerzxcv",
178
- :date => Time.utc(2014, 11, 21, 13, 43, 15),
179
- :expires => 90,
180
- :originator => "QueryStringSigningTest",
181
- :email_address => "Anonymous",
182
- :display_name => "á Anonymous")
183
-
184
- @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
185
- end
186
-
187
- it "returns the correct algorithm as a query parameter" do
188
- @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
189
- end
190
- it "returns the correct credential as a query parameter" do
191
- @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
192
- end
193
- it "returns the correct signed_headers value as a query parameter" do
194
- @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
195
- end
196
- it "returns the correct signature as a query parameter" do
197
- @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "1f008f205bff02f7a62c2bf9f630f9506c794524f51a37ce4140c1587ad90616"
198
- end
199
-
200
- end
201
-
202
- describe "when using query string signing mechanism and path contains spaces" do
203
-
204
- before do
205
- normalized_request = Pandexio::Request.new(
206
- :method => "PUT",
207
- :path => "/asdf/qwer/1234/title and description",
208
- :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
209
- :headers => { "sample" => "example", "Host" => "localhost" },
210
- :payload => "testing")
211
-
212
- signing_options = Pandexio::SigningOptions.new(
213
- :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
214
- :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
215
- :domain_id => "1234567890",
216
- :domain_key => "asdfjklqwerzxcv",
217
- :date => Time.utc(2014, 11, 21, 13, 43, 15),
218
- :expires => 90,
219
- :originator => "QueryStringSigningTest",
220
- :email_address => "Anonymous",
221
- :display_name => "Anonymous")
222
-
223
- @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
224
- end
225
-
226
- it "returns the correct algorithm as a query parameter" do
227
- @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
228
- end
229
- it "returns the correct credential as a query parameter" do
230
- @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
231
- end
232
- it "returns the correct signed_headers value as a query parameter" do
233
- @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
234
- end
235
- it "returns the correct signature as a query parameter" do
236
- @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "9cbd539d41fe31394b11b848970cc127b514dadb9d52223c4dcab5089a86ae44"
237
- end
238
-
239
- end
240
-
241
- describe "when using query string signing mechanism and payload contains non-ASCII characters" do
242
-
243
- before do
244
- normalized_request = Pandexio::Request.new(
245
- :method => "PUT",
246
- :path => "/asdf/qwer/1234/title",
247
- :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
248
- :headers => { "sample" => "example", "Host" => "localhost" },
249
- :payload => "testing á")
250
-
251
- signing_options = Pandexio::SigningOptions.new(
252
- :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
253
- :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
254
- :domain_id => "1234567890",
255
- :domain_key => "asdfjklqwerzxcv",
256
- :date => Time.utc(2014, 11, 21, 13, 43, 15),
257
- :expires => 90,
258
- :originator => "QueryStringSigningTest",
259
- :email_address => "Anonymous",
260
- :display_name => "Anonymous")
261
-
262
- @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
263
- end
264
-
265
- it "returns the correct algorithm as a query parameter" do
266
- @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
267
- end
268
- it "returns the correct credential as a query parameter" do
269
- @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
270
- end
271
- it "returns the correct signed_headers value as a query parameter" do
272
- @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
273
- end
274
- it "returns the correct signature as a query parameter" do
275
- @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "5155764a11094d8bfe4ebca3b0c87e8547636bd5391948fd2f2f2afa634ffabb"
276
- end
277
-
278
- end
279
-
280
- describe "when using query string signing mechanism and attributes include profile image" do
281
-
282
- before do
283
- normalized_request = Pandexio::Request.new(
284
- :method => "PUT",
285
- :path => "/asdf/qwer/1234/title",
286
- :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
287
- :headers => { "sample" => "example", "Host" => "localhost" },
288
- :payload => "testing")
289
-
290
- signing_options = Pandexio::SigningOptions.new(
291
- :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
292
- :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
293
- :domain_id => "1234567890",
294
- :domain_key => "asdfjklqwerzxcv",
295
- :date => Time.utc(2014, 11, 21, 13, 43, 15),
296
- :expires => 90,
297
- :originator => "QueryStringSigningTest",
298
- :email_address => "Anonymous",
299
- :display_name => "Anonymous",
300
- :profile_image => "abcdefg")
301
-
302
- @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
303
- end
304
-
305
- it "returns the correct algorithm as a query parameter" do
306
- @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
307
- end
308
- it "returns the correct credential as a query parameter" do
309
- @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
310
- end
311
- it "returns the correct signed_headers value as a query parameter" do
312
- @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
313
- end
314
- it "returns the correct signature as a query parameter" do
315
- @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "ead72d2e09c2a74b9712178f43eb68eed1c3877b206b221507eb8a1a82b67c77"
316
- end
317
-
318
- end
319
-
320
- 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 and email_address contains uppercase and lowercase characters" 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 "returns the correct algorithm as a query parameter" do
34
+ @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
35
+ end
36
+ it "returns the correct credential as a query parameter" do
37
+ @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
38
+ end
39
+ it "returns the correct signed_headers value as a query parameter" do
40
+ @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
41
+ end
42
+ it "returns the correct signature as a query parameter" do
43
+ @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "6ab83c6a331ba2d684d2557f1e415f3aee86bee105da1f5ad1bc4cc1cdf42f1a"
44
+ end
45
+
46
+ end
47
+
48
+ describe "when using query string signing mechanism and email_address contains only lowercase characters" do
49
+
50
+ before do
51
+ normalized_request = Pandexio::Request.new(
52
+ :method => "PUT",
53
+ :path => "/asdf/qwer/1234/title",
54
+ :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
55
+ :headers => { "sample" => "example", "Host" => "localhost" },
56
+ :payload => "testing")
57
+
58
+ signing_options = Pandexio::SigningOptions.new(
59
+ :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
60
+ :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
61
+ :domain_id => "1234567890",
62
+ :domain_key => "asdfjklqwerzxcv",
63
+ :date => Time.utc(2014, 11, 21, 13, 43, 15),
64
+ :expires => 90,
65
+ :originator => "QueryStringSigningTest",
66
+ :email_address => "anonymous",
67
+ :display_name => "Anonymous")
68
+
69
+ @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
70
+ end
71
+
72
+ it "returns the correct algorithm as a query parameter" do
73
+ @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
74
+ end
75
+ it "returns the correct credential as a query parameter" do
76
+ @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
77
+ end
78
+ it "returns the correct signed_headers value as a query parameter" do
79
+ @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
80
+ end
81
+ it "returns the correct signature as a query parameter" do
82
+ @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "4a8516231d42bf673e0660cebd81112f9540994856b2173daf2829b4897e3ada"
83
+ end
84
+
85
+ end
86
+
87
+ describe "when using query string signing mechanism and email_address contains only uppercase characters" do
88
+
89
+ before do
90
+ normalized_request = Pandexio::Request.new(
91
+ :method => "PUT",
92
+ :path => "/asdf/qwer/1234/title",
93
+ :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
94
+ :headers => { "sample" => "example", "Host" => "localhost" },
95
+ :payload => "testing")
96
+
97
+ signing_options = Pandexio::SigningOptions.new(
98
+ :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
99
+ :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
100
+ :domain_id => "1234567890",
101
+ :domain_key => "asdfjklqwerzxcv",
102
+ :date => Time.utc(2014, 11, 21, 13, 43, 15),
103
+ :expires => 90,
104
+ :originator => "QueryStringSigningTest",
105
+ :email_address => "ANONYMOUS",
106
+ :display_name => "Anonymous")
107
+
108
+ @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
109
+ end
110
+
111
+ it "returns the correct algorithm as a query parameter" do
112
+ @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
113
+ end
114
+ it "returns the correct credential as a query parameter" do
115
+ @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
116
+ end
117
+ it "returns the correct signed_headers value as a query parameter" do
118
+ @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
119
+ end
120
+ it "returns the correct signature as a query parameter" do
121
+ @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "8d549c05c925b92b609f9746be57acf944cdb13749de084d3d21daebb91b0c0a"
122
+ end
123
+
124
+ end
125
+
126
+ describe "when using query string signing mechanism and display_name contains spaces" do
127
+
128
+ before do
129
+ normalized_request = Pandexio::Request.new(
130
+ :method => "PUT",
131
+ :path => "/asdf/qwer/1234/title",
132
+ :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
133
+ :headers => { "sample" => "example", "Host" => "localhost" },
134
+ :payload => "testing")
135
+
136
+ signing_options = Pandexio::SigningOptions.new(
137
+ :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
138
+ :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
139
+ :domain_id => "1234567890",
140
+ :domain_key => "asdfjklqwerzxcv",
141
+ :date => Time.utc(2014, 11, 21, 13, 43, 15),
142
+ :expires => 90,
143
+ :originator => "QueryStringSigningTest",
144
+ :email_address => "Anonymous",
145
+ :display_name => "A. Anonymous")
146
+
147
+ @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
148
+ end
149
+
150
+ it "returns the correct algorithm as a query parameter" do
151
+ @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
152
+ end
153
+ it "returns the correct credential as a query parameter" do
154
+ @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
155
+ end
156
+ it "returns the correct signed_headers value as a query parameter" do
157
+ @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
158
+ end
159
+ it "returns the correct signature as a query parameter" do
160
+ @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "bcc1e6b33cd7f84316dc9cfd428a1d9161fd575de55d7e86008fb33664f43ac7"
161
+ end
162
+
163
+ end
164
+
165
+ describe "when using query string signing mechanism and display_name contains non-ASCII characters" do
166
+
167
+ before do
168
+ normalized_request = Pandexio::Request.new(
169
+ :method => "PUT",
170
+ :path => "/asdf/qwer/1234/title",
171
+ :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
172
+ :headers => { "sample" => "example", "Host" => "localhost" },
173
+ :payload => "testing")
174
+
175
+ signing_options = Pandexio::SigningOptions.new(
176
+ :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
177
+ :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
178
+ :domain_id => "1234567890",
179
+ :domain_key => "asdfjklqwerzxcv",
180
+ :date => Time.utc(2014, 11, 21, 13, 43, 15),
181
+ :expires => 90,
182
+ :originator => "QueryStringSigningTest",
183
+ :email_address => "Anonymous",
184
+ :display_name => Anonymous")
185
+
186
+ @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
187
+ end
188
+
189
+ it "returns the correct algorithm as a query parameter" do
190
+ @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
191
+ end
192
+ it "returns the correct credential as a query parameter" do
193
+ @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
194
+ end
195
+ it "returns the correct signed_headers value as a query parameter" do
196
+ @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
197
+ end
198
+ it "returns the correct signature as a query parameter" do
199
+ @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "1f008f205bff02f7a62c2bf9f630f9506c794524f51a37ce4140c1587ad90616"
200
+ end
201
+
202
+ end
203
+
204
+ describe "when using query string signing mechanism and path contains spaces" do
205
+
206
+ before do
207
+ normalized_request = Pandexio::Request.new(
208
+ :method => "PUT",
209
+ :path => "/asdf/qwer/1234/title and description",
210
+ :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
211
+ :headers => { "sample" => "example", "Host" => "localhost" },
212
+ :payload => "testing")
213
+
214
+ signing_options = Pandexio::SigningOptions.new(
215
+ :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
216
+ :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
217
+ :domain_id => "1234567890",
218
+ :domain_key => "asdfjklqwerzxcv",
219
+ :date => Time.utc(2014, 11, 21, 13, 43, 15),
220
+ :expires => 90,
221
+ :originator => "QueryStringSigningTest",
222
+ :email_address => "Anonymous",
223
+ :display_name => "Anonymous")
224
+
225
+ @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
226
+ end
227
+
228
+ it "returns the correct algorithm as a query parameter" do
229
+ @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
230
+ end
231
+ it "returns the correct credential as a query parameter" do
232
+ @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
233
+ end
234
+ it "returns the correct signed_headers value as a query parameter" do
235
+ @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
236
+ end
237
+ it "returns the correct signature as a query parameter" do
238
+ @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "9cbd539d41fe31394b11b848970cc127b514dadb9d52223c4dcab5089a86ae44"
239
+ end
240
+
241
+ end
242
+
243
+ describe "when using query string signing mechanism and payload contains non-ASCII characters" do
244
+
245
+ before do
246
+ normalized_request = Pandexio::Request.new(
247
+ :method => "PUT",
248
+ :path => "/asdf/qwer/1234/title",
249
+ :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
250
+ :headers => { "sample" => "example", "Host" => "localhost" },
251
+ :payload => "testing á")
252
+
253
+ signing_options = Pandexio::SigningOptions.new(
254
+ :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
255
+ :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
256
+ :domain_id => "1234567890",
257
+ :domain_key => "asdfjklqwerzxcv",
258
+ :date => Time.utc(2014, 11, 21, 13, 43, 15),
259
+ :expires => 90,
260
+ :originator => "QueryStringSigningTest",
261
+ :email_address => "Anonymous",
262
+ :display_name => "Anonymous")
263
+
264
+ @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
265
+ end
266
+
267
+ it "returns the correct algorithm as a query parameter" do
268
+ @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
269
+ end
270
+ it "returns the correct credential as a query parameter" do
271
+ @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
272
+ end
273
+ it "returns the correct signed_headers value as a query parameter" do
274
+ @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
275
+ end
276
+ it "returns the correct signature as a query parameter" do
277
+ @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "5155764a11094d8bfe4ebca3b0c87e8547636bd5391948fd2f2f2afa634ffabb"
278
+ end
279
+
280
+ end
281
+
282
+ describe "when using query string signing mechanism and attributes include profile image" do
283
+
284
+ before do
285
+ normalized_request = Pandexio::Request.new(
286
+ :method => "PUT",
287
+ :path => "/asdf/qwer/1234/title",
288
+ :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
289
+ :headers => { "sample" => "example", "Host" => "localhost" },
290
+ :payload => "testing")
291
+
292
+ signing_options = Pandexio::SigningOptions.new(
293
+ :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
294
+ :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
295
+ :domain_id => "1234567890",
296
+ :domain_key => "asdfjklqwerzxcv",
297
+ :date => Time.utc(2014, 11, 21, 13, 43, 15),
298
+ :expires => 90,
299
+ :originator => "QueryStringSigningTest",
300
+ :email_address => "Anonymous",
301
+ :display_name => "Anonymous",
302
+ :profile_image => "abcdefg")
303
+
304
+ @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
305
+ end
306
+
307
+ it "returns the correct algorithm as a query parameter" do
308
+ @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
309
+ end
310
+ it "returns the correct credential as a query parameter" do
311
+ @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
312
+ end
313
+ it "returns the correct signed_headers value as a query parameter" do
314
+ @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
315
+ end
316
+ it "returns the correct signature as a query parameter" do
317
+ @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "ead72d2e09c2a74b9712178f43eb68eed1c3877b206b221507eb8a1a82b67c77"
318
+ end
319
+
320
+ end
321
+
322
+ end
321
323
  end