Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated params when calling TokenCoder#decode #9

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/omniauth/strategies/cloudfoundry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def refresh(access_token)

def expired?(access_token)
access_token = access_token.auth_header if access_token.respond_to? :auth_header
expiry = CF::UAA::TokenCoder.decode(access_token.split()[1], nil, nil, false)[:expires_at]
expiry = CF::UAA::TokenCoder.decode(access_token.split()[1])[:expires_at]
expiry.is_a?(Integer) && expiry <= Time.now.to_i
end

Expand Down
10 changes: 10 additions & 0 deletions spec/omniauth/strategies/uaa_oauth2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,14 @@ def app; lambda{|env| [200, {}, ["Hello."]]} end
subject.build_access_token('query-string').should be_empty
end
end

describe '#expired?' do
it 'sets params correctly on TokenCoder#decode' do
subject.access_token = OmniAuth::Strategies::CFAccessToken.new
CF::UAA::TokenCoder.should_receive(:decode)
.with(subject.access_token.auth_header.split()[1]).and_return({expires_at: 12345})

subject.expired?(subject.access_token)
end
end
end