test/createsend_test.rb in createsend-3.1.0 vs test/createsend_test.rb in createsend-3.1.1

- old
+ new

@@ -71,35 +71,35 @@ lambda { access_token, expires_in, refresh_token = CreateSend::CreateSend.exchange_token( client_id, client_secret, redirect_uri, code) }.should raise_error( Exception, 'Error exchanging code for access token: invalid_grant - Specified code was invalid or expired') FakeWeb.last_request.body.should == "grant_type=authorization_code&client_id=8998879&client_secret=iou0q9wud0q9wd0q9wid0q9iwd0q9wid0q9wdqwd&redirect_uri=http%3A%2F%2Fexample.com%2Fauth&code=invalidcode" end - + should "refresh an access token given a refresh token" do - refresh_token = 'tGzv3JOkF0XG5Qx2TlKWIA' + refresh_token = 'ASP95S4aR+9KsgfHB0dapTYxNA==' options = { :body => fixture_file("refresh_oauth_token.json"), :content_type => "application/json; charset=utf-8" } FakeWeb.register_uri(:post, "https://api.createsend.com/oauth/token", options) new_access_token, new_expires_in, new_refresh_token = CreateSend::CreateSend.refresh_access_token refresh_token - FakeWeb.last_request.body.should == "grant_type=refresh_token&refresh_token=#{refresh_token}" + FakeWeb.last_request.body.should == "grant_type=refresh_token&refresh_token=#{CGI.escape(refresh_token)}" new_access_token.should == "SlAV32hkKG2e12e" new_expires_in.should == 1209600 new_refresh_token.should == "tGzv3JOkF0XG5Qx2TlKWIA" end should "raise an error when an attempt to refresh an access token fails" do - refresh_token = 'invalidrefreshtoken' + refresh_token = 'ASP95S4aR+9KsgfHB0dapTYxNA==' options = { :body => fixture_file("oauth_refresh_token_error.json"), :content_type => "application/json; charset=utf-8" } FakeWeb.register_uri(:post, "https://api.createsend.com/oauth/token", options) lambda { access_token, expires_in, refresh_token = CreateSend::CreateSend.refresh_access_token( refresh_token) }.should raise_error( Exception, 'Error refreshing access token: invalid_grant - Specified refresh_token was invalid or expired') - FakeWeb.last_request.body.should == "grant_type=refresh_token&refresh_token=#{refresh_token}" + FakeWeb.last_request.body.should == "grant_type=refresh_token&refresh_token=#{CGI.escape(refresh_token)}" end should "get a person's api key" do base_uri = "https://api.createsend.com/api/v3" uri = URI.parse(base_uri) @@ -115,12 +115,12 @@ end context "when an api caller is authenticated using oauth" do setup do - @access_token = "h9898wu98u9dqjoijnwld" - @refresh_token = "tGzv3JOkF0XG5Qx2TlKWIA" + @access_token = "ASP95S4aR+9KsgfHB0dapTYxNA==" + @refresh_token = "5S4aASP9R+9KsgfHB0dapTYxNA==" @auth = { :access_token => @access_token, :refresh_token => @refresh_token } end @@ -131,11 +131,11 @@ :content_type => "application/json; charset=utf-8" } FakeWeb.register_uri(:post, "https://api.createsend.com/oauth/token", options) cs = CreateSend::CreateSend.new @auth new_access_token, new_expires_in, new_refresh_token = cs.refresh_token - FakeWeb.last_request.body.should == "grant_type=refresh_token&refresh_token=tGzv3JOkF0XG5Qx2TlKWIA" + FakeWeb.last_request.body.should == "grant_type=refresh_token&refresh_token=#{CGI.escape(@auth[:refresh_token])}" new_access_token.should == "SlAV32hkKG2e12e" new_expires_in.should == 1209600 new_refresh_token.should == "tGzv3JOkF0XG5Qx2TlKWIA" cs.auth_details.should == { :access_token => new_access_token, @@ -160,10 +160,10 @@ lambda { new_access_token, new_refresh_token = cs.refresh_token }.should raise_error( Exception, '@auth_details[:refresh_token] does not contain a refresh token.') end should "raise an error when an attempt to refresh the access token is made but the refresh token is invalid" do - refresh_token = 'invalidrefreshtoken' + refresh_token = 'ASP95S4aR+9KsgfHB0dapTYxNA==' cs = CreateSend::CreateSend.new :access_token => 'any token', :refresh_token => refresh_token options = { :body => fixture_file("oauth_refresh_token_error.json"), :content_type => "application/json; charset=utf-8" } FakeWeb.register_uri(:post, "https://api.createsend.com/oauth/token", options)