Example #1
0
 def test_process_perma_payments_transmission_expired_timestamp(self, decrypt, unstringify, timestamp):
     post = spoof_perma_payments_post()
     unstringify_data.return_value = post['encrypted_data']
     timestamp.return_value = False
     with self.assertRaises(InvalidTransmissionException) as excinfo:
         process_perma_payments_transmission(post, [])
     assert 'Expired timestamp in data.' in str(excinfo.exception)
Example #2
0
 def test_process_perma_payments_transmission_missing_timestamp(self, decrypt, unstringify):
     post = spoof_perma_payments_post()
     del post['encrypted_data']['timestamp']
     unstringify.return_value = post['encrypted_data']
     with self.assertRaises(InvalidTransmissionException) as excinfo:
         process_perma_payments_transmission(post, [])
     assert 'Missing timestamp in data.' in str(excinfo.exception)
Example #3
0
    def test_process_perma_payments_transmission_happy_path(self, decrypt, unstringify, timestamp):
        post = spoof_perma_payments_post()
        decrypt.return_value = sentinel.decrypted
        unstringify.return_value = post['encrypted_data']
        timestamp.return_value = True

        assert process_perma_payments_transmission(post, ['desired_field']) == {'desired_field': 'desired_field'}

        decrypt.assert_called_once_with(post['encrypted_data'])
        unstringify.assert_called_once_with(sentinel.decrypted)
        timestamp.assert_called_once_with(post['encrypted_data']['timestamp'], settings.PERMA_PAYMENTS_TIMESTAMP_MAX_AGE_SECONDS)
Example #4
0
 def test_process_perma_payments_transmission_encryption_problem(self, decrypt):
     decrypt.side_effect = SentinelException
     with self.assertRaises(InvalidTransmissionException) as excinfo:
         process_perma_payments_transmission(spoof_perma_payments_post(), [])
     assert 'SentinelException' in str(excinfo.exception)
     assert decrypt.call_count == 1
Example #5
0
 def test_process_perma_payments_transmission_encrypted_data_empty(self):
     with self.assertRaises(InvalidTransmissionException) as excinfo:
         assert process_perma_payments_transmission({'encrypted_data': ''}, [])
     assert 'No encrypted_data in POST.' in str(excinfo.exception)
Example #6
0
 def test_process_perma_payments_transmission_not_valid_json(self, decrypt, unstringify):
     unstringify.side_effect = SentinelException
     with self.assertRaises(InvalidTransmissionException) as excinfo:
         process_perma_payments_transmission(spoof_perma_payments_post(), [])
     assert 'SentinelException' in str(excinfo.exception)
     assert unstringify.call_count == 1