Add tests when authorization code is not included in callback
Tomoya Hirano authored 9 years ago
Josef Šimánek committed 9 years ago
434 | 434 | assert_equal nil, strategy.send(:signed_request_from_cookie) |
435 | 435 | end |
436 | 436 | end |
437 | end | |
437 | ||
438 | class MissingCodeInParamsRequestTest < TestCase | |
439 | def setup | |
440 | super | |
441 | @request.stubs(:params).returns({}) | |
442 | end | |
443 | ||
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)) | |
446 | strategy.callback_phase | |
447 | end | |
448 | end | |
449 | ||
450 | class MissingCodeInCookieRequestTest < TestCase | |
451 | def setup(algo = nil) | |
452 | super() | |
453 | @payload = { | |
454 | 'algorithm' => algo || 'HMAC-SHA256', | |
455 | 'code' => nil, | |
456 | 'issued_at' => Time.now.to_i, | |
457 | 'user_id' => '123456' | |
458 | } | |
459 | ||
460 | @request.stubs(:cookies).returns({"fbsr_#{@client_id}" => signed_request(@payload, @client_secret)}) | |
461 | end | |
462 | ||
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)) | |
465 | strategy.callback_phase | |
466 | end | |
467 | end | |
468 | end |