File: test_crypto.py

package info (click to toggle)
python-braintree 3.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,376 kB
  • ctags: 1,998
  • sloc: python: 13,634; makefile: 73; sh: 8
file content (19 lines) | stat: -rw-r--r-- 890 bytes parent folder | download | duplicates (2)
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.assertEquals("d503d7a1a6adba1e6474e9ff2c4167f9dfdf4247", actual)

    def test_sha256_hmac_hash(self):
        actual = Crypto.sha256_hmac_hash("secret-key", "secret-message")
        self.assertEquals("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"))