示例#1
0
 def test_verify_api_key_usage_inactive(self):
     arguments = MockArgumentParser()
     client = SanicYadlanClient("yadlan", arguments)
     self.assertIsNotNone(client)
     client.configuration.client_configuration._use_api_keys = False
     request = unittest.mock.Mock()
     self.assertEqual((None, None), client.verify_api_key_usage(request))
示例#2
0
 def test_verify_api_key_usage_active(self):
     arguments = MockArgumentParser()
     client = SanicYadlanClient("yadlan", arguments)
     self.assertIsNotNone(client)
     client.configuration.client_configuration._use_api_keys = True
     client.configuration.client_configuration._api_key_file = os.path.dirname(__file__) + os.sep + ".." + os.sep + ".." + os.sep + "api_keys.txt"
     client.load_api_keys()
     request = unittest.mock.Mock()
     request.args = {}
     request.args['apikey'] = '11111111'
     self.assertEqual(({'error': 'Unauthorized access'}, 401), client.verify_api_key_usage(request))