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.
- data/README.md +78 -78
- data/Rakefile +8 -8
- data/lib/pandexio.rb +150 -152
- data/lib/request.rb +24 -24
- data/lib/signing_algorithms.rb +36 -36
- data/lib/signing_attributes.rb +21 -21
- data/lib/signing_mechanisms.rb +16 -16
- data/lib/signing_options.rb +29 -29
- data/test/test_header_signing.rb +250 -248
- data/test/test_query_string_signing.rb +322 -320
- metadata +8 -6
- checksums.yaml +0 -7
data/lib/request.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
module Pandexio
|
2
|
-
|
3
|
-
class Request
|
4
|
-
|
5
|
-
def initialize(params = {})
|
6
|
-
@method = params.fetch(:method, nil)
|
7
|
-
@path = params.fetch(:path, nil)
|
8
|
-
@query_parameters = params.fetch(:query_parameters, {})
|
9
|
-
@headers = params.fetch(:headers, {})
|
10
|
-
@payload = params.fetch(:payload, nil)
|
11
|
-
end
|
12
|
-
|
13
|
-
attr_accessor :method
|
14
|
-
attr_accessor :path
|
15
|
-
attr_accessor :query_parameters
|
16
|
-
attr_accessor :headers
|
17
|
-
attr_accessor :payload
|
18
|
-
|
19
|
-
def to_s
|
20
|
-
"#{@method} #{@path}#{LINE_BREAK}query_parameters: #{query_parameters}#{LINE_BREAK}headers: #{headers}#{LINE_BREAK}payload: #{payload}"
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
1
|
+
module Pandexio
|
2
|
+
|
3
|
+
class Request
|
4
|
+
|
5
|
+
def initialize(params = {})
|
6
|
+
@method = params.fetch(:method, nil)
|
7
|
+
@path = params.fetch(:path, nil)
|
8
|
+
@query_parameters = params.fetch(:query_parameters, {})
|
9
|
+
@headers = params.fetch(:headers, {})
|
10
|
+
@payload = params.fetch(:payload, nil)
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_accessor :method
|
14
|
+
attr_accessor :path
|
15
|
+
attr_accessor :query_parameters
|
16
|
+
attr_accessor :headers
|
17
|
+
attr_accessor :payload
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
"#{@method} #{@path}#{LINE_BREAK}query_parameters: #{query_parameters}#{LINE_BREAK}headers: #{headers}#{LINE_BREAK}payload: #{payload}"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
25
|
end
|
data/lib/signing_algorithms.rb
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
module Pandexio
|
2
|
-
|
3
|
-
class SigningAlgorithms
|
4
|
-
|
5
|
-
PDX_HMAC_MD5 = "PDX-HMAC-MD5"
|
6
|
-
PDX_HMAC_SHA1 = "PDX-HMAC-SHA1"
|
7
|
-
PDX_HMAC_SHA256 = "PDX-HMAC-SHA256"
|
8
|
-
PDX_HMAC_SHA384 = "PDX-HMAC-SHA384"
|
9
|
-
PDX_HMAC_SHA512 = "PDX-HMAC-SHA512"
|
10
|
-
|
11
|
-
def self.is_v(a)
|
12
|
-
|
13
|
-
return !a.nil? && a.is_a?(String) &&
|
14
|
-
(a == PDX_HMAC_MD5 ||
|
15
|
-
a == PDX_HMAC_SHA1 ||
|
16
|
-
a == PDX_HMAC_SHA256 ||
|
17
|
-
a == PDX_HMAC_SHA384 ||
|
18
|
-
a == PDX_HMAC_SHA512)
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.to_d(a)
|
23
|
-
|
24
|
-
return case a
|
25
|
-
when SigningAlgorithms::PDX_HMAC_MD5; OpenSSL::Digest::MD5.new
|
26
|
-
when SigningAlgorithms::PDX_HMAC_SHA1; OpenSSL::Digest::SHA1.new
|
27
|
-
when SigningAlgorithms::PDX_HMAC_SHA256; OpenSSL::Digest::SHA256.new
|
28
|
-
when SigningAlgorithms::PDX_HMAC_SHA384; OpenSSL::Digest::SHA384.new
|
29
|
-
when SigningAlgorithms::PDX_HMAC_SHA512; OpenSSL::Digest::SHA512.new
|
30
|
-
else raise 'Invalid signing algorithm'
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
1
|
+
module Pandexio
|
2
|
+
|
3
|
+
class SigningAlgorithms
|
4
|
+
|
5
|
+
PDX_HMAC_MD5 = "PDX-HMAC-MD5"
|
6
|
+
PDX_HMAC_SHA1 = "PDX-HMAC-SHA1"
|
7
|
+
PDX_HMAC_SHA256 = "PDX-HMAC-SHA256"
|
8
|
+
PDX_HMAC_SHA384 = "PDX-HMAC-SHA384"
|
9
|
+
PDX_HMAC_SHA512 = "PDX-HMAC-SHA512"
|
10
|
+
|
11
|
+
def self.is_v(a)
|
12
|
+
|
13
|
+
return !a.nil? && a.is_a?(String) &&
|
14
|
+
(a == PDX_HMAC_MD5 ||
|
15
|
+
a == PDX_HMAC_SHA1 ||
|
16
|
+
a == PDX_HMAC_SHA256 ||
|
17
|
+
a == PDX_HMAC_SHA384 ||
|
18
|
+
a == PDX_HMAC_SHA512)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.to_d(a)
|
23
|
+
|
24
|
+
return case a
|
25
|
+
when SigningAlgorithms::PDX_HMAC_MD5; OpenSSL::Digest::MD5.new
|
26
|
+
when SigningAlgorithms::PDX_HMAC_SHA1; OpenSSL::Digest::SHA1.new
|
27
|
+
when SigningAlgorithms::PDX_HMAC_SHA256; OpenSSL::Digest::SHA256.new
|
28
|
+
when SigningAlgorithms::PDX_HMAC_SHA384; OpenSSL::Digest::SHA384.new
|
29
|
+
when SigningAlgorithms::PDX_HMAC_SHA512; OpenSSL::Digest::SHA512.new
|
30
|
+
else raise 'Invalid signing algorithm'
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
37
|
end
|
data/lib/signing_attributes.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
module Pandexio
|
2
|
-
|
3
|
-
class SigningAttributes
|
4
|
-
# Used by "headers" only
|
5
|
-
AUTHORIZATION = "Authorization"
|
6
|
-
|
7
|
-
# Used by "query_parameters" only
|
8
|
-
ALGORITHM = "X-Pdx-Algorithm"
|
9
|
-
CREDENTIAL = "X-Pdx-Credential"
|
10
|
-
SIGNED_HEADERS = "X-Pdx-SignedHeaders"
|
11
|
-
SIGNATURE = "X-Pdx-Signature"
|
12
|
-
|
13
|
-
# Used by "headers" and "query_parameters"
|
14
|
-
DATE = "X-Pdx-Date"
|
15
|
-
EXPIRES = "X-Pdx-Expires"
|
16
|
-
ORIGINATOR = "X-Pdx-Originator"
|
17
|
-
EMAIL_ADDRESS = "X-Pdx-EmailAddress"
|
18
|
-
DISPLAY_NAME = "X-Pdx-DisplayName"
|
19
|
-
PROFILE_IMAGE = "X-Pdx-ProfileImage"
|
20
|
-
end
|
21
|
-
|
1
|
+
module Pandexio
|
2
|
+
|
3
|
+
class SigningAttributes
|
4
|
+
# Used by "headers" only
|
5
|
+
AUTHORIZATION = "Authorization"
|
6
|
+
|
7
|
+
# Used by "query_parameters" only
|
8
|
+
ALGORITHM = "X-Pdx-Algorithm"
|
9
|
+
CREDENTIAL = "X-Pdx-Credential"
|
10
|
+
SIGNED_HEADERS = "X-Pdx-SignedHeaders"
|
11
|
+
SIGNATURE = "X-Pdx-Signature"
|
12
|
+
|
13
|
+
# Used by "headers" and "query_parameters"
|
14
|
+
DATE = "X-Pdx-Date"
|
15
|
+
EXPIRES = "X-Pdx-Expires"
|
16
|
+
ORIGINATOR = "X-Pdx-Originator"
|
17
|
+
EMAIL_ADDRESS = "X-Pdx-EmailAddress"
|
18
|
+
DISPLAY_NAME = "X-Pdx-DisplayName"
|
19
|
+
PROFILE_IMAGE = "X-Pdx-ProfileImage"
|
20
|
+
end
|
21
|
+
|
22
22
|
end
|
data/lib/signing_mechanisms.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
module Pandexio
|
2
|
-
|
3
|
-
class SigningMechanisms
|
4
|
-
|
5
|
-
QUERY_STRING = "QueryString"
|
6
|
-
HEADER = "Header"
|
7
|
-
|
8
|
-
def self.is_v(m)
|
9
|
-
|
10
|
-
return !m.nil? && m.is_a?(String) &&
|
11
|
-
(m == QUERY_STRING || m == HEADER)
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
1
|
+
module Pandexio
|
2
|
+
|
3
|
+
class SigningMechanisms
|
4
|
+
|
5
|
+
QUERY_STRING = "QueryString"
|
6
|
+
HEADER = "Header"
|
7
|
+
|
8
|
+
def self.is_v(m)
|
9
|
+
|
10
|
+
return !m.nil? && m.is_a?(String) &&
|
11
|
+
(m == QUERY_STRING || m == HEADER)
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
17
|
end
|
data/lib/signing_options.rb
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
module Pandexio
|
2
|
-
|
3
|
-
class SigningOptions
|
4
|
-
def initialize(params = {})
|
5
|
-
@algorithm = params.fetch(:algorithm, nil)
|
6
|
-
@mechanism = params.fetch(:mechanism, nil)
|
7
|
-
@domain_id = params.fetch(:domain_id, nil)
|
8
|
-
@domain_key = params.fetch(:domain_key, nil)
|
9
|
-
@date = params.fetch(:date, nil)
|
10
|
-
@expires = params.fetch(:expires, nil)
|
11
|
-
@originator = params.fetch(:originator, nil)
|
12
|
-
@email_address = params.fetch(:email_address, nil)
|
13
|
-
@display_name = params.fetch(:display_name, nil)
|
14
|
-
@profile_image = params.fetch(:profile_image, nil)
|
15
|
-
end
|
16
|
-
|
17
|
-
attr_accessor :algorithm
|
18
|
-
attr_accessor :mechanism
|
19
|
-
attr_accessor :domain_id
|
20
|
-
attr_accessor :domain_key
|
21
|
-
attr_accessor :date
|
22
|
-
attr_accessor :expires
|
23
|
-
attr_accessor :originator
|
24
|
-
attr_accessor :email_address
|
25
|
-
attr_accessor :display_name
|
26
|
-
attr_accessor :profile_image
|
27
|
-
|
28
|
-
end
|
29
|
-
|
1
|
+
module Pandexio
|
2
|
+
|
3
|
+
class SigningOptions
|
4
|
+
def initialize(params = {})
|
5
|
+
@algorithm = params.fetch(:algorithm, nil)
|
6
|
+
@mechanism = params.fetch(:mechanism, nil)
|
7
|
+
@domain_id = params.fetch(:domain_id, nil)
|
8
|
+
@domain_key = params.fetch(:domain_key, nil)
|
9
|
+
@date = params.fetch(:date, nil)
|
10
|
+
@expires = params.fetch(:expires, nil)
|
11
|
+
@originator = params.fetch(:originator, nil)
|
12
|
+
@email_address = params.fetch(:email_address, nil)
|
13
|
+
@display_name = params.fetch(:display_name, nil)
|
14
|
+
@profile_image = params.fetch(:profile_image, nil)
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_accessor :algorithm
|
18
|
+
attr_accessor :mechanism
|
19
|
+
attr_accessor :domain_id
|
20
|
+
attr_accessor :domain_key
|
21
|
+
attr_accessor :date
|
22
|
+
attr_accessor :expires
|
23
|
+
attr_accessor :originator
|
24
|
+
attr_accessor :email_address
|
25
|
+
attr_accessor :display_name
|
26
|
+
attr_accessor :profile_image
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
30
|
end
|
data/test/test_header_signing.rb
CHANGED
@@ -1,249 +1,251 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
:
|
74
|
-
:
|
75
|
-
:
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
84
|
-
:
|
85
|
-
:
|
86
|
-
:
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
:
|
104
|
-
:
|
105
|
-
:
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
:
|
111
|
-
:
|
112
|
-
:
|
113
|
-
:
|
114
|
-
:
|
115
|
-
:
|
116
|
-
:
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
:
|
134
|
-
:
|
135
|
-
:
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
:
|
141
|
-
:
|
142
|
-
:
|
143
|
-
:
|
144
|
-
:
|
145
|
-
:
|
146
|
-
:
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
:
|
164
|
-
:
|
165
|
-
:
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
:
|
171
|
-
:
|
172
|
-
:
|
173
|
-
:
|
174
|
-
:
|
175
|
-
:
|
176
|
-
:
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
:
|
194
|
-
:
|
195
|
-
:
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
:
|
201
|
-
:
|
202
|
-
:
|
203
|
-
:
|
204
|
-
:
|
205
|
-
:
|
206
|
-
:
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
:
|
224
|
-
:
|
225
|
-
:
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
:
|
231
|
-
:
|
232
|
-
:
|
233
|
-
:
|
234
|
-
:
|
235
|
-
:
|
236
|
-
:
|
237
|
-
:
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
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 header 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::HEADER,
|
22
|
+
:domain_id => "1234567890",
|
23
|
+
:domain_key => "asdfjklqwerzxcv",
|
24
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
25
|
+
:expires => 90,
|
26
|
+
:originator => "HeaderSigningTest",
|
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 authorization header" do
|
34
|
+
@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"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "when using header signing mechanism and email_address contains all lowercase characters" do
|
40
|
+
|
41
|
+
before do
|
42
|
+
normalized_request = Pandexio::Request.new(
|
43
|
+
:method => "PUT",
|
44
|
+
:path => "/asdf/qwer/1234/title",
|
45
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
46
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
47
|
+
:payload => "testing")
|
48
|
+
|
49
|
+
signing_options = Pandexio::SigningOptions.new(
|
50
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
51
|
+
:mechanism => Pandexio::SigningMechanisms::HEADER,
|
52
|
+
:domain_id => "1234567890",
|
53
|
+
:domain_key => "asdfjklqwerzxcv",
|
54
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
55
|
+
:expires => 90,
|
56
|
+
:originator => "HeaderSigningTest",
|
57
|
+
:email_address => "anonymous",
|
58
|
+
:display_name => "Anonymous")
|
59
|
+
|
60
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "returns the correct authorization header" do
|
64
|
+
@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"
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "when using header signing mechanism and email_address contains all uppercase characters" do
|
70
|
+
|
71
|
+
before do
|
72
|
+
normalized_request = Pandexio::Request.new(
|
73
|
+
:method => "PUT",
|
74
|
+
:path => "/asdf/qwer/1234/title",
|
75
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
76
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
77
|
+
:payload => "testing")
|
78
|
+
|
79
|
+
signing_options = Pandexio::SigningOptions.new(
|
80
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
81
|
+
:mechanism => Pandexio::SigningMechanisms::HEADER,
|
82
|
+
:domain_id => "1234567890",
|
83
|
+
:domain_key => "asdfjklqwerzxcv",
|
84
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
85
|
+
:expires => 90,
|
86
|
+
:originator => "HeaderSigningTest",
|
87
|
+
:email_address => "ANONYMOUS",
|
88
|
+
:display_name => "Anonymous")
|
89
|
+
|
90
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "returns the correct authorization header" do
|
94
|
+
@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"
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "when using header signing mechanism and display_name contains spaces" do
|
100
|
+
|
101
|
+
before do
|
102
|
+
normalized_request = Pandexio::Request.new(
|
103
|
+
:method => "PUT",
|
104
|
+
:path => "/asdf/qwer/1234/title",
|
105
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
106
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
107
|
+
:payload => "testing")
|
108
|
+
|
109
|
+
signing_options = Pandexio::SigningOptions.new(
|
110
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
111
|
+
:mechanism => Pandexio::SigningMechanisms::HEADER,
|
112
|
+
:domain_id => "1234567890",
|
113
|
+
:domain_key => "asdfjklqwerzxcv",
|
114
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
115
|
+
:expires => 90,
|
116
|
+
:originator => "HeaderSigningTest",
|
117
|
+
:email_address => "Anonymous",
|
118
|
+
:display_name => "A. Anonymous")
|
119
|
+
|
120
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "returns the correct authorization header" do
|
124
|
+
@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"
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "when using header signing mechanism and display_name contains non-ASCII characters" do
|
130
|
+
|
131
|
+
before do
|
132
|
+
normalized_request = Pandexio::Request.new(
|
133
|
+
:method => "PUT",
|
134
|
+
:path => "/asdf/qwer/1234/title",
|
135
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
136
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
137
|
+
:payload => "testing")
|
138
|
+
|
139
|
+
signing_options = Pandexio::SigningOptions.new(
|
140
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
141
|
+
:mechanism => Pandexio::SigningMechanisms::HEADER,
|
142
|
+
:domain_id => "1234567890",
|
143
|
+
:domain_key => "asdfjklqwerzxcv",
|
144
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
145
|
+
:expires => 90,
|
146
|
+
:originator => "HeaderSigningTest",
|
147
|
+
:email_address => "Anonymous",
|
148
|
+
:display_name => "á Anonymous")
|
149
|
+
|
150
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "returns the correct authorization header" do
|
154
|
+
@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"
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "when using header signing mechanism and path contains spaces" do
|
160
|
+
|
161
|
+
before do
|
162
|
+
normalized_request = Pandexio::Request.new(
|
163
|
+
:method => "PUT",
|
164
|
+
:path => "/asdf/qwer/1234/title and description",
|
165
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
166
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
167
|
+
:payload => "testing")
|
168
|
+
|
169
|
+
signing_options = Pandexio::SigningOptions.new(
|
170
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
171
|
+
:mechanism => Pandexio::SigningMechanisms::HEADER,
|
172
|
+
:domain_id => "1234567890",
|
173
|
+
:domain_key => "asdfjklqwerzxcv",
|
174
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
175
|
+
:expires => 90,
|
176
|
+
:originator => "HeaderSigningTest",
|
177
|
+
:email_address => "Anonymous",
|
178
|
+
:display_name => "Anonymous")
|
179
|
+
|
180
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
181
|
+
end
|
182
|
+
|
183
|
+
it "returns the correct authorization header" do
|
184
|
+
@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"
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
describe "when using header signing mechanism and payload contains non-ASCII characters" do
|
190
|
+
|
191
|
+
before do
|
192
|
+
normalized_request = Pandexio::Request.new(
|
193
|
+
:method => "PUT",
|
194
|
+
:path => "/asdf/qwer/1234/title",
|
195
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
196
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
197
|
+
:payload => "testing á")
|
198
|
+
|
199
|
+
signing_options = Pandexio::SigningOptions.new(
|
200
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
201
|
+
:mechanism => Pandexio::SigningMechanisms::HEADER,
|
202
|
+
:domain_id => "1234567890",
|
203
|
+
:domain_key => "asdfjklqwerzxcv",
|
204
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
205
|
+
:expires => 90,
|
206
|
+
:originator => "HeaderSigningTest",
|
207
|
+
:email_address => "Anonymous",
|
208
|
+
:display_name => "Anonymous")
|
209
|
+
|
210
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
211
|
+
end
|
212
|
+
|
213
|
+
it "returns the correct authorization header" do
|
214
|
+
@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"
|
215
|
+
end
|
216
|
+
|
217
|
+
end
|
218
|
+
|
219
|
+
describe "when using header signing mechanism and attributes include profile_image" do
|
220
|
+
|
221
|
+
before do
|
222
|
+
normalized_request = Pandexio::Request.new(
|
223
|
+
:method => "PUT",
|
224
|
+
:path => "/asdf/qwer/1234/title",
|
225
|
+
:query_parameters => { "nonce" => "987654321", "Baseline" => "5" },
|
226
|
+
:headers => { "sample" => "example", "Host" => "localhost" },
|
227
|
+
:payload => "testing")
|
228
|
+
|
229
|
+
signing_options = Pandexio::SigningOptions.new(
|
230
|
+
:algorithm => Pandexio::SigningAlgorithms::PDX_HMAC_SHA256,
|
231
|
+
:mechanism => Pandexio::SigningMechanisms::HEADER,
|
232
|
+
:domain_id => "1234567890",
|
233
|
+
:domain_key => "asdfjklqwerzxcv",
|
234
|
+
:date => Time.utc(2014, 11, 21, 13, 43, 15),
|
235
|
+
:expires => 90,
|
236
|
+
:originator => "HeaderSigningTest",
|
237
|
+
:email_address => "Anonymous",
|
238
|
+
:display_name => "Anonymous",
|
239
|
+
:profile_image => "abcdefg")
|
240
|
+
|
241
|
+
@authorized_request = Pandexio::to_authorized_request(normalized_request, signing_options)
|
242
|
+
end
|
243
|
+
|
244
|
+
it "returns the correct authorization header" do
|
245
|
+
@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"
|
246
|
+
end
|
247
|
+
|
248
|
+
end
|
249
|
+
|
250
|
+
end
|
249
251
|
end
|