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')
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'))
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'))
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'))
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)
def wrapped_call_proxy(method, *args): return call_proxy(SERVER_URI, method, HTTP_METHOD, *args)
def test_dek_status_get(self): status, resp, f_time = call_proxy(self.server_uri, 'dek_status', 'GET') self.assertEqual(status, 'success')
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')
def test_debug_post(self): status, resp, f_time = call_proxy(self.server_uri, 'debug_method', 'POST') self.assertEqual(status, 'success')