Codebase list ruby-omniauth-facebook / c47de0d
Add tests when authorization code is not included in callback Tomoya Hirano authored 9 years ago Josef Šimánek committed 9 years ago
1 changed file(s) with 32 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
434434 assert_equal nil, strategy.send(:signed_request_from_cookie)
435435 end
436436 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