signet 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/lib/signet/oauth_1.rb +8 -1
- data/lib/signet/version.rb +1 -1
- data/spec/signet/oauth_1_spec.rb +115 -4
- metadata +4 -4
data/CHANGELOG
CHANGED
data/lib/signet/oauth_1.rb
CHANGED
@@ -175,7 +175,14 @@ module Signet #:nodoc:
|
|
175
175
|
raise TypeError, "Expected Enumerable, got #{parameters.class}."
|
176
176
|
end
|
177
177
|
method = method.to_s.upcase
|
178
|
-
|
178
|
+
parsed_uri = Addressable::URI.parse(uri)
|
179
|
+
uri = Addressable::URI.new(
|
180
|
+
:scheme => parsed_uri.normalized_scheme,
|
181
|
+
:authority => parsed_uri.normalized_authority,
|
182
|
+
:path => parsed_uri.path,
|
183
|
+
:query => parsed_uri.query,
|
184
|
+
:fragment => parsed_uri.fragment
|
185
|
+
)
|
179
186
|
uri_parameters = uri.query_values.to_a
|
180
187
|
uri = uri.omit(:query, :fragment).to_s
|
181
188
|
merged_parameters =
|
data/lib/signet/version.rb
CHANGED
data/spec/signet/oauth_1_spec.rb
CHANGED
@@ -101,7 +101,72 @@ describe Signet::OAuth1 do
|
|
101
101
|
)
|
102
102
|
end
|
103
103
|
|
104
|
-
it
|
104
|
+
it "should correctly generate a base string with an already encoded URI" do
|
105
|
+
method = "GET"
|
106
|
+
uri = "http://photos.example.net/https%3A%2F%2Fwww.example.com"
|
107
|
+
parameters = {
|
108
|
+
"oauth_consumer_key" => "dpf43f3p2l4k3l03",
|
109
|
+
"oauth_token" => "nnch734d00sl2jdk",
|
110
|
+
"oauth_signature_method" => "HMAC-SHA1",
|
111
|
+
"oauth_timestamp" => "1191242096",
|
112
|
+
"oauth_nonce" => "kllo9940pd9333jh",
|
113
|
+
"oauth_version" => "1.0",
|
114
|
+
"file" => "vacation.jpg",
|
115
|
+
"size" => "original"
|
116
|
+
}
|
117
|
+
Signet::OAuth1.generate_base_string(method, uri, parameters).should == (
|
118
|
+
"GET&http%3A%2F%2Fphotos.example.net%2F" +
|
119
|
+
"https%253A%252F%252Fwww.example.com&file%3Dvacation.jpg%26" +
|
120
|
+
"oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
|
121
|
+
"oauth_nonce%3Dkllo9940pd9333jh%26" +
|
122
|
+
"oauth_signature_method%3DHMAC-SHA1%26" +
|
123
|
+
"oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" +
|
124
|
+
"oauth_version%3D1.0%26size%3Doriginal"
|
125
|
+
)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should correctly generate a base string with an already encoded URI" do
|
129
|
+
method = "GET"
|
130
|
+
uri = "http://example.com/r%20v/X?id=123"
|
131
|
+
parameters = {
|
132
|
+
"oauth_consumer_key" => "dpf43f3p2l4k3l03",
|
133
|
+
"oauth_token" => "nnch734d00sl2jdk",
|
134
|
+
"oauth_signature_method" => "HMAC-SHA1",
|
135
|
+
"oauth_timestamp" => "1191242096",
|
136
|
+
"oauth_nonce" => "kllo9940pd9333jh",
|
137
|
+
"oauth_version" => "1.0"
|
138
|
+
}
|
139
|
+
Signet::OAuth1.generate_base_string(method, uri, parameters).should == (
|
140
|
+
"GET&http%3A%2F%2Fexample.com%2Fr%2520v%2FX&" +
|
141
|
+
"id%3D123%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
|
142
|
+
"oauth_nonce%3Dkllo9940pd9333jh%26" +
|
143
|
+
"oauth_signature_method%3DHMAC-SHA1%26" +
|
144
|
+
"oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" +
|
145
|
+
"oauth_version%3D1.0"
|
146
|
+
)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should correctly generate a base string when port 8080 is specified' do
|
150
|
+
method = "GET"
|
151
|
+
uri = "http://www.example.net:8080/?q=1"
|
152
|
+
parameters = {
|
153
|
+
"oauth_consumer_key" => "dpf43f3p2l4k3l03",
|
154
|
+
"oauth_token" => "nnch734d00sl2jdk",
|
155
|
+
"oauth_signature_method" => "HMAC-SHA1",
|
156
|
+
"oauth_timestamp" => "1191242096",
|
157
|
+
"oauth_nonce" => "kllo9940pd9333jh",
|
158
|
+
"oauth_version" => "1.0"
|
159
|
+
}
|
160
|
+
Signet::OAuth1.generate_base_string(method, uri, parameters).should == (
|
161
|
+
"GET&http%3A%2F%2Fwww.example.net%3A8080%2F&" +
|
162
|
+
"oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
|
163
|
+
"oauth_nonce%3Dkllo9940pd9333jh%26" +
|
164
|
+
"oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26" +
|
165
|
+
"oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26q%3D1"
|
166
|
+
)
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'should correctly generate a base string when port 80 is specified' do
|
105
170
|
method = "GET"
|
106
171
|
uri = "http://photos.example.net:80/photos"
|
107
172
|
parameters = {
|
@@ -124,7 +189,7 @@ describe Signet::OAuth1 do
|
|
124
189
|
)
|
125
190
|
end
|
126
191
|
|
127
|
-
it 'should correctly generate a base string
|
192
|
+
it 'should correctly generate a base string when port 443 is specified' do
|
128
193
|
method = "GET"
|
129
194
|
uri = "https://photos.example.net:443/photos"
|
130
195
|
parameters = {
|
@@ -147,10 +212,56 @@ describe Signet::OAuth1 do
|
|
147
212
|
)
|
148
213
|
end
|
149
214
|
|
150
|
-
it 'should correctly generate a base signature' do
|
215
|
+
it 'should correctly generate a base signature with uppercase scheme' do
|
216
|
+
method = 'GET'
|
217
|
+
uri =
|
218
|
+
"HTTP://photos.example.net/photos?file=vacation.jpg"
|
219
|
+
parameters = {
|
220
|
+
"oauth_consumer_key" => "dpf43f3p2l4k3l03",
|
221
|
+
"oauth_token" => "nnch734d00sl2jdk",
|
222
|
+
"oauth_signature_method" => "HMAC-SHA1",
|
223
|
+
"oauth_timestamp" => "1191242096",
|
224
|
+
"oauth_nonce" => "kllo9940pd9333jh",
|
225
|
+
"oauth_version" => "1.0",
|
226
|
+
"size" => "original"
|
227
|
+
}
|
228
|
+
Signet::OAuth1.generate_base_string(method, uri, parameters).should == (
|
229
|
+
"GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" +
|
230
|
+
"oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
|
231
|
+
"oauth_nonce%3Dkllo9940pd9333jh%26" +
|
232
|
+
"oauth_signature_method%3DHMAC-SHA1%26" +
|
233
|
+
"oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" +
|
234
|
+
"oauth_version%3D1.0%26size%3Doriginal"
|
235
|
+
)
|
236
|
+
end
|
237
|
+
|
238
|
+
it 'should correctly generate a base signature with mixedcase authority' do
|
239
|
+
method = 'GET'
|
240
|
+
uri =
|
241
|
+
"http://photos.eXaMpLe.NET/photos?file=vacation.jpg"
|
242
|
+
parameters = {
|
243
|
+
"oauth_consumer_key" => "dpf43f3p2l4k3l03",
|
244
|
+
"oauth_token" => "nnch734d00sl2jdk",
|
245
|
+
"oauth_signature_method" => "HMAC-SHA1",
|
246
|
+
"oauth_timestamp" => "1191242096",
|
247
|
+
"oauth_nonce" => "kllo9940pd9333jh",
|
248
|
+
"oauth_version" => "1.0",
|
249
|
+
"size" => "original"
|
250
|
+
}
|
251
|
+
Signet::OAuth1.generate_base_string(method, uri, parameters).should == (
|
252
|
+
"GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" +
|
253
|
+
"oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
|
254
|
+
"oauth_nonce%3Dkllo9940pd9333jh%26" +
|
255
|
+
"oauth_signature_method%3DHMAC-SHA1%26" +
|
256
|
+
"oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" +
|
257
|
+
"oauth_version%3D1.0%26size%3Doriginal"
|
258
|
+
)
|
259
|
+
end
|
260
|
+
|
261
|
+
it 'should correctly generate a base signature with a method symbol' do
|
151
262
|
method = :get
|
152
263
|
uri =
|
153
|
-
"
|
264
|
+
"http://photos.example.net/photos?file=vacation.jpg"
|
154
265
|
parameters = {
|
155
266
|
"oauth_consumer_key" => "dpf43f3p2l4k3l03",
|
156
267
|
"oauth_token" => "nnch734d00sl2jdk",
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: signet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bob Aman
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-05 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|