signet 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/CHANGELOG.md +7 -0
- data/Gemfile +2 -19
- data/lib/signet/oauth_2/client.rb +82 -50
- data/lib/signet/oauth_2.rb +9 -2
- data/lib/signet/version.rb +2 -2
- data/signet.gemspec +38 -0
- data/spec/signet/oauth_1/client_spec.rb +231 -243
- data/spec/signet/oauth_1/credential_spec.rb +30 -30
- data/spec/signet/oauth_1/server_spec.rb +128 -129
- data/spec/signet/oauth_1/services/google_spec.rb +24 -25
- data/spec/signet/oauth_1/signature_methods/hmac_sha1_spec.rb +4 -4
- data/spec/signet/oauth_1/signature_methods/plaintext_spec.rb +4 -4
- data/spec/signet/oauth_1/signature_methods/rsa_sha1_spec.rb +6 -6
- data/spec/signet/oauth_1_spec.rb +190 -192
- data/spec/signet/oauth_2/client_spec.rb +296 -181
- data/spec/signet/oauth_2_spec.rb +58 -48
- data/spec/signet_spec.rb +23 -23
- data/spec/spec_helper.rb +3 -1
- data/tasks/gem.rake +3 -55
- data/tasks/spec.rake +0 -25
- metadata +99 -38
data/spec/signet/oauth_1_spec.rb
CHANGED
@@ -33,8 +33,8 @@ describe Signet::OAuth1 do
|
|
33
33
|
["z", "p"],
|
34
34
|
["z", "t"]
|
35
35
|
]
|
36
|
-
Signet::OAuth1.normalize_parameters(parameters).
|
37
|
-
'a=1&c=hi%20there&f=25&f=50&f=a&z=p&z=t'
|
36
|
+
expect(Signet::OAuth1.normalize_parameters(parameters)).to eq(
|
37
|
+
'a=1&c=hi%20there&f=25&f=50&f=a&z=p&z=t')
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'should correctly normalize parameters' do
|
@@ -51,10 +51,10 @@ describe Signet::OAuth1 do
|
|
51
51
|
["c2", ""],
|
52
52
|
["a3", "2 q"]
|
53
53
|
]
|
54
|
-
Signet::OAuth1.normalize_parameters(parameters).
|
54
|
+
expect(Signet::OAuth1.normalize_parameters(parameters)).to eq(
|
55
55
|
'a2=r%20b&a3=2%20q&a3=a&b5=%3D%253D&c%40=&c2=&oauth_consumer_key=9dj' +
|
56
56
|
'dj82h48djs9d2&oauth_nonce=7d8f3e4a&oauth_signature_method=HMAC-SHA1' +
|
57
|
-
'&oauth_timestamp=137131201&oauth_token=kkk9d7dh3k39sjv7'
|
57
|
+
'&oauth_timestamp=137131201&oauth_token=kkk9d7dh3k39sjv7')
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'should exclude the "oauth_signature" parameter when normalizing' do
|
@@ -64,22 +64,22 @@ describe Signet::OAuth1 do
|
|
64
64
|
["c", "3"],
|
65
65
|
["oauth_signature", "dpf43f3p2l4k3l03"]
|
66
66
|
]
|
67
|
-
Signet::OAuth1.normalize_parameters(parameters).
|
68
|
-
"a=1&b=2&c=3"
|
67
|
+
expect(Signet::OAuth1.normalize_parameters(parameters)).to eq(
|
68
|
+
"a=1&b=2&c=3")
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'should raise an error if normalizing parameters with bogus values' do
|
72
|
-
(lambda do
|
72
|
+
expect(lambda do
|
73
73
|
Signet::OAuth1.normalize_parameters(42)
|
74
|
-
end).
|
74
|
+
end).to raise_error(TypeError)
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'should raise an error if generating a base string with bogus values' do
|
78
|
-
(lambda do
|
78
|
+
expect(lambda do
|
79
79
|
Signet::OAuth1.generate_base_string(
|
80
80
|
"GET", "http://photos.example.net/photos", 42
|
81
81
|
)
|
82
|
-
end).
|
82
|
+
end).to raise_error(TypeError)
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'should correctly generate a base string' do
|
@@ -95,7 +95,7 @@ describe Signet::OAuth1 do
|
|
95
95
|
"file" => "vacation.jpg",
|
96
96
|
"size" => "original"
|
97
97
|
}
|
98
|
-
Signet::OAuth1.generate_base_string(method, uri, parameters).
|
98
|
+
expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
|
99
99
|
"GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" +
|
100
100
|
"oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
|
101
101
|
"oauth_nonce%3Dkllo9940pd9333jh%26" +
|
@@ -118,7 +118,7 @@ describe Signet::OAuth1 do
|
|
118
118
|
"file" => "vacation.jpg",
|
119
119
|
"size" => "original"
|
120
120
|
}
|
121
|
-
Signet::OAuth1.generate_base_string(method, uri, parameters).
|
121
|
+
expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
|
122
122
|
"GET&http%3A%2F%2Fphotos.example.net%2F" +
|
123
123
|
"https%253A%252F%252Fwww.example.com&file%3Dvacation.jpg%26" +
|
124
124
|
"oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
|
@@ -140,7 +140,7 @@ describe Signet::OAuth1 do
|
|
140
140
|
"oauth_nonce" => "kllo9940pd9333jh",
|
141
141
|
"oauth_version" => "1.0"
|
142
142
|
}
|
143
|
-
Signet::OAuth1.generate_base_string(method, uri, parameters).
|
143
|
+
expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
|
144
144
|
"GET&http%3A%2F%2Fexample.com%2Fr%2520v%2FX&" +
|
145
145
|
"id%3D123%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
|
146
146
|
"oauth_nonce%3Dkllo9940pd9333jh%26" +
|
@@ -161,7 +161,7 @@ describe Signet::OAuth1 do
|
|
161
161
|
"oauth_nonce" => "kllo9940pd9333jh",
|
162
162
|
"oauth_version" => "1.0"
|
163
163
|
}
|
164
|
-
Signet::OAuth1.generate_base_string(method, uri, parameters).
|
164
|
+
expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
|
165
165
|
"GET&http%3A%2F%2Fwww.example.net%3A8080%2F&" +
|
166
166
|
"oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
|
167
167
|
"oauth_nonce%3Dkllo9940pd9333jh%26" +
|
@@ -183,7 +183,7 @@ describe Signet::OAuth1 do
|
|
183
183
|
"file" => "vacation.jpg",
|
184
184
|
"size" => "original"
|
185
185
|
}
|
186
|
-
Signet::OAuth1.generate_base_string(method, uri, parameters).
|
186
|
+
expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
|
187
187
|
"GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" +
|
188
188
|
"oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
|
189
189
|
"oauth_nonce%3Dkllo9940pd9333jh%26" +
|
@@ -206,7 +206,7 @@ describe Signet::OAuth1 do
|
|
206
206
|
"file" => "vacation.jpg",
|
207
207
|
"size" => "original"
|
208
208
|
}
|
209
|
-
Signet::OAuth1.generate_base_string(method, uri, parameters).
|
209
|
+
expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
|
210
210
|
"GET&https%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" +
|
211
211
|
"oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
|
212
212
|
"oauth_nonce%3Dkllo9940pd9333jh%26" +
|
@@ -229,7 +229,7 @@ describe Signet::OAuth1 do
|
|
229
229
|
"oauth_version" => "1.0",
|
230
230
|
"size" => "original"
|
231
231
|
}
|
232
|
-
Signet::OAuth1.generate_base_string(method, uri, parameters).
|
232
|
+
expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
|
233
233
|
"GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" +
|
234
234
|
"oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
|
235
235
|
"oauth_nonce%3Dkllo9940pd9333jh%26" +
|
@@ -252,7 +252,7 @@ describe Signet::OAuth1 do
|
|
252
252
|
"oauth_version" => "1.0",
|
253
253
|
"size" => "original"
|
254
254
|
}
|
255
|
-
Signet::OAuth1.generate_base_string(method, uri, parameters).
|
255
|
+
expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
|
256
256
|
"GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" +
|
257
257
|
"oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
|
258
258
|
"oauth_nonce%3Dkllo9940pd9333jh%26" +
|
@@ -275,7 +275,7 @@ describe Signet::OAuth1 do
|
|
275
275
|
"oauth_version" => "1.0",
|
276
276
|
"size" => "original"
|
277
277
|
}
|
278
|
-
Signet::OAuth1.generate_base_string(method, uri, parameters).
|
278
|
+
expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
|
279
279
|
"GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" +
|
280
280
|
"oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
|
281
281
|
"oauth_nonce%3Dkllo9940pd9333jh%26" +
|
@@ -295,9 +295,9 @@ describe Signet::OAuth1 do
|
|
295
295
|
["oauth_nonce", "4572616e48616d6d65724c61686176"],
|
296
296
|
["oauth_version", "1.0"]
|
297
297
|
]
|
298
|
-
Signet::OAuth1.generate_authorization_header(
|
298
|
+
expect(Signet::OAuth1.generate_authorization_header(
|
299
299
|
parameters, "http://sp.example.com/"
|
300
|
-
).
|
300
|
+
)).to eq (
|
301
301
|
'OAuth realm="http://sp.example.com/", ' +
|
302
302
|
'oauth_consumer_key="0685bd9184jfhq22", ' +
|
303
303
|
'oauth_token="ad180jjd733klru7", ' +
|
@@ -311,9 +311,9 @@ describe Signet::OAuth1 do
|
|
311
311
|
|
312
312
|
it 'should raise an error if generating an authorization header ' +
|
313
313
|
'with bogus values' do
|
314
|
-
(lambda do
|
314
|
+
expect(lambda do
|
315
315
|
Signet::OAuth1.generate_authorization_header(42)
|
316
|
-
end).
|
316
|
+
end).to raise_error(TypeError)
|
317
317
|
end
|
318
318
|
|
319
319
|
it 'should raise an error if generating an authorization header ' +
|
@@ -328,9 +328,9 @@ describe Signet::OAuth1 do
|
|
328
328
|
["oauth_nonce", "4572616e48616d6d65724c61686176"],
|
329
329
|
["oauth_version", "1.0"]
|
330
330
|
]
|
331
|
-
(lambda do
|
331
|
+
expect(lambda do
|
332
332
|
Signet::OAuth1.generate_authorization_header(parameters)
|
333
|
-
end).
|
333
|
+
end).to raise_error(ArgumentError)
|
334
334
|
end
|
335
335
|
|
336
336
|
it 'should correctly parse an authorization header' do
|
@@ -344,14 +344,14 @@ describe Signet::OAuth1 do
|
|
344
344
|
'oauth_nonce="4572616e48616d6d65724c61686176", ' +
|
345
345
|
'oauth_version="1.0"'
|
346
346
|
).inject({}) { |h,(k,v)| h[k]=v; h }
|
347
|
-
parameters['realm'].
|
348
|
-
parameters['oauth_consumer_key'].
|
349
|
-
parameters['oauth_token'].
|
350
|
-
parameters['oauth_signature_method'].
|
351
|
-
parameters['oauth_signature'].
|
352
|
-
parameters['oauth_timestamp'].
|
353
|
-
parameters['oauth_nonce'].
|
354
|
-
parameters['oauth_version'].
|
347
|
+
expect(parameters['realm']).to eq 'http://sp.example.com/'
|
348
|
+
expect(parameters['oauth_consumer_key']).to eq '0685bd9184jfhq22'
|
349
|
+
expect(parameters['oauth_token']).to eq 'ad180jjd733klru7'
|
350
|
+
expect(parameters['oauth_signature_method']).to eq 'HMAC-SHA1'
|
351
|
+
expect(parameters['oauth_signature']).to eq 'wOJIO9A2W5mFwDgiDvZbTSMK/PY='
|
352
|
+
expect(parameters['oauth_timestamp']).to eq '137131200'
|
353
|
+
expect(parameters['oauth_nonce']).to eq '4572616e48616d6d65724c61686176'
|
354
|
+
expect(parameters['oauth_version']).to eq '1.0'
|
355
355
|
end
|
356
356
|
|
357
357
|
it 'should not unescape a realm in an authorization header' do
|
@@ -366,38 +366,38 @@ describe Signet::OAuth1 do
|
|
366
366
|
'oauth_nonce="4572616e48616d6d65724c61686176", ' +
|
367
367
|
'oauth_version="1.0"'
|
368
368
|
).inject({}) { |h,(k,v)| h[k]=v; h }
|
369
|
-
parameters['realm'].
|
370
|
-
parameters['domain'].
|
371
|
-
parameters['oauth_consumer_key'].
|
372
|
-
parameters['oauth_token'].
|
373
|
-
parameters['oauth_signature_method'].
|
374
|
-
parameters['oauth_signature'].
|
375
|
-
parameters['oauth_timestamp'].
|
376
|
-
parameters['oauth_nonce'].
|
377
|
-
parameters['oauth_version'].
|
369
|
+
expect(parameters['realm']).to eq 'http%3A%2F%2Fsp.example.com%2F'
|
370
|
+
expect(parameters['domain']).to eq 'http://sp.example.com/'
|
371
|
+
expect(parameters['oauth_consumer_key']).to eq '0685bd9184jfhq22'
|
372
|
+
expect(parameters['oauth_token']).to eq 'ad180jjd733klru7'
|
373
|
+
expect(parameters['oauth_signature_method']).to eq 'HMAC-SHA1'
|
374
|
+
expect(parameters['oauth_signature']).to eq 'wOJIO9A2W5mFwDgiDvZbTSMK/PY='
|
375
|
+
expect(parameters['oauth_timestamp']).to eq '137131200'
|
376
|
+
expect(parameters['oauth_nonce']).to eq '4572616e48616d6d65724c61686176'
|
377
|
+
expect(parameters['oauth_version']).to eq '1.0'
|
378
378
|
end
|
379
379
|
|
380
380
|
it 'should raise an error if parsing an authorization header ' +
|
381
381
|
'with bogus values' do
|
382
|
-
(lambda do
|
382
|
+
expect(lambda do
|
383
383
|
Signet::OAuth1.parse_authorization_header(42)
|
384
|
-
end).
|
384
|
+
end).to raise_error(TypeError)
|
385
385
|
end
|
386
386
|
|
387
387
|
it 'should raise an error if parsing a non-OAuth authorization header' do
|
388
|
-
(lambda do
|
388
|
+
expect(lambda do
|
389
389
|
Signet::OAuth1.parse_authorization_header(
|
390
390
|
'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
|
391
391
|
)
|
392
|
-
end).
|
392
|
+
end).to raise_error(Signet::ParseError)
|
393
393
|
end
|
394
394
|
|
395
395
|
it 'should correctly parse a form encoded credential' do
|
396
396
|
credential = Signet::OAuth1.parse_form_encoded_credentials(
|
397
397
|
'oauth_token=hh5s93j4hdidpola&oauth_token_secret=hdhd0244k9j7ao03'
|
398
398
|
)
|
399
|
-
credential.key.
|
400
|
-
credential.secret.
|
399
|
+
expect(credential.key).to eq 'hh5s93j4hdidpola'
|
400
|
+
expect(credential.secret).to eq 'hdhd0244k9j7ao03'
|
401
401
|
end
|
402
402
|
|
403
403
|
it 'should correctly parse a form encoded credential' do
|
@@ -405,15 +405,15 @@ describe Signet::OAuth1 do
|
|
405
405
|
'oauth_token=hdk48Djdsa&oauth_token_secret=xyz4992k83j47x0b&' +
|
406
406
|
'oauth_callback_confirmed=true'
|
407
407
|
)
|
408
|
-
credential.key.
|
409
|
-
credential.secret.
|
408
|
+
expect(credential.key).to eq 'hdk48Djdsa'
|
409
|
+
expect(credential.secret).to eq 'xyz4992k83j47x0b'
|
410
410
|
end
|
411
411
|
|
412
412
|
it 'should raise an error if parsing a form encoded credential ' +
|
413
413
|
'with bogus values' do
|
414
|
-
(lambda do
|
414
|
+
expect(lambda do
|
415
415
|
Signet::OAuth1.parse_form_encoded_credentials(42)
|
416
|
-
end).
|
416
|
+
end).to raise_error(TypeError)
|
417
417
|
end
|
418
418
|
|
419
419
|
it 'should correctly generate a signature for a set of parameters' do
|
@@ -431,13 +431,13 @@ describe Signet::OAuth1 do
|
|
431
431
|
"file" => "vacation.jpg",
|
432
432
|
"size" => "original"
|
433
433
|
}
|
434
|
-
Signet::OAuth1.sign_parameters(
|
434
|
+
expect(Signet::OAuth1.sign_parameters(
|
435
435
|
method,
|
436
436
|
uri,
|
437
437
|
parameters,
|
438
438
|
client_credential_secret,
|
439
439
|
token_credential_secret
|
440
|
-
).
|
440
|
+
)).to eq "tR3+Ty81lMeYAr/Fid0kMTYa/WM="
|
441
441
|
end
|
442
442
|
|
443
443
|
it 'should raise an error when trying to sign with with unknown method' do
|
@@ -455,7 +455,7 @@ describe Signet::OAuth1 do
|
|
455
455
|
"file" => "vacation.jpg",
|
456
456
|
"size" => "original"
|
457
457
|
}
|
458
|
-
(lambda do
|
458
|
+
expect(lambda do
|
459
459
|
Signet::OAuth1.sign_parameters(
|
460
460
|
method,
|
461
461
|
uri,
|
@@ -463,7 +463,7 @@ describe Signet::OAuth1 do
|
|
463
463
|
client_credential_secret,
|
464
464
|
token_credential_secret
|
465
465
|
)
|
466
|
-
end).
|
466
|
+
end).to raise_error(NotImplementedError)
|
467
467
|
end
|
468
468
|
|
469
469
|
it 'should correctly generate authorization URIs' do
|
@@ -477,10 +477,10 @@ describe Signet::OAuth1 do
|
|
477
477
|
:callback => callback
|
478
478
|
)
|
479
479
|
)
|
480
|
-
parsed_uri.query_values.
|
481
|
-
parsed_uri.query_values['oauth_token'].
|
482
|
-
parsed_uri.query_values.
|
483
|
-
parsed_uri.query_values['oauth_callback'].
|
480
|
+
expect(parsed_uri.query_values).to have_key('oauth_token')
|
481
|
+
expect(parsed_uri.query_values['oauth_token']).to eq temporary_credential_key
|
482
|
+
expect(parsed_uri.query_values).to have_key('oauth_callback')
|
483
|
+
expect(parsed_uri.query_values['oauth_callback']).to eq callback
|
484
484
|
end
|
485
485
|
end
|
486
486
|
|
@@ -501,55 +501,55 @@ describe Signet::OAuth1, 'when generating temporary credentials parameters' do
|
|
501
501
|
end
|
502
502
|
|
503
503
|
it 'should raise an error if the client credential key is missing' do
|
504
|
-
(lambda do
|
504
|
+
expect(lambda do
|
505
505
|
Signet::OAuth1.unsigned_temporary_credential_parameters(
|
506
506
|
:client_credential_key => nil,
|
507
507
|
:callback => @callback,
|
508
508
|
:signature_method => @signature_method,
|
509
509
|
:additional_parameters => @additional_parameters
|
510
510
|
)
|
511
|
-
end).
|
511
|
+
end).to raise_error(ArgumentError)
|
512
512
|
end
|
513
513
|
|
514
514
|
it 'should have the correct client credential key' do
|
515
|
-
@unsigned_parameters.
|
516
|
-
@unsigned_parameters['oauth_consumer_key'].
|
515
|
+
expect(@unsigned_parameters).to have_key('oauth_consumer_key')
|
516
|
+
expect(@unsigned_parameters['oauth_consumer_key']).to eq @client_credential_key
|
517
517
|
end
|
518
518
|
|
519
519
|
it 'should have the correct signature method' do
|
520
|
-
@unsigned_parameters.
|
521
|
-
@unsigned_parameters['oauth_signature_method'].
|
520
|
+
expect(@unsigned_parameters).to have_key('oauth_signature_method')
|
521
|
+
expect(@unsigned_parameters['oauth_signature_method']).to eq @signature_method
|
522
522
|
end
|
523
523
|
|
524
524
|
it 'should have a valid timestamp' do
|
525
525
|
# Verify that we have a timestamp, it's in the correct format and within
|
526
526
|
# a reasonable range of the current time.
|
527
|
-
@unsigned_parameters.
|
528
|
-
@unsigned_parameters['oauth_timestamp'].
|
529
|
-
@unsigned_parameters['oauth_timestamp'].to_i.
|
530
|
-
@unsigned_parameters['oauth_timestamp'].to_i.
|
527
|
+
expect(@unsigned_parameters).to have_key('oauth_timestamp')
|
528
|
+
expect(@unsigned_parameters['oauth_timestamp']).to match(/^[0-9]+$/)
|
529
|
+
expect(@unsigned_parameters['oauth_timestamp'].to_i).to be <= Time.now.to_i
|
530
|
+
expect(@unsigned_parameters['oauth_timestamp'].to_i).to be >= Time.now.to_i - 1
|
531
531
|
end
|
532
532
|
|
533
533
|
it 'should have a valid nonce' do
|
534
534
|
# Verify that we have a nonce and that it has sufficient length for
|
535
535
|
# uniqueness.
|
536
|
-
@unsigned_parameters.
|
537
|
-
@unsigned_parameters['oauth_nonce'].
|
536
|
+
expect(@unsigned_parameters).to have_key('oauth_nonce')
|
537
|
+
expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
|
538
538
|
end
|
539
539
|
|
540
540
|
it 'should have the correct callback' do
|
541
|
-
@unsigned_parameters.
|
542
|
-
@unsigned_parameters['oauth_callback'].
|
541
|
+
expect(@unsigned_parameters).to have_key('oauth_callback')
|
542
|
+
expect(@unsigned_parameters['oauth_callback']).to eq @callback
|
543
543
|
end
|
544
544
|
|
545
545
|
it 'should have the correct scope parameter' do
|
546
|
-
@unsigned_parameters.
|
547
|
-
@unsigned_parameters['scope'].
|
546
|
+
expect(@unsigned_parameters).to have_key('scope')
|
547
|
+
expect(@unsigned_parameters['scope']).to eq @scope
|
548
548
|
end
|
549
549
|
|
550
550
|
it 'should have the correct OAuth version' do
|
551
|
-
@unsigned_parameters.
|
552
|
-
@unsigned_parameters['oauth_version'].
|
551
|
+
expect(@unsigned_parameters).to have_key('oauth_version')
|
552
|
+
expect(@unsigned_parameters['oauth_version']).to eq '1.0'
|
553
553
|
end
|
554
554
|
end
|
555
555
|
|
@@ -569,77 +569,77 @@ describe Signet::OAuth1, 'when generating token credential parameters' do
|
|
569
569
|
end
|
570
570
|
|
571
571
|
it 'should raise an error if the client credential key is missing' do
|
572
|
-
(lambda do
|
572
|
+
expect(lambda do
|
573
573
|
Signet::OAuth1.unsigned_token_credential_parameters(
|
574
574
|
:client_credential_key => nil,
|
575
575
|
:temporary_credential_key => @temporary_credential_key,
|
576
576
|
:signature_method => @signature_method,
|
577
577
|
:verifier => @verifier
|
578
578
|
)
|
579
|
-
end).
|
579
|
+
end).to raise_error(ArgumentError)
|
580
580
|
end
|
581
581
|
|
582
582
|
it 'should raise an error if the temporary credential key is missing' do
|
583
|
-
(lambda do
|
583
|
+
expect(lambda do
|
584
584
|
Signet::OAuth1.unsigned_token_credential_parameters(
|
585
585
|
:client_credential_key => @client_credential_key,
|
586
586
|
:temporary_credential_key => nil,
|
587
587
|
:signature_method => @signature_method,
|
588
588
|
:verifier => @verifier
|
589
589
|
)
|
590
|
-
end).
|
590
|
+
end).to raise_error(ArgumentError)
|
591
591
|
end
|
592
592
|
|
593
593
|
it 'should raise an error if the verifier is missing' do
|
594
|
-
(lambda do
|
594
|
+
expect(lambda do
|
595
595
|
Signet::OAuth1.unsigned_token_credential_parameters(
|
596
596
|
:client_credential_key => @client_credential_key,
|
597
597
|
:temporary_credential_key => @temporary_credential_key,
|
598
598
|
:signature_method => @signature_method,
|
599
599
|
:verifier => nil
|
600
600
|
)
|
601
|
-
end).
|
601
|
+
end).to raise_error(ArgumentError)
|
602
602
|
end
|
603
603
|
|
604
604
|
it 'should have the correct client credential key' do
|
605
|
-
@unsigned_parameters.
|
606
|
-
@unsigned_parameters['oauth_consumer_key'].
|
605
|
+
expect(@unsigned_parameters).to have_key('oauth_consumer_key')
|
606
|
+
expect(@unsigned_parameters['oauth_consumer_key']).to eq @client_credential_key
|
607
607
|
end
|
608
608
|
|
609
609
|
it 'should have the correct temporary credentials key' do
|
610
|
-
@unsigned_parameters.
|
611
|
-
@unsigned_parameters['oauth_token'].
|
610
|
+
expect(@unsigned_parameters).to have_key('oauth_token')
|
611
|
+
expect(@unsigned_parameters['oauth_token']).to eq @temporary_credential_key
|
612
612
|
end
|
613
613
|
|
614
614
|
it 'should have the correct signature method' do
|
615
|
-
@unsigned_parameters.
|
616
|
-
@unsigned_parameters['oauth_signature_method'].
|
615
|
+
expect(@unsigned_parameters).to have_key('oauth_signature_method')
|
616
|
+
expect(@unsigned_parameters['oauth_signature_method']).to eq @signature_method
|
617
617
|
end
|
618
618
|
|
619
619
|
it 'should have a valid timestamp' do
|
620
620
|
# Verify that we have a timestamp, it's in the correct format and within
|
621
621
|
# a reasonable range of the current time.
|
622
|
-
@unsigned_parameters.
|
623
|
-
@unsigned_parameters['oauth_timestamp'].
|
624
|
-
@unsigned_parameters['oauth_timestamp'].to_i.
|
625
|
-
@unsigned_parameters['oauth_timestamp'].to_i.
|
622
|
+
expect(@unsigned_parameters).to have_key('oauth_timestamp')
|
623
|
+
expect(@unsigned_parameters['oauth_timestamp']).to match(/^[0-9]+$/)
|
624
|
+
expect(@unsigned_parameters['oauth_timestamp'].to_i).to be <= Time.now.to_i
|
625
|
+
expect(@unsigned_parameters['oauth_timestamp'].to_i).to be >= Time.now.to_i - 1
|
626
626
|
end
|
627
627
|
|
628
628
|
it 'should have a valid nonce' do
|
629
629
|
# Verify that we have a nonce and that it has sufficient length for
|
630
630
|
# uniqueness.
|
631
|
-
@unsigned_parameters.
|
632
|
-
@unsigned_parameters['oauth_nonce'].
|
631
|
+
expect(@unsigned_parameters).to have_key('oauth_nonce')
|
632
|
+
expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
|
633
633
|
end
|
634
634
|
|
635
635
|
it 'should have the verifier' do
|
636
|
-
@unsigned_parameters.
|
637
|
-
@unsigned_parameters['oauth_verifier'].
|
636
|
+
expect(@unsigned_parameters).to have_key('oauth_verifier')
|
637
|
+
expect(@unsigned_parameters['oauth_verifier']).to eq @verifier
|
638
638
|
end
|
639
639
|
|
640
640
|
it 'should have the correct OAuth version' do
|
641
|
-
@unsigned_parameters.
|
642
|
-
@unsigned_parameters['oauth_version'].
|
641
|
+
expect(@unsigned_parameters).to have_key('oauth_version')
|
642
|
+
expect(@unsigned_parameters['oauth_version']).to eq '1.0'
|
643
643
|
end
|
644
644
|
end
|
645
645
|
|
@@ -657,59 +657,59 @@ describe Signet::OAuth1, 'when generating protected resource parameters' do
|
|
657
657
|
end
|
658
658
|
|
659
659
|
it 'should raise an error if the client credential key is missing' do
|
660
|
-
(lambda do
|
660
|
+
expect(lambda do
|
661
661
|
Signet::OAuth1.unsigned_resource_parameters(
|
662
662
|
:client_credential_key => nil,
|
663
663
|
:token_credential_key => @token_credential_key,
|
664
664
|
:signature_method => @signature_method
|
665
665
|
)
|
666
|
-
end).
|
666
|
+
end).to raise_error(ArgumentError)
|
667
667
|
end
|
668
668
|
|
669
669
|
it 'should raise an error if the token credential key is missing' do
|
670
|
-
(lambda do
|
670
|
+
expect(lambda do
|
671
671
|
Signet::OAuth1.unsigned_resource_parameters(
|
672
672
|
:client_credential_key => @client_credential_key,
|
673
673
|
:token_credential_key => nil,
|
674
674
|
:signature_method => @signature_method
|
675
675
|
)
|
676
|
-
end).
|
676
|
+
end).to raise_error(ArgumentError)
|
677
677
|
end
|
678
678
|
|
679
679
|
it 'should have the correct client credential key' do
|
680
|
-
@unsigned_parameters.
|
681
|
-
@unsigned_parameters['oauth_consumer_key'].
|
680
|
+
expect(@unsigned_parameters).to have_key('oauth_consumer_key')
|
681
|
+
expect(@unsigned_parameters['oauth_consumer_key']).to eq @client_credential_key
|
682
682
|
end
|
683
683
|
|
684
684
|
it 'should have the correct token credentials key' do
|
685
|
-
@unsigned_parameters.
|
686
|
-
@unsigned_parameters['oauth_token'].
|
685
|
+
expect(@unsigned_parameters).to have_key('oauth_token')
|
686
|
+
expect(@unsigned_parameters['oauth_token']).to eq @token_credential_key
|
687
687
|
end
|
688
688
|
|
689
689
|
it 'should have the correct signature method' do
|
690
|
-
@unsigned_parameters.
|
691
|
-
@unsigned_parameters['oauth_signature_method'].
|
690
|
+
expect(@unsigned_parameters).to have_key('oauth_signature_method')
|
691
|
+
expect(@unsigned_parameters['oauth_signature_method']).to eq @signature_method
|
692
692
|
end
|
693
693
|
|
694
694
|
it 'should have a valid timestamp' do
|
695
695
|
# Verify that we have a timestamp, it's in the correct format and within
|
696
696
|
# a reasonable range of the current time.
|
697
|
-
@unsigned_parameters.
|
698
|
-
@unsigned_parameters['oauth_timestamp'].
|
699
|
-
@unsigned_parameters['oauth_timestamp'].to_i.
|
700
|
-
@unsigned_parameters['oauth_timestamp'].to_i.
|
697
|
+
expect(@unsigned_parameters).to have_key('oauth_timestamp')
|
698
|
+
expect(@unsigned_parameters['oauth_timestamp']).to match(/^[0-9]+$/)
|
699
|
+
expect(@unsigned_parameters['oauth_timestamp'].to_i).to be <= Time.now.to_i
|
700
|
+
expect(@unsigned_parameters['oauth_timestamp'].to_i).to be >= Time.now.to_i - 1
|
701
701
|
end
|
702
702
|
|
703
703
|
it 'should have a valid nonce' do
|
704
704
|
# Verify that we have a nonce and that it has sufficient length for
|
705
705
|
# uniqueness.
|
706
|
-
@unsigned_parameters.
|
707
|
-
@unsigned_parameters['oauth_nonce'].
|
706
|
+
expect(@unsigned_parameters).to have_key('oauth_nonce')
|
707
|
+
expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
|
708
708
|
end
|
709
709
|
|
710
710
|
it 'should have the correct OAuth version' do
|
711
|
-
@unsigned_parameters.
|
712
|
-
@unsigned_parameters['oauth_version'].
|
711
|
+
expect(@unsigned_parameters).to have_key('oauth_version')
|
712
|
+
expect(@unsigned_parameters['oauth_version']).to eq '1.0'
|
713
713
|
end
|
714
714
|
end
|
715
715
|
|
@@ -734,39 +734,39 @@ describe Signet::OAuth1, 'when generating token credential parameters ' +
|
|
734
734
|
end
|
735
735
|
|
736
736
|
it 'should have the correct client credential key' do
|
737
|
-
@unsigned_parameters.
|
738
|
-
@unsigned_parameters['oauth_consumer_key'].
|
737
|
+
expect(@unsigned_parameters).to have_key('oauth_consumer_key')
|
738
|
+
expect(@unsigned_parameters['oauth_consumer_key']).to eq @client_credential.key
|
739
739
|
end
|
740
740
|
|
741
741
|
it 'should have the correct temporary credentials key' do
|
742
|
-
@unsigned_parameters.
|
743
|
-
@unsigned_parameters['oauth_token'].
|
742
|
+
expect(@unsigned_parameters).to have_key('oauth_token')
|
743
|
+
expect(@unsigned_parameters['oauth_token']).to eq @temporary_credential.key
|
744
744
|
end
|
745
745
|
|
746
746
|
it 'should have the correct signature method' do
|
747
|
-
@unsigned_parameters.
|
748
|
-
@unsigned_parameters['oauth_signature_method'].
|
747
|
+
expect(@unsigned_parameters).to have_key('oauth_signature_method')
|
748
|
+
expect(@unsigned_parameters['oauth_signature_method']).to eq @signature_method
|
749
749
|
end
|
750
750
|
|
751
751
|
it 'should have a valid timestamp' do
|
752
752
|
# Verify that we have a timestamp, it's in the correct format and within
|
753
753
|
# a reasonable range of the current time.
|
754
|
-
@unsigned_parameters.
|
755
|
-
@unsigned_parameters['oauth_timestamp'].
|
756
|
-
@unsigned_parameters['oauth_timestamp'].to_i.
|
757
|
-
@unsigned_parameters['oauth_timestamp'].to_i.
|
754
|
+
expect(@unsigned_parameters).to have_key('oauth_timestamp')
|
755
|
+
expect(@unsigned_parameters['oauth_timestamp']).to match(/^[0-9]+$/)
|
756
|
+
expect(@unsigned_parameters['oauth_timestamp'].to_i).to be <= Time.now.to_i
|
757
|
+
expect(@unsigned_parameters['oauth_timestamp'].to_i).to be >= Time.now.to_i - 1
|
758
758
|
end
|
759
759
|
|
760
760
|
it 'should have a valid nonce' do
|
761
761
|
# Verify that we have a nonce and that it has sufficient length for
|
762
762
|
# uniqueness.
|
763
|
-
@unsigned_parameters.
|
764
|
-
@unsigned_parameters['oauth_nonce'].
|
763
|
+
expect(@unsigned_parameters).to have_key('oauth_nonce')
|
764
|
+
expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
|
765
765
|
end
|
766
766
|
|
767
767
|
it 'should have the correct OAuth version' do
|
768
|
-
@unsigned_parameters.
|
769
|
-
@unsigned_parameters['oauth_version'].
|
768
|
+
expect(@unsigned_parameters).to have_key('oauth_version')
|
769
|
+
expect(@unsigned_parameters['oauth_version']).to eq '1.0'
|
770
770
|
end
|
771
771
|
end
|
772
772
|
|
@@ -791,41 +791,39 @@ describe Signet::OAuth1, 'when generating token credential parameters ' +
|
|
791
791
|
end
|
792
792
|
|
793
793
|
it 'should have the correct client credential key' do
|
794
|
-
@unsigned_parameters.
|
795
|
-
@unsigned_parameters['oauth_consumer_key'].
|
796
|
-
@client.client_credential_key
|
794
|
+
expect(@unsigned_parameters).to have_key('oauth_consumer_key')
|
795
|
+
expect(@unsigned_parameters['oauth_consumer_key']).to eq @client.client_credential_key
|
797
796
|
end
|
798
797
|
|
799
798
|
it 'should have the correct temporary credentials key' do
|
800
|
-
@unsigned_parameters.
|
801
|
-
@unsigned_parameters['oauth_token'].
|
802
|
-
@client.temporary_credential_key
|
799
|
+
expect(@unsigned_parameters).to have_key('oauth_token')
|
800
|
+
expect(@unsigned_parameters['oauth_token']).to eq @client.temporary_credential_key
|
803
801
|
end
|
804
802
|
|
805
803
|
it 'should have the correct signature method' do
|
806
|
-
@unsigned_parameters.
|
807
|
-
@unsigned_parameters['oauth_signature_method'].
|
804
|
+
expect(@unsigned_parameters).to have_key('oauth_signature_method')
|
805
|
+
expect(@unsigned_parameters['oauth_signature_method']).to eq @signature_method
|
808
806
|
end
|
809
807
|
|
810
808
|
it 'should have a valid timestamp' do
|
811
809
|
# Verify that we have a timestamp, it's in the correct format and within
|
812
810
|
# a reasonable range of the current time.
|
813
|
-
@unsigned_parameters.
|
814
|
-
@unsigned_parameters['oauth_timestamp'].
|
815
|
-
@unsigned_parameters['oauth_timestamp'].to_i.
|
816
|
-
@unsigned_parameters['oauth_timestamp'].to_i.
|
811
|
+
expect(@unsigned_parameters).to have_key('oauth_timestamp')
|
812
|
+
expect(@unsigned_parameters['oauth_timestamp']).to match(/^[0-9]+$/)
|
813
|
+
expect(@unsigned_parameters['oauth_timestamp'].to_i).to be <= Time.now.to_i
|
814
|
+
expect(@unsigned_parameters['oauth_timestamp'].to_i).to be >= Time.now.to_i - 1
|
817
815
|
end
|
818
816
|
|
819
817
|
it 'should have a valid nonce' do
|
820
818
|
# Verify that we have a nonce and that it has sufficient length for
|
821
819
|
# uniqueness.
|
822
|
-
@unsigned_parameters.
|
823
|
-
@unsigned_parameters['oauth_nonce'].
|
820
|
+
expect(@unsigned_parameters).to have_key('oauth_nonce')
|
821
|
+
expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
|
824
822
|
end
|
825
823
|
|
826
824
|
it 'should have the correct OAuth version' do
|
827
|
-
@unsigned_parameters.
|
828
|
-
@unsigned_parameters['oauth_version'].
|
825
|
+
expect(@unsigned_parameters).to have_key('oauth_version')
|
826
|
+
expect(@unsigned_parameters['oauth_version']).to eq '1.0'
|
829
827
|
end
|
830
828
|
end
|
831
829
|
|
@@ -850,83 +848,83 @@ describe Signet::OAuth1, 'when generating token credential parameters ' +
|
|
850
848
|
end
|
851
849
|
|
852
850
|
it 'should have the correct client credential key' do
|
853
|
-
@unsigned_parameters.
|
854
|
-
@unsigned_parameters['oauth_consumer_key'].
|
851
|
+
expect(@unsigned_parameters).to have_key('oauth_consumer_key')
|
852
|
+
expect(@unsigned_parameters['oauth_consumer_key']).to eq @client_credential.key
|
855
853
|
end
|
856
854
|
|
857
855
|
it 'should have the correct temporary credentials key' do
|
858
|
-
@unsigned_parameters.
|
859
|
-
@unsigned_parameters['oauth_token'].
|
856
|
+
expect(@unsigned_parameters).to have_key('oauth_token')
|
857
|
+
expect(@unsigned_parameters['oauth_token']).to eq @temporary_credential.key
|
860
858
|
end
|
861
859
|
|
862
860
|
it 'should have the correct signature method' do
|
863
|
-
@unsigned_parameters.
|
864
|
-
@unsigned_parameters['oauth_signature_method'].
|
861
|
+
expect(@unsigned_parameters).to have_key('oauth_signature_method')
|
862
|
+
expect(@unsigned_parameters['oauth_signature_method']).to eq @signature_method
|
865
863
|
end
|
866
864
|
|
867
865
|
it 'should have a valid timestamp' do
|
868
866
|
# Verify that we have a timestamp, it's in the correct format and within
|
869
867
|
# a reasonable range of the current time.
|
870
|
-
@unsigned_parameters.
|
871
|
-
@unsigned_parameters['oauth_timestamp'].
|
872
|
-
@unsigned_parameters['oauth_timestamp'].to_i.
|
873
|
-
@unsigned_parameters['oauth_timestamp'].to_i.
|
868
|
+
expect(@unsigned_parameters).to have_key('oauth_timestamp')
|
869
|
+
expect(@unsigned_parameters['oauth_timestamp']).to match(/^[0-9]+$/)
|
870
|
+
expect(@unsigned_parameters['oauth_timestamp'].to_i).to be <= Time.now.to_i
|
871
|
+
expect(@unsigned_parameters['oauth_timestamp'].to_i).to be >= Time.now.to_i - 1
|
874
872
|
end
|
875
873
|
|
876
874
|
it 'should have a valid nonce' do
|
877
875
|
# Verify that we have a nonce and that it has sufficient length for
|
878
876
|
# uniqueness.
|
879
|
-
@unsigned_parameters.
|
880
|
-
@unsigned_parameters['oauth_nonce'].
|
877
|
+
expect(@unsigned_parameters).to have_key('oauth_nonce')
|
878
|
+
expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
|
881
879
|
end
|
882
880
|
|
883
881
|
it 'should have the correct OAuth version' do
|
884
|
-
@unsigned_parameters.
|
885
|
-
@unsigned_parameters['oauth_version'].
|
882
|
+
expect(@unsigned_parameters).to have_key('oauth_version')
|
883
|
+
expect(@unsigned_parameters['oauth_version']).to eq '1.0'
|
886
884
|
end
|
887
885
|
end
|
888
886
|
|
889
887
|
describe Signet::OAuth1, 'extracting credential keys from options' do
|
890
888
|
it 'should raise an error for bogus credentials' do
|
891
|
-
(lambda do
|
889
|
+
expect(lambda do
|
892
890
|
Signet::OAuth1.extract_credential_key_option(
|
893
891
|
:client, {:client_credential_key => true}
|
894
892
|
)
|
895
|
-
end).
|
893
|
+
end).to raise_error(TypeError)
|
896
894
|
end
|
897
895
|
|
898
896
|
it 'should raise an error for bogus credentials' do
|
899
|
-
(lambda do
|
897
|
+
expect(lambda do
|
900
898
|
Signet::OAuth1.extract_credential_key_option(
|
901
899
|
:client, {:client_credential => 42}
|
902
900
|
)
|
903
|
-
end).
|
901
|
+
end).to raise_error(TypeError)
|
904
902
|
end
|
905
903
|
|
906
904
|
it 'should raise an error for bogus credentials' do
|
907
|
-
(lambda do
|
905
|
+
expect(lambda do
|
908
906
|
Signet::OAuth1.extract_credential_key_option(
|
909
907
|
:client, {:client => 42}
|
910
908
|
)
|
911
|
-
end).
|
909
|
+
end).to raise_error(TypeError)
|
912
910
|
end
|
913
911
|
|
914
912
|
it 'should return nil for missing credential key' do
|
915
|
-
Signet::OAuth1.extract_credential_key_option(:client, {}).
|
913
|
+
expect(Signet::OAuth1.extract_credential_key_option(:client, {})).to eq nil
|
916
914
|
end
|
917
915
|
|
918
916
|
it 'should find the correct credential key' do
|
919
|
-
Signet::OAuth1.extract_credential_key_option(
|
917
|
+
expect(Signet::OAuth1.extract_credential_key_option(
|
920
918
|
:client, {:client_credential_key => 'dpf43f3p2l4k3l03'}
|
921
|
-
).
|
919
|
+
)).to eq 'dpf43f3p2l4k3l03'
|
922
920
|
end
|
923
921
|
|
924
922
|
it 'should find the correct credential key' do
|
925
|
-
Signet::OAuth1.extract_credential_key_option(
|
923
|
+
expect(Signet::OAuth1.extract_credential_key_option(
|
926
924
|
:client, {:client_credential => Signet::OAuth1::Credential.new(
|
927
925
|
'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
|
928
926
|
)}
|
929
|
-
).
|
927
|
+
)).to eq 'dpf43f3p2l4k3l03'
|
930
928
|
end
|
931
929
|
|
932
930
|
it 'should find the correct credential key' do
|
@@ -934,9 +932,9 @@ describe Signet::OAuth1, 'extracting credential keys from options' do
|
|
934
932
|
client.client_credential = Signet::OAuth1::Credential.new(
|
935
933
|
'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
|
936
934
|
)
|
937
|
-
Signet::OAuth1.extract_credential_key_option(
|
935
|
+
expect(Signet::OAuth1.extract_credential_key_option(
|
938
936
|
:client, {:client => client}
|
939
|
-
).
|
937
|
+
)).to eq 'dpf43f3p2l4k3l03'
|
940
938
|
end
|
941
939
|
|
942
940
|
it 'should find the correct credential key' do
|
@@ -944,53 +942,53 @@ describe Signet::OAuth1, 'extracting credential keys from options' do
|
|
944
942
|
client.temporary_credential = Signet::OAuth1::Credential.new(
|
945
943
|
'hh5s93j4hdidpola', 'hdhd0244k9j7ao03'
|
946
944
|
)
|
947
|
-
Signet::OAuth1.extract_credential_key_option(
|
945
|
+
expect(Signet::OAuth1.extract_credential_key_option(
|
948
946
|
:temporary, {:client => client}
|
949
|
-
).
|
947
|
+
)).to eq 'hh5s93j4hdidpola'
|
950
948
|
end
|
951
949
|
end
|
952
950
|
|
953
951
|
describe Signet::OAuth1, 'extracting credential secrets from options' do
|
954
952
|
it 'should raise an error for bogus credentials' do
|
955
|
-
(lambda do
|
953
|
+
expect(lambda do
|
956
954
|
Signet::OAuth1.extract_credential_secret_option(
|
957
955
|
:client, {:client_credential_secret => true}
|
958
956
|
)
|
959
|
-
end).
|
957
|
+
end).to raise_error(TypeError)
|
960
958
|
end
|
961
959
|
|
962
960
|
it 'should raise an error for bogus credentials' do
|
963
|
-
(lambda do
|
961
|
+
expect(lambda do
|
964
962
|
Signet::OAuth1.extract_credential_secret_option(
|
965
963
|
:client, {:client_credential => 42}
|
966
964
|
)
|
967
|
-
end).
|
965
|
+
end).to raise_error(TypeError)
|
968
966
|
end
|
969
967
|
|
970
968
|
it 'should raise an error for bogus credentials' do
|
971
|
-
(lambda do
|
969
|
+
expect(lambda do
|
972
970
|
Signet::OAuth1.extract_credential_secret_option(
|
973
971
|
:client, {:client => 42}
|
974
972
|
)
|
975
|
-
end).
|
973
|
+
end).to raise_error(TypeError)
|
976
974
|
end
|
977
975
|
|
978
976
|
it 'should raise an error for missing credential secret' do
|
979
|
-
Signet::OAuth1.extract_credential_secret_option(:client, {}).
|
977
|
+
expect(Signet::OAuth1.extract_credential_secret_option(:client, {})).to eq nil
|
980
978
|
end
|
981
979
|
|
982
980
|
it 'should find the correct credential secret' do
|
983
|
-
Signet::OAuth1.extract_credential_secret_option(
|
981
|
+
expect(Signet::OAuth1.extract_credential_secret_option(
|
984
982
|
:client, {:client_credential_secret => 'kd94hf93k423kf44'}
|
985
|
-
).
|
983
|
+
)).to eq 'kd94hf93k423kf44'
|
986
984
|
end
|
987
985
|
|
988
986
|
it 'should find the correct credential secret' do
|
989
|
-
Signet::OAuth1.extract_credential_secret_option(
|
987
|
+
expect(Signet::OAuth1.extract_credential_secret_option(
|
990
988
|
:client, {:client_credential => Signet::OAuth1::Credential.new(
|
991
989
|
'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
|
992
990
|
)}
|
993
|
-
).
|
991
|
+
)).to eq 'kd94hf93k423kf44'
|
994
992
|
end
|
995
993
|
|
996
994
|
it 'should find the correct credential secret' do
|
@@ -998,9 +996,9 @@ describe Signet::OAuth1, 'extracting credential secrets from options' do
|
|
998
996
|
client.client_credential = Signet::OAuth1::Credential.new(
|
999
997
|
'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
|
1000
998
|
)
|
1001
|
-
Signet::OAuth1.extract_credential_secret_option(
|
999
|
+
expect(Signet::OAuth1.extract_credential_secret_option(
|
1002
1000
|
:client, {:client => client}
|
1003
|
-
).
|
1001
|
+
)).to eq 'kd94hf93k423kf44'
|
1004
1002
|
end
|
1005
1003
|
|
1006
1004
|
it 'should find the correct credential secret' do
|
@@ -1008,8 +1006,8 @@ describe Signet::OAuth1, 'extracting credential secrets from options' do
|
|
1008
1006
|
client.temporary_credential = Signet::OAuth1::Credential.new(
|
1009
1007
|
'hh5s93j4hdidpola', 'hdhd0244k9j7ao03'
|
1010
1008
|
)
|
1011
|
-
Signet::OAuth1.extract_credential_secret_option(
|
1009
|
+
expect(Signet::OAuth1.extract_credential_secret_option(
|
1012
1010
|
:temporary, {:client => client}
|
1013
|
-
).
|
1011
|
+
)).to eq 'hdhd0244k9j7ao03'
|
1014
1012
|
end
|
1015
1013
|
end
|