Sha256: 50eb4c7b9d2785455f682e3f38224d8dea5a337a6eb13545bc8583734b0eb025
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
require 'spec_helper.rb' describe Rack::OAuth2::Server::Token::RefreshToken do context "when valid refresh_token is given" do before do # NOTE: for some reason, test fails when called Rack::OAuth2::Server::Authorization::Token directly @app = Rack::OAuth2::Server::Token.new(simple_app) do |request, response| response.access_token = "access_token" end @request = Rack::MockRequest.new @app end it "should return access_token as json response body" do response = @request.post("/", :params => { :grant_type => "refresh_token", :client_id => "valid_client", :refresh_token => "valid_refresh_token" }) response.status.should == 200 response.content_type.should == "application/json" response.body.should == "{\"access_token\":\"access_token\"}" end end context "when invalid refresh_token is given" do before do # NOTE: for some reason, test fails when called Rack::OAuth2::Server::Authorization::Code directly @app = Rack::OAuth2::Server::Token.new(simple_app) do |request, response| raise Rack::OAuth2::Server::Unauthorized.new(:invalid_grant, 'Invalid refresh_token.') end @request = Rack::MockRequest.new @app end it "should return error message as json response body" do response = @request.post("/", :params => { :grant_type => "refresh_token", :client_id => "valid_client", :refresh_token => "invalid_refresh_token" }) response.status.should == 400 response.content_type.should == "application/json" response.body.should == "{\"error_description\":\"Invalid refresh_token.\",\"error\":\"invalid_grant\"}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack-oauth2-0.0.7 | spec/rack/oauth2/server/token/refresh_token_spec.rb |