File: test_crypto.py

package info (click to toggle)
python-braintree 4.31.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,576 kB
  • sloc: python: 28,946; makefile: 9; sh: 8
file content (19 lines) | stat: -rw-r--r-- 888 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from tests.test_helper import *

class TestCrypto(unittest.TestCase):
    def test_sha1_hmac_hash(self):
        actual = Crypto.sha1_hmac_hash("secretKey", "hello world")
        self.assertEqual("d503d7a1a6adba1e6474e9ff2c4167f9dfdf4247", actual)

    def test_sha256_hmac_hash(self):
        actual = Crypto.sha256_hmac_hash("secret-key", "secret-message")
        self.assertEqual("68e7f2ecab71db67b1aca2a638f5122810315c3013f27c2196cd53e88709eecc", actual)

    def test_secure_compare_returns_true_when_same(self):
        self.assertTrue(Crypto.secure_compare("a_string", "a_string"))

    def test_secure_compare_returns_false_when_different_lengths(self):
        self.assertFalse(Crypto.secure_compare("a_string", "a_string_that_is_longer"))

    def test_secure_compare_returns_false_when_different(self):
        self.assertFalse(Crypto.secure_compare("a_string", "a_strong"))