378 | 378 |
test 'is nil' do
|
379 | 379 |
assert_nil strategy.send(:signed_request)
|
380 | 380 |
end
|
|
381 |
|
|
382 |
test 'throws an error on calling build_access_token' do
|
|
383 |
assert_equal 'must pass either a `code` parameter or a signed request (via `signed_request` parameter or a `fbsr_XXX` cookie)',
|
|
384 |
assert_raises(OmniAuth::Strategies::Facebook::NoAuthorizationCodeError) { strategy.send(:build_access_token) }.message
|
|
385 |
end
|
381 | 386 |
end
|
382 | 387 |
|
383 | 388 |
class CookiePresentTest < TestCase
|
384 | |
def setup
|
385 | |
super
|
|
389 |
def setup(algo = nil)
|
|
390 |
super()
|
386 | 391 |
@payload = {
|
387 | |
'algorithm' => 'HMAC-SHA256',
|
|
392 |
'algorithm' => algo || 'HMAC-SHA256',
|
388 | 393 |
'code' => 'm4c0d3z',
|
389 | 394 |
'issued_at' => Time.now.to_i,
|
390 | 395 |
'user_id' => '123456'
|
|
396 | 401 |
test 'parses the access code out from the cookie' do
|
397 | 402 |
assert_equal @payload, strategy.send(:signed_request)
|
398 | 403 |
end
|
|
404 |
|
|
405 |
test 'throws an error if the algorithm is unknown' do
|
|
406 |
setup('UNKNOWN-ALGO')
|
|
407 |
assert_equal "unknown algorithm: UNKNOWN-ALGO", assert_raises(NotImplementedError) { strategy.send(:signed_request) }.message
|
|
408 |
end
|
399 | 409 |
end
|
400 | 410 |
|
401 | 411 |
class ParamPresentTest < TestCase
|
402 | |
def setup
|
403 | |
super
|
|
412 |
def setup(algo = nil)
|
|
413 |
super()
|
404 | 414 |
@payload = {
|
405 | |
'algorithm' => 'HMAC-SHA256',
|
|
415 |
'algorithm' => algo || 'HMAC-SHA256',
|
406 | 416 |
'oauth_token' => 'XXX',
|
407 | 417 |
'issued_at' => Time.now.to_i,
|
408 | 418 |
'user_id' => '123456'
|
|
413 | 423 |
|
414 | 424 |
test 'parses the access code out from the param' do
|
415 | 425 |
assert_equal @payload, strategy.send(:signed_request)
|
|
426 |
end
|
|
427 |
|
|
428 |
test 'throws an error if the algorithm is unknown' do
|
|
429 |
setup('UNKNOWN-ALGO')
|
|
430 |
assert_equal "unknown algorithm: UNKNOWN-ALGO", assert_raises(NotImplementedError) { strategy.send(:signed_request) }.message
|
416 | 431 |
end
|
417 | 432 |
end
|
418 | 433 |
|