Ejemplo n.º 1
0
 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'
         })
Ejemplo n.º 2
0
 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'
         })
Ejemplo n.º 3
0
    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
        )
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
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)