Skip to content

Instantly share code, notes, and snippets.

@kylewelsby
Created October 2, 2011 14:31
Show Gist options
  • Save kylewelsby/1257503 to your computer and use it in GitHub Desktop.
Save kylewelsby/1257503 to your computer and use it in GitHub Desktop.
OAuth2 refresh_token testing
group :test do
...
gem 'timecop'
...
end
describe "expires_at" do
it "should allow access with valid token" do
request.env['Authorization'] = "OAuth #{@user.authentication_token}"
get :messages
response.code.should eql 200
end
it "should not allow access with expired token" do
Timecop.freeze(Time.at(Time.now + @user.expires_at.seconds)) do
request.env['Authorization'] = "OAuth #{@user.authentication_token}"
get :messages
response.code.should eql 401
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment