def test_ok(self): self.req.get.return_value = self.get_response('foo', 200) assert self.get(reverse('braintree:auth')).status_code, 200 self.req.get.assert_called_with( 'https://b.c/some/url/', verify=(Environment.braintree_root() + '/ssl/api_braintreegateway_com.ca.crt'), data='', timeout=settings.DEFAULT_TIMEOUT, headers={ 'Authorization': 'Basic Og==', 'Content-Type': 'application/xml; charset=utf-8' })
def test_ok(self): self.req.get.return_value = self.get_response('foo', 200) assert self.get(reverse('braintree:auth')).status_code, 200 self.req.get.assert_called_with( 'https://b.c/some/url/', verify=(Environment.braintree_root() + '/ssl/api_braintreegateway_com.ca.crt'), data='', timeout=settings.DEFAULT_TIMEOUT, headers={ 'Authorization': 'Basic Og==', 'Content-Type': 'application/xml; charset=utf-8' })
def configure_braintree(self): sandbox = Environment( 'sandbox', 'api.sandbox.braintreegateway.com', '443', 'https://auth.sandbox.venmo.com', True, Environment.braintree_root() + '/ssl/api_braintreegateway_com.ca.crt' ) braintree.Configuration.configure( environment=sandbox, merchant_id=self.BRAINTREE_MERCHANT_ID, public_key=self.BRAINTREE_PUBLIC_KEY, private_key=self.BRAINTREE_PRIVATE_KEY )
def braintree(request): """ Pass the request through to Braintree. There are two jobs to do: 1) Add in the Braintree auth into the HTTP headers 2) Ensure that requests will check the correct Braintree crt. """ new_request = prepare(request) # Until https://github.com/mozilla/solitude-auth/pull/3 is merged. new_request['headers']['Content-Type'] = 'application/xml; charset=utf-8' # Add in the correct Braintree Authorization. new_request['headers']['Authorization'] = b"Basic " + encodebytes( settings.BRAINTREE_PUBLIC_KEY.encode('ascii') + b":" + settings.BRAINTREE_PRIVATE_KEY.encode('ascii')).strip() # Taken from http://bit.ly/1cBESdC and ensures that the # crt is passed through to the requests verify parameter. new_request['verify'] = (Environment.braintree_root() + '/ssl/api_braintreegateway_com.ca.crt') return send(new_request)
def braintree(request): """ Pass the request through to Braintree. There are two jobs to do: 1) Add in the Braintree auth into the HTTP headers 2) Ensure that requests will check the correct Braintree crt. """ new_request = prepare(request) # Until https://github.com/mozilla/solitude-auth/pull/3 is merged. new_request['headers']['Content-Type'] = 'application/xml; charset=utf-8' # Add in the correct Braintree Authorization. new_request['headers']['Authorization'] = b"Basic " + encodebytes( settings.BRAINTREE_PUBLIC_KEY.encode('ascii') + b":" + settings.BRAINTREE_PRIVATE_KEY.encode('ascii')).strip() # Taken from http://bit.ly/1cBESdC and ensures that the # crt is passed through to the requests verify parameter. new_request['verify'] = ( Environment.braintree_root() + '/ssl/api_braintreegateway_com.ca.crt') return send(new_request)