Skip to content

Commit

Permalink
Add test for unkown_signature_algorithm fail and ensure kind of fails…
Browse files Browse the repository at this point in the history
… in tests.
  • Loading branch information
simi committed Dec 2, 2014
1 parent 3ec55a2 commit 5b6b6a0
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def setup
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.expects(:fail!).times(1).with(:no_authorization_code, kind_of(OmniAuth::Strategies::Facebook::NoAuthorizationCodeError))
strategy.callback_phase
end
end
Expand All @@ -462,7 +462,26 @@ def setup(algo = nil)
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.expects(:fail!).times(1).with(:no_authorization_code, kind_of(OmniAuth::Strategies::Facebook::NoAuthorizationCodeError))
strategy.callback_phase
end
end

class UnknownAlgorithmInCookieRequestTest < TestCase
def setup
super()
@payload = {
'algorithm' => 'UNKNOWN-ALGO',
'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 an algorithm is unknown' do
strategy.expects(:fail!).times(1).with(:unknown_signature_algorithm, kind_of(OmniAuth::Strategies::Facebook::UnknownSignatureAlgorithmError))
strategy.callback_phase
end
end
Expand Down

0 comments on commit 5b6b6a0

Please sign in to comment.