Add test for unkown_signature_algorithm fail and ensure kind of fails in tests.
Josef Šimánek
9 years ago
442 | 442 | end |
443 | 443 | |
444 | 444 | test 'calls fail! when a code is not included in the params' do |
445 | strategy.expects(:fail!).times(1).with(:no_authorization_code, kind_of(Exception)) | |
445 | strategy.expects(:fail!).times(1).with(:no_authorization_code, kind_of(OmniAuth::Strategies::Facebook::NoAuthorizationCodeError)) | |
446 | 446 | strategy.callback_phase |
447 | 447 | end |
448 | 448 | end |
461 | 461 | end |
462 | 462 | |
463 | 463 | test 'calls fail! when a code is not included in the cookie' do |
464 | strategy.expects(:fail!).times(1).with(:no_authorization_code, kind_of(Exception)) | |
464 | strategy.expects(:fail!).times(1).with(:no_authorization_code, kind_of(OmniAuth::Strategies::Facebook::NoAuthorizationCodeError)) | |
465 | 465 | strategy.callback_phase |
466 | 466 | end |
467 | 467 | end |
468 | end | |
468 | ||
469 | class UnknownAlgorithmInCookieRequestTest < TestCase | |
470 | def setup | |
471 | super() | |
472 | @payload = { | |
473 | 'algorithm' => 'UNKNOWN-ALGO', | |
474 | 'code' => nil, | |
475 | 'issued_at' => Time.now.to_i, | |
476 | 'user_id' => '123456' | |
477 | } | |
478 | ||
479 | @request.stubs(:cookies).returns({"fbsr_#{@client_id}" => signed_request(@payload, @client_secret)}) | |
480 | end | |
481 | ||
482 | test 'calls fail! when an algorithm is unknown' do | |
483 | strategy.expects(:fail!).times(1).with(:unknown_signature_algorithm, kind_of(OmniAuth::Strategies::Facebook::UnknownSignatureAlgorithmError)) | |
484 | strategy.callback_phase | |
485 | end | |
486 | end | |
487 | end |