예제 #1
0
 def test_request_with_token_authentication(self, request):
     request.return_value.json.return_value = self.token_response
     c = Client(**self.data)
     c.request('GET', '/clients', token=True)
     auth = ('client', 'secret')
     request.assert_called_with(
         'GET', 'http://localhost:4444/clients', auth=auth)
예제 #2
0
 def test_request_with_basic_authentication(self, request):
     c = Client(**self.data)
     c.request(
         'POST', '/oauth2/token', token=False,
         auth=('client', 'secret'), json={'token': 'foobar'})
     request.assert_called_with(
         'POST', 'http://localhost:4445/oauth2/token',
         auth=('client', 'secret'), json={'token': 'foobar'})
예제 #3
0
 def test_request_with_token_authentication(self, request):
     request.return_value.json.return_value = self.token_response
     c = Client(**self.data)
     c.request('GET', '/clients', token=True)
     headers = {'Authorization': 'bearer super-token'}
     request.assert_called_with('GET',
                                'http://localhost/clients',
                                headers=headers)