pandexio 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93955fe9ac0c000146783acacd316db93d9a7c1c
4
- data.tar.gz: 81e6a17fdcfc3e31e6211e0169c22f85765ad2f2
3
+ metadata.gz: 6cd2d9a0a972ccb1636367359eb12658522579da
4
+ data.tar.gz: beeb502e30bebc0f5f564ad807783eba24cbb0db
5
5
  SHA512:
6
- metadata.gz: b71c8853105942558299ab05bbb2e4ac2fe44216af5499f8048d67f4bd06022825d0d6969411f0b2350e3390b98cffe05a7463ebcbafb7c17309c84d21dda058
7
- data.tar.gz: 2cb926aa6447257e3e0580bc42d2544d3a9a280a8ca553e8fef69bb0730386783bae2ce3fe56f0c6a0fde6dd12bdbb42a97fda0dd704de7e8b6600ff4f4a572f
6
+ metadata.gz: dffc3b73f6718db28f80b5eb09366b33e6fff5f3bc8bfc9f23d0e0e9b0bac8324dca564aa01f0d920baca39c14dba78454b576d7c7d3b8cd495452662d7fc1bb
7
+ data.tar.gz: d7ea52536369cd252f204b3daa7327b4f8124268a4775be0b6363dcb7fca27880f5936fb900a37e7dd5d983900391ebbec754e3c1437744997e243c06796e68b
data/lib/pandexio.rb CHANGED
@@ -77,7 +77,8 @@ module Pandexio
77
77
  end
78
78
 
79
79
  def self.build_canonical_payload(payload, digest)
80
- return digest.hexdigest(payload)
80
+ canonical_payload = digest.hexdigest(payload).encode('UTF-8')
81
+ return canonical_payload;
81
82
  end
82
83
 
83
84
  def self.build_canonical_request(request, digest)
@@ -89,7 +90,8 @@ module Pandexio
89
90
  end
90
91
 
91
92
  def self.build_string_to_sign(canonical_request, signing_options)
92
- return "#{signing_options.algorithm}#{LINE_BREAK}#{signing_options.date.iso8601}#{LINE_BREAK}#{canonical_request}"
93
+ signing_string = "#{signing_options.algorithm}#{LINE_BREAK}#{signing_options.date.iso8601}#{LINE_BREAK}#{canonical_request}".encode('UTF-8')
94
+ return signing_string
93
95
  end
94
96
 
95
97
  def self.generate_signature(string_to_sign, signing_options, digest)
@@ -123,7 +125,7 @@ module Pandexio
123
125
  p[SigningAttributes::ORIGINATOR] = signing_options.originator
124
126
  p[SigningAttributes::EMAIL_ADDRESS] = signing_options.email_address
125
127
  p[SigningAttributes::DISPLAY_NAME] = signing_options.display_name
126
- p[SigningAttributes::THUMBNAIL] = signing_options.thumbnail if !signing_options.thumbnail.nil? && signing_options.thumbnail.is_a?(String) && !signing_options.thumbnail.empty?
128
+ p[SigningAttributes::PROFILE_IMAGE] = signing_options.profile_image if !signing_options.profile_image.nil? && signing_options.profile_image.is_a?(String) && !signing_options.profile_image.empty?
127
129
  end
128
130
 
129
131
  append.call(
@@ -16,7 +16,7 @@ module Pandexio
16
16
  ORIGINATOR = "X-Pdx-Originator"
17
17
  EMAIL_ADDRESS = "X-Pdx-EmailAddress"
18
18
  DISPLAY_NAME = "X-Pdx-DisplayName"
19
- THUMBNAIL = "X-Pdx-Thumbnail"
19
+ PROFILE_IMAGE = "X-Pdx-ProfileImage"
20
20
  end
21
21
 
22
22
  end
@@ -11,7 +11,7 @@ module Pandexio
11
11
  @originator = params.fetch(:originator, nil)
12
12
  @email_address = params.fetch(:email_address, nil)
13
13
  @display_name = params.fetch(:display_name, nil)
14
- @thumbnail = params.fetch(:thumbnail, nil)
14
+ @profile_image = params.fetch(:profile_image, nil)
15
15
  end
16
16
 
17
17
  attr_accessor :algorithm
@@ -23,7 +23,7 @@ module Pandexio
23
23
  attr_accessor :originator
24
24
  attr_accessor :email_address
25
25
  attr_accessor :display_name
26
- attr_accessor :thumbnail
26
+ attr_accessor :profile_image
27
27
 
28
28
  end
29
29
 
@@ -2,33 +2,248 @@ require 'minitest/autorun'
2
2
  require_relative '../lib/pandexio.rb'
3
3
 
4
4
  describe Pandexio do
5
- before do
6
- normalized_request = Pandexio::Request.new(
7
- :method => "PUT",
8
- :path => "/asdf/qwer/1234/title",
9
- :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
10
- :headers => { "sample" => "example", "Host" => "localhost" },
11
- :payload => "testing")
12
-
13
- date = Time.utc(2014, 11, 21, 13, 43, 15)
14
-
15
- signing_options = Pandexio::SigningOptions.new(
16
- :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
17
- :mechanism => Pandexio::SigningMechanisms::HEADER,
18
- :domain_id => "1234567890",
19
- :domain_key => "asdfjklqwerzxcv",
20
- :date => date,
21
- :expires => 90,
22
- :originator => "HeaderSigningTest",
23
- :email_address => "Anonymous",
24
- :display_name => "Anonymous")
25
-
26
- @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
27
- end
5
+ describe "#to_authorized_request" do
6
+
7
+ describe "when using header 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::HEADER,
20
+ :domain_id => "1234567890",
21
+ :domain_key => "asdfjklqwerzxcv",
22
+ :date => Time.utc(2014, 11, 21, 13, 43, 15),
23
+ :expires => 90,
24
+ :originator => "HeaderSigningTest",
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 authorization header" do
32
+ @authorized_request.headers["Authorization"].must_equal "PDX-HMAC-SHA256 Credential=1234567890, SignedHeaders=host;sample;x-pdx-date;x-pdx-displayname;x-pdx-emailaddress;x-pdx-expires;x-pdx-originator, Signature=a2e3dbc31b712bec6071dc7c5770bc60d4b03afa20e8329e6f4f6a2d74d32709"
33
+ end
34
+
35
+ end
36
+
37
+ describe "when using header signing mechanism and email_address contains all lowercase characters" do
38
+
39
+ before do
40
+ normalized_request = Pandexio::Request.new(
41
+ :method => "PUT",
42
+ :path => "/asdf/qwer/1234/title",
43
+ :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
44
+ :headers => { "sample" => "example", "Host" => "localhost" },
45
+ :payload => "testing")
46
+
47
+ signing_options = Pandexio::SigningOptions.new(
48
+ :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
49
+ :mechanism => Pandexio::SigningMechanisms::HEADER,
50
+ :domain_id => "1234567890",
51
+ :domain_key => "asdfjklqwerzxcv",
52
+ :date => Time.utc(2014, 11, 21, 13, 43, 15),
53
+ :expires => 90,
54
+ :originator => "HeaderSigningTest",
55
+ :email_address => "anonymous",
56
+ :display_name => "Anonymous")
57
+
58
+ @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
59
+ end
60
+
61
+ it "returns the correct authorization header" do
62
+ @authorized_request.headers["Authorization"].must_equal "PDX-HMAC-SHA256 Credential=1234567890, SignedHeaders=host;sample;x-pdx-date;x-pdx-displayname;x-pdx-emailaddress;x-pdx-expires;x-pdx-originator, Signature=d2c3ba8ed5c10371a4a370a7e7ee5f483d4eaac4545a97d6aaced30d8e62d2a0"
63
+ end
64
+
65
+ end
66
+
67
+ describe "when using header signing mechanism and email_address contains all uppercase characters" do
68
+
69
+ before do
70
+ normalized_request = Pandexio::Request.new(
71
+ :method => "PUT",
72
+ :path => "/asdf/qwer/1234/title",
73
+ :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
74
+ :headers => { "sample" => "example", "Host" => "localhost" },
75
+ :payload => "testing")
76
+
77
+ signing_options = Pandexio::SigningOptions.new(
78
+ :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
79
+ :mechanism => Pandexio::SigningMechanisms::HEADER,
80
+ :domain_id => "1234567890",
81
+ :domain_key => "asdfjklqwerzxcv",
82
+ :date => Time.utc(2014, 11, 21, 13, 43, 15),
83
+ :expires => 90,
84
+ :originator => "HeaderSigningTest",
85
+ :email_address => "ANONYMOUS",
86
+ :display_name => "Anonymous")
87
+
88
+ @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
89
+ end
90
+
91
+ it "returns the correct authorization header" do
92
+ @authorized_request.headers["Authorization"].must_equal "PDX-HMAC-SHA256 Credential=1234567890, SignedHeaders=host;sample;x-pdx-date;x-pdx-displayname;x-pdx-emailaddress;x-pdx-expires;x-pdx-originator, Signature=865f3555991dc8f73760058b643a6a169c07c3a32ab3d247aa0eebdc24e9d6e9"
93
+ end
94
+
95
+ end
96
+
97
+ describe "when using header signing mechanism and display_name contains spaces" do
98
+
99
+ before do
100
+ normalized_request = Pandexio::Request.new(
101
+ :method => "PUT",
102
+ :path => "/asdf/qwer/1234/title",
103
+ :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
104
+ :headers => { "sample" => "example", "Host" => "localhost" },
105
+ :payload => "testing")
106
+
107
+ signing_options = Pandexio::SigningOptions.new(
108
+ :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
109
+ :mechanism => Pandexio::SigningMechanisms::HEADER,
110
+ :domain_id => "1234567890",
111
+ :domain_key => "asdfjklqwerzxcv",
112
+ :date => Time.utc(2014, 11, 21, 13, 43, 15),
113
+ :expires => 90,
114
+ :originator => "HeaderSigningTest",
115
+ :email_address => "Anonymous",
116
+ :display_name => "A. Anonymous")
117
+
118
+ @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
119
+ end
120
+
121
+ it "returns the correct authorization header" do
122
+ @authorized_request.headers["Authorization"].must_equal "PDX-HMAC-SHA256 Credential=1234567890, SignedHeaders=host;sample;x-pdx-date;x-pdx-displayname;x-pdx-emailaddress;x-pdx-expires;x-pdx-originator, Signature=e1fc00541454d11c58bae1273af56b528def5e60575feedbe0a9019b88fe1b79"
123
+ end
124
+
125
+ end
126
+
127
+ describe "when using header signing mechanism and display_name contains non-ASCII characters" do
128
+
129
+ before do
130
+ normalized_request = Pandexio::Request.new(
131
+ :method => "PUT",
132
+ :path => "/asdf/qwer/1234/title",
133
+ :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
134
+ :headers => { "sample" => "example", "Host" => "localhost" },
135
+ :payload => "testing")
136
+
137
+ signing_options = Pandexio::SigningOptions.new(
138
+ :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
139
+ :mechanism => Pandexio::SigningMechanisms::HEADER,
140
+ :domain_id => "1234567890",
141
+ :domain_key => "asdfjklqwerzxcv",
142
+ :date => Time.utc(2014, 11, 21, 13, 43, 15),
143
+ :expires => 90,
144
+ :originator => "HeaderSigningTest",
145
+ :email_address => "Anonymous",
146
+ :display_name => "á Anonymous")
147
+
148
+ @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
149
+ end
150
+
151
+ it "returns the correct authorization header" do
152
+ @authorized_request.headers["Authorization"].must_equal "PDX-HMAC-SHA256 Credential=1234567890, SignedHeaders=host;sample;x-pdx-date;x-pdx-displayname;x-pdx-emailaddress;x-pdx-expires;x-pdx-originator, Signature=347ac3df3930eaf2ba107c932e740dae5430a99f4fef76b18a4452d07125c209"
153
+ end
154
+
155
+ end
156
+
157
+ describe "when using header signing mechanism and path contains spaces" do
158
+
159
+ before do
160
+ normalized_request = Pandexio::Request.new(
161
+ :method => "PUT",
162
+ :path => "/asdf/qwer/1234/title and description",
163
+ :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
164
+ :headers => { "sample" => "example", "Host" => "localhost" },
165
+ :payload => "testing")
166
+
167
+ signing_options = Pandexio::SigningOptions.new(
168
+ :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
169
+ :mechanism => Pandexio::SigningMechanisms::HEADER,
170
+ :domain_id => "1234567890",
171
+ :domain_key => "asdfjklqwerzxcv",
172
+ :date => Time.utc(2014, 11, 21, 13, 43, 15),
173
+ :expires => 90,
174
+ :originator => "HeaderSigningTest",
175
+ :email_address => "Anonymous",
176
+ :display_name => "Anonymous")
177
+
178
+ @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
179
+ end
180
+
181
+ it "returns the correct authorization header" do
182
+ @authorized_request.headers["Authorization"].must_equal "PDX-HMAC-SHA256 Credential=1234567890, SignedHeaders=host;sample;x-pdx-date;x-pdx-displayname;x-pdx-emailaddress;x-pdx-expires;x-pdx-originator, Signature=e8946dbd83307f5bf86f7f152d6cee95426834dd5901588da84df1b8207e2bca"
183
+ end
184
+
185
+ end
186
+
187
+ describe "when using header signing mechanism and payload contains non-ASCII characters" do
188
+
189
+ before do
190
+ normalized_request = Pandexio::Request.new(
191
+ :method => "PUT",
192
+ :path => "/asdf/qwer/1234/title",
193
+ :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
194
+ :headers => { "sample" => "example", "Host" => "localhost" },
195
+ :payload => "testing á")
196
+
197
+ signing_options = Pandexio::SigningOptions.new(
198
+ :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
199
+ :mechanism => Pandexio::SigningMechanisms::HEADER,
200
+ :domain_id => "1234567890",
201
+ :domain_key => "asdfjklqwerzxcv",
202
+ :date => Time.utc(2014, 11, 21, 13, 43, 15),
203
+ :expires => 90,
204
+ :originator => "HeaderSigningTest",
205
+ :email_address => "Anonymous",
206
+ :display_name => "Anonymous")
207
+
208
+ @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
209
+ end
210
+
211
+ it "returns the correct authorization header" do
212
+ @authorized_request.headers["Authorization"].must_equal "PDX-HMAC-SHA256 Credential=1234567890, SignedHeaders=host;sample;x-pdx-date;x-pdx-displayname;x-pdx-emailaddress;x-pdx-expires;x-pdx-originator, Signature=fec62f69abbb53261dceaf1a52dab932e24e5f6e97f189da559562e14c13a9f7"
213
+ end
214
+
215
+ end
216
+
217
+ describe "when using header signing mechanism and attributes include profile_image" do
218
+
219
+ before do
220
+ normalized_request = Pandexio::Request.new(
221
+ :method => "PUT",
222
+ :path => "/asdf/qwer/1234/title",
223
+ :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
224
+ :headers => { "sample" => "example", "Host" => "localhost" },
225
+ :payload => "testing")
226
+
227
+ signing_options = Pandexio::SigningOptions.new(
228
+ :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
229
+ :mechanism => Pandexio::SigningMechanisms::HEADER,
230
+ :domain_id => "1234567890",
231
+ :domain_key => "asdfjklqwerzxcv",
232
+ :date => Time.utc(2014, 11, 21, 13, 43, 15),
233
+ :expires => 90,
234
+ :originator => "HeaderSigningTest",
235
+ :email_address => "Anonymous",
236
+ :display_name => "Anonymous",
237
+ :profile_image => "abcdefg")
238
+
239
+ @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
240
+ end
241
+
242
+ it "returns the correct authorization header" do
243
+ @authorized_request.headers["Authorization"].must_equal "PDX-HMAC-SHA256 Credential=1234567890, SignedHeaders=host;sample;x-pdx-date;x-pdx-displayname;x-pdx-emailaddress;x-pdx-expires;x-pdx-originator;x-pdx-profileimage, Signature=e7fb1de006519be4a1c778c3055f05dfa2fafb96fb1bc033a77ba4df4da8829d"
244
+ end
28
245
 
29
- describe "#header_signing" do
30
- it "returns the correct authorization header" do
31
- @authorized_request.headers["Authorization"].must_equal "PDX-HMAC-SHA256 Credential=1234567890, SignedHeaders=host;sample;x-pdx-date;x-pdx-displayname;x-pdx-emailaddress;x-pdx-expires;x-pdx-originator, Signature=a2e3dbc31b712bec6071dc7c5770bc60d4b03afa20e8329e6f4f6a2d74d32709"
32
246
  end
247
+
33
248
  end
34
249
  end
@@ -2,42 +2,320 @@ require 'minitest/autorun'
2
2
  require_relative '../lib/pandexio.rb'
3
3
 
4
4
  describe Pandexio do
5
- before do
6
- normalized_request = Pandexio::Request.new(
7
- :method => "PUT",
8
- :path => "/asdf/qwer/1234/title",
9
- :query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
10
- :headers => { "sample" => "example", "Host" => "localhost" },
11
- :payload => "testing")
12
-
13
- date = Time.utc(2014, 11, 21, 13, 43, 15)
14
-
15
- signing_options = Pandexio::SigningOptions.new(
16
- :algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
17
- :mechanism => Pandexio::SigningMechanisms::QUERY_STRING,
18
- :domain_id => "1234567890",
19
- :domain_key => "asdfjklqwerzxcv",
20
- :date => date,
21
- :expires => 90,
22
- :originator => "QueryStringSigningTest",
23
- :email_address => "Anonymous",
24
- :display_name => "Anonymous")
25
-
26
- @authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
27
- end
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
28
43
 
29
- describe "#query_string_signing" do
30
- it "returns the correct algorithm as a query parameter" do
31
- @authorized_request.query_parameters["X-Pdx-Algorithm"].must_equal "PDX-HMAC-SHA256"
32
44
  end
33
- it "returns the correct credential as a query parameter" do
34
- @authorized_request.query_parameters["X-Pdx-Credential"].must_equal "1234567890"
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
+
35
83
  end
36
- it "returns the correct signed_headers value as a query parameter" do
37
- @authorized_request.query_parameters["X-Pdx-SignedHeaders"].must_equal "host;sample"
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
+
38
122
  end
39
- it "returns the correct signature as a query parameter" do
40
- @authorized_request.query_parameters["X-Pdx-Signature"].must_equal "6ab83c6a331ba2d684d2557f1e415f3aee86bee105da1f5ad1bc4cc1cdf42f1a"
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
+
41
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
+
42
320
  end
43
321
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pandexio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Varilone
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-11 00:00:00.000000000 Z
11
+ date: 2015-06-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Pandexio SDK for Ruby
14
14
  email: bvarilone@gmail.com
@@ -49,5 +49,5 @@ rubyforge_project:
49
49
  rubygems_version: 2.4.4
50
50
  signing_key:
51
51
  specification_version: 4
52
- summary: ''
52
+ summary: Signs Pandexio requests using HMAC
53
53
  test_files: []