From 743d3df95af76c0cea0bf5993de521e3703dce67 Mon Sep 17 00:00:00 2001 From: Derek Lindahl <dlindahl@customink.com> Date: Wed, 14 Dec 2011 23:26:43 -0500 Subject: [PATCH] Added intentionally partial test for invalid ticket failures --- lib/omniauth/strategies/cas.rb | 2 +- spec/omniauth/strategies/cas_spec.rb | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/omniauth/strategies/cas.rb b/lib/omniauth/strategies/cas.rb index dd3dcb3..e94f2b7 100644 --- a/lib/omniauth/strategies/cas.rb +++ b/lib/omniauth/strategies/cas.rb @@ -26,7 +26,7 @@ module OmniAuth return fail!(:no_ticket, 'No CAS Ticket') unless ticket # validator = ServiceTicketValidator.new(@configuration, callback_url, ticket) # @user_info = validator.user_info - return fail!(:invalid_ticket, 'Invalid CAS Ticket') if @user_info.empty? + return fail!(:invalid_ticket, 'Invalid CAS Ticket') if @user_info.nil? or @user_info.empty? super end diff --git a/spec/omniauth/strategies/cas_spec.rb b/spec/omniauth/strategies/cas_spec.rb index 92fd936..52b5ce5 100644 --- a/spec/omniauth/strategies/cas_spec.rb +++ b/spec/omniauth/strategies/cas_spec.rb @@ -42,17 +42,20 @@ describe OmniAuth::Strategies::CAS, :type => :strategy do end end - # describe 'GET /auth/cas/callback with an invalid ticket' do - # before do - # # stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=9391d/). - # # to_return(:body => File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'cas_failure.xml'))) - # # get '/auth/cas/callback?ticket=9391d' - # end - # it 'should fail'# do - # # last_response.should be_redirect - # # last_response.headers['Location'].should =~ /invalid_ticket/ - # # end - # end + describe 'GET /auth/cas/callback with an invalid ticket' do + before do + # stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=9391d/). + # to_return(:body => File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'cas_failure.xml'))) + get '/auth/cas/callback?ticket=9391d' + end + + subject { last_response } + + it { should be_redirect } + it 'should have a failure message' do + subject.headers['Location'].should =~ /message=invalid_ticket/ + end + end # describe 'GET /auth/cas/callback with a valid ticket' do # before do -- GitLab