Skip to content

Commit

Permalink
Fix for CAS validation when response is compressed
Browse files Browse the repository at this point in the history
  • Loading branch information
needto committed Feb 21, 2011
1 parent 31cb192 commit abfb051
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Expand Up @@ -68,7 +68,7 @@ def get_service_response_body
http = Net::HTTP.new(@uri.host, @uri.port)
http.use_ssl = @uri.port == 443 || @uri.instance_of?(URI::HTTPS)
http.start do |c|
response = c.get "#{@uri.path}?#{@uri.query}", VALIDATION_REQUEST_HEADERS
response = c.get "#{@uri.path}?#{@uri.query}", VALIDATION_REQUEST_HEADERS.dup
result = response.body
end
result
Expand Down
17 changes: 17 additions & 0 deletions oa-enterprise/spec/omniauth/strategies/cas_spec.rb
Expand Up @@ -72,4 +72,21 @@ def strategy
last_response.body.should == 'true'
end
end

describe 'GET /auth/cas/callback with a valid ticket and gzipped response from the server' do
before do
zipped = StringIO.new
Zlib::GzipWriter.wrap zipped do |io|
io.write File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'cas_success.xml'))
end
stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=593af/).
with { |request| @request_uri = request.uri.to_s }.
to_return(:body => zipped.string, :headers => { 'content-encoding' => 'gzip' })
get '/auth/cas/callback?ticket=593af'
end

it 'should call through to the master app when response is gzipped' do
last_response.body.should == 'true'
end
end
end

0 comments on commit abfb051

Please sign in to comment.