Created
October 2, 2011 14:31
-
-
Save kylewelsby/1257503 to your computer and use it in GitHub Desktop.
OAuth2 refresh_token testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group :test do | |
... | |
gem 'timecop' | |
... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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