Exemplo n.º 1
0
 def test_in_case_decryption_fails_it_should_raise(self):
     self.request.headers = {AUTHORIZATION_HEADER: 'Browserid 1234',
                             CLIENT_STATE_HEADER: '12345'}
     tempered_cache = ENCRYPTED_CREDENTIALS.replace('0', 'a')
     with mock.patch('syncto.authentication.TokenserverClient') as TSClient:
         TSClient.return_value.get_hawk_credentials.return_value = \
             self.credentials
         with mock.patch.object(
                 self.request.registry.cache, 'get',
                 return_value=tempered_cache):
             self.assertRaises(CryptoError, build_sync_client, self.request)
Exemplo n.º 2
0
 def test_statsd_time_sync_client_calls(self):
     with mock.patch.object(
             self.request.registry.cache, 'get',
             return_value=ENCRYPTED_CREDENTIALS.encode('utf-8')):
         with mock.patch('requests.request'):
             build_sync_client(self.request)
             self.mocked_client.timer.assert_any_call(
                 'syncclient.start_time')
             self.mocked_client.timer.assert_any_call(
                 'syncclient.syncclient.auth')
             self.mocked_client.timer.assert_any_call(
                 'syncclient.syncclient.get_records')
             self.mocked_client.timer.assert_any_call(
                 'syncclient.syncclient.get_record')
             self.mocked_client.timer.assert_any_call(
                 'syncclient.syncclient.put_record')
             self.mocked_client.timer.assert_any_call(
                 'syncclient.syncclient.delete_record')