Skip to content

Commit

Permalink
Merge pull request #10 from ruisalgado/issue/ignored_server_port
Browse files Browse the repository at this point in the history
Fix typo that caused CAS server port to be ignored
  • Loading branch information
dlindahl committed Jun 14, 2013
2 parents 9d8a136 + 53278cf commit 5cad177
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/omniauth/strategies/cas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def cas_url
uri = Addressable::URI.new
uri.host = @options.host
uri.scheme = @options.ssl ? 'https' : 'http'
uri.port = @options.post
uri.port = @options.port
uri.path = @options.path

uri.to_s
Expand Down
17 changes: 11 additions & 6 deletions spec/omniauth/strategies/cas_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class MyCasProvider < OmniAuth::Strategies::CAS; end # TODO: Not really needed.
def app
Rack::Builder.new {
use OmniAuth::Test::PhonySession
use MyCasProvider, name: :cas, host: 'cas.example.org', uid_key: :employeeid
use MyCasProvider, name: :cas, host: 'cas.example.org', ssl: false, port: 8080, uid_key: :employeeid
run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] }
}.to_app
end
Expand All @@ -21,10 +21,15 @@ def app
it { should be_redirect }

it 'should redirect to the CAS server' do
subject.headers['Location'].should == 'https://cas.example.org/login?' + redirect_params
subject.headers['Location'].should == 'http://cas.example.org:8080/login?' + redirect_params
end
end

describe 'defaults' do
subject { MyCasProvider.default_options.to_hash }
it { should include('ssl' => true) }
end

describe 'GET /auth/cas' do
let(:return_url) { 'http://myapp.com/admin/foo' }

Expand Down Expand Up @@ -59,7 +64,7 @@ def app

describe 'GET /auth/cas/callback with an invalid ticket' do
before do
stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=9391d/).
stub_request(:get, /^http:\/\/cas.example.org:8080?\/serviceValidate\?([^&]+&)?ticket=9391d/).
to_return( body: File.read('spec/fixtures/cas_failure.xml') )
get '/auth/cas/callback?ticket=9391d'
end
Expand All @@ -77,7 +82,7 @@ def app
let(:return_url) { 'http://127.0.0.10/?some=parameter' }

before do
stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=593af/)
stub_request(:get, /^http:\/\/cas.example.org:8080?\/serviceValidate\?([^&]+&)?ticket=593af/)
.with { |request| @request_uri = request.uri.to_s }
.to_return( body: File.read('spec/fixtures/cas_success.xml') )

Expand All @@ -89,7 +94,7 @@ def app
end

it 'should properly encode the service URL' do
WebMock.should have_requested(:get, 'https://cas.example.org/serviceValidate')
WebMock.should have_requested(:get, 'http://cas.example.org:8080/serviceValidate')
.with(query: {
ticket: '593af',
service: 'http://example.org/auth/cas/callback?url=' + Rack::Utils.escape('http://127.0.0.10/?some=parameter')
Expand Down Expand Up @@ -143,4 +148,4 @@ def app
end
end

end
end

0 comments on commit 5cad177

Please sign in to comment.