Example #1
0
    def scenario(self):
        self.sleep()
        card_data = generate_random_card_data(mode='full')
        status, resp, exec_time = wrapped_call_proxy('tokenize_card', card_data)
        self.send_result('tokenize_card', status, resp, exec_time)
        if status != 'success':
            log.debug('Error raised in tokenize_card')
            return
        card_token = get_resp_field(resp, 'card_token')
        cvn_token = get_resp_field(resp, 'cvn_token')
        if not card_token:
            log.debug('Cant find card token in tokenize_card response!')
            return
        if not cvn_token:
            log.debug('Cant find cvn token in tokenize_card response!')
            return
        status, resp, exec_time = wrapped_call_proxy('detokenize_card',
                                                     card_token, cvn_token)
        self.send_result('detokenize_card', status, resp, exec_time)
        if status != 'success':
            log.debug('Error raised in detokenize_card')
            return

        status, resp, exec_time = wrapped_call_proxy('remove_card',
                                                     card_token, cvn_token)
        self.send_result('remove_card', status, resp, exec_time)
        if status != 'success':
            log.debug('Error raised in remove_card')
Example #2
0
    def scenario(self):
        self.sleep()
        card_data = generate_random_card_data(mode='full')
        status, resp, exec_time = wrapped_call_proxy('tokenize_card',
                                                     card_data)
        self.send_result('tokenize_card', status, resp, exec_time)
        if status != 'success':
            log.debug('Error raised in tokenize_card')
            return
        card_token = get_resp_field(resp, 'card_token')
        cvn_token = get_resp_field(resp, 'cvn_token')
        if not card_token:
            log.debug('Cant find card token in tokenize_card response!')
            return
        if not cvn_token:
            log.debug('Cant find cvn token in tokenize_card response!')
            return
        status, resp, exec_time = wrapped_call_proxy('detokenize_card',
                                                     card_token, cvn_token)
        self.send_result('detokenize_card', status, resp, exec_time)
        if status != 'success':
            log.debug('Error raised in detokenize_card')
            return

        status, resp, exec_time = wrapped_call_proxy('remove_card', card_token,
                                                     cvn_token)
        self.send_result('remove_card', status, resp, exec_time)
        if status != 'success':
            log.debug('Error raised in remove_card')
Example #3
0
 def test_get_token_without_cvn_post(self):
     card_data = generate_random_card_data(mode='without_cvn')
     status, resp, f_time = call_proxy(self.server_uri,
                                       'tokenize_card', 'POST', card_data)
     self.assertEqual(status, 'success')
     self.assertTrue(get_resp_field(resp, 'card_token'))
     self.assertTrue(get_resp_field(resp, 'pan_masked'))
     self.assertFalse(get_resp_field(resp, 'pan'))
Example #4
0
 def test_get_token_without_cvn_post(self):
     card_data = generate_random_card_data(mode='without_cvn')
     status, resp, f_time = call_proxy(self.server_uri, 'tokenize_card',
                                       'POST', card_data)
     self.assertEqual(status, 'success')
     self.assertTrue(get_resp_field(resp, 'card_token'))
     self.assertTrue(get_resp_field(resp, 'pan_masked'))
     self.assertFalse(get_resp_field(resp, 'pan'))
Example #5
0
 def test_remove_card_post(self):
     source_card_data = generate_random_card_data(mode='full')
     status, resp, f_time = call_proxy(self.server_uri, 'tokenize_card',
                                       'POST', source_card_data)
     card_token = get_resp_field(resp, 'card_token')
     cvn_token = get_resp_field(resp, 'cvn_token')
     status, resp, f_time = call_proxy(self.server_uri, 'remove_card',
                                       'POST', card_token, cvn_token)
     self.assertEqual(status, 'success')
Example #6
0
 def test_remove_card_post(self):
     source_card_data = generate_random_card_data(mode='full')
     status, resp, f_time = call_proxy(self.server_uri,
                                       'tokenize_card', 'POST',
                                       source_card_data)
     card_token = get_resp_field(resp, 'card_token')
     cvn_token = get_resp_field(resp, 'cvn_token')
     status, resp, f_time = call_proxy(
         self.server_uri, 'remove_card', 'POST',
         card_token, cvn_token)
     self.assertEqual(status, 'success')
Example #7
0
 def test_get_card_get(self):
     source_card_data = generate_random_card_data(mode='full')
     status, resp, f_time = call_proxy(self.server_uri, 'tokenize_card',
                                       'GET', source_card_data)
     card_token = get_resp_field(resp, 'card_token')
     cvn_token = get_resp_field(resp, 'cvn_token')
     status, resp, f_time = call_proxy(self.server_uri, 'detokenize_card',
                                       'GET', card_token, cvn_token)
     self.assertEqual(status, 'success')
     self.assertEqual(source_card_data.pan, get_resp_field(resp, 'pan'))
     self.assertEqual(source_card_data.cvn, get_resp_field(resp, 'cvn'))
Example #8
0
 def test_get_card_get(self):
     source_card_data = generate_random_card_data(mode='full')
     status, resp, f_time = call_proxy(self.server_uri,
                                       'tokenize_card', 'GET', source_card_data)
     card_token = get_resp_field(resp, 'card_token')
     cvn_token = get_resp_field(resp, 'cvn_token')
     status, resp, f_time = call_proxy(
         self.server_uri, 'detokenize_card', 'GET',
         card_token, cvn_token)
     self.assertEqual(status, 'success')
     self.assertEqual(source_card_data.pan, get_resp_field(resp, 'pan'))
     self.assertEqual(source_card_data.cvn, get_resp_field(resp, 'cvn'))
Example #9
0
 def test_get_token_multiple_duplicate_post(self):
     card_data = generate_random_card_data(mode='full')
     orig_pan = card_data.pan
     orig_cvn = card_data.cvn
     status, resp, f_time = call_proxy(self.server_uri,
                                       'tokenize_card', 'POST', card_data)
     orig_card_token = get_resp_field(resp, 'card_token')
     orig_cvn_token = get_resp_field(resp, 'cvn_token')
     for _ in range(5):
         card_data.pan = orig_pan
         card_data.cvn = orig_cvn
         status, resp, f_time = call_proxy(self.server_uri,
                                           'tokenize_card', 'POST', card_data)
         dup_card_token = get_resp_field(resp, 'card_token')
         dup_cvn_token = get_resp_field(resp, 'cvn_token')
         self.assertEqual(orig_card_token, dup_card_token)
         self.assertNotEqual(orig_cvn_token, dup_cvn_token)
Example #10
0
 def test_get_token_multiple_duplicate_post(self):
     card_data = generate_random_card_data(mode='full')
     orig_pan = card_data.pan
     orig_cvn = card_data.cvn
     status, resp, f_time = call_proxy(self.server_uri, 'tokenize_card',
                                       'POST', card_data)
     orig_card_token = get_resp_field(resp, 'card_token')
     orig_cvn_token = get_resp_field(resp, 'cvn_token')
     for _ in range(5):
         card_data.pan = orig_pan
         card_data.cvn = orig_cvn
         status, resp, f_time = call_proxy(self.server_uri, 'tokenize_card',
                                           'POST', card_data)
         dup_card_token = get_resp_field(resp, 'card_token')
         dup_cvn_token = get_resp_field(resp, 'cvn_token')
         self.assertEqual(orig_card_token, dup_card_token)
         self.assertNotEqual(orig_cvn_token, dup_cvn_token)
Example #11
0
 def send_result(self, name, status, resp, exec_time):
     params = {
         'worker_name': self.name,
         'func_name': name,
         'status': status,
         'exec_time': exec_time,
         'response': resp,
     }
     if status != 'success':
         params['status_code'] = get_resp_field(resp, 'status_code')
     self.stat_queue.put_nowait(params)
Example #12
0
 def send_result(self, name, status, resp, exec_time):
     params = {
         'worker_name': self.name,
         'func_name': name,
         'status': status,
         'exec_time': exec_time,
         'response': resp,
     }
     if status != 'success':
         params['status_code'] = get_resp_field(resp, 'status_code')
     self.stat_queue.put_nowait(params)
Example #13
0
 def test_check_kek_get(self):
     status, resp, f_time = call_proxy(self.server_uri,
                                       'check_kek', 'GET')
     self.assertEqual('true', get_resp_field(resp, 'check_kek'))
     self.assertEqual(status, 'success')
Example #14
0
 def test_check_kek_get(self):
     status, resp, f_time = call_proxy(self.server_uri, 'check_kek', 'GET')
     self.assertEqual('true', get_resp_field(resp, 'check_kek'))
     self.assertEqual(status, 'success')