Sha256: 356af85cb2f72913d00fa8af26900ba1d36a86c73740427169f53d4100b568be
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
require_relative '../../lib/mangopay/api/service/oauth_tokens' require_relative '../../lib/mangopay/api/http_client' require_relative '../../lib/mangopay/common/response_error' require_relative '../context/user_context' describe MangoApi::OAuthTokens do include_context 'user_context' describe '.create' do context 'having a valid configuration' do config = MangoPay.configuration it 'creates a valid authorization token' do token = MangoApi::OAuthTokens.create(config) # noinspection RubyStringKeysInHashInspection headers = { 'Authorization' => "#{token['token_type']} #{token['access_token']}", 'User-Agent' => "MANGOPAY V2 RubyBindings/#{MangoPay::VERSION}", 'Content-Type' => 'application/json' } url = 'https://api.sandbox.mangopay.com/v2.01/sdk-unit-tests/users/natural' # noinspection RubyResolve user = NATURAL_USER_DATA begin # launch a request to the MangoPay server using # the newly-created token as Authorization header MangoApi::HttpClient.post_raw(URI(url)) do |request| request.body = user.jsonify! headers.each do |k, v| request.add_field(k, v) end end rescue MangoApi::ResponseError => e raise "unsuccessful request using created token\n"\ "#{e.code} #{e.details}\n#{e.message}" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mangopay-v4-4.0.1 | spec/mangopay/oauth_tokens_spec.rb |