1
0
Fork 0
mirror of https://github.com/simi/omniauth-facebook.git synced 2022-11-09 12:32:45 -05:00

Add tests when authorization code is not included in callback

This commit is contained in:
Tomoya Hirano 2014-04-30 09:28:48 +02:00 committed by Josef Šimánek
parent a0036b9e5f
commit c47de0daab

View file

@ -435,4 +435,35 @@ module SignedRequestTests
assert_equal nil, strategy.send(:signed_request_from_cookie) assert_equal nil, strategy.send(:signed_request_from_cookie)
end end
end end
class MissingCodeInParamsRequestTest < TestCase
def setup
super
@request.stubs(:params).returns({})
end
test 'calls fail! when a code is not included in the params' do
strategy.expects(:fail!).times(1).with(:no_authorization_code, kind_of(Exception))
strategy.callback_phase
end
end
class MissingCodeInCookieRequestTest < TestCase
def setup(algo = nil)
super()
@payload = {
'algorithm' => algo || 'HMAC-SHA256',
'code' => nil,
'issued_at' => Time.now.to_i,
'user_id' => '123456'
}
@request.stubs(:cookies).returns({"fbsr_#{@client_id}" => signed_request(@payload, @client_secret)})
end
test 'calls fail! when a code is not included in the cookie' do
strategy.expects(:fail!).times(1).with(:no_authorization_code, kind_of(Exception))
strategy.callback_phase
end
end
end end