aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_utils.py
blob: c39364c7c31deb8111c7e83cef96775683db851d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import pytest

from .utils import (
    base_hash_test, encrypt_test, hash_test, long_string_hash_test,
    base_hmac_test, hmac_test, stream_encryption_test, aead_test,
    aead_exception_test, aead_tag_exception_test,
)


class TestEncryptTest(object):
    def test_skips_if_only_if_returns_false(self):
        with pytest.raises(pytest.skip.Exception) as exc_info:
            encrypt_test(
                None, None, None, None,
                only_if=lambda backend: False,
                skip_message="message!"
            )
        assert exc_info.value.args[0] == "message!"


class TestAEADTest(object):
    def test_skips_if_only_if_returns_false(self):
        with pytest.raises(pytest.skip.Exception) as exc_info:
            aead_test(
                None, None, None, None,
                only_if=lambda backend: False,
                skip_message="message!"
            )
        assert exc_info.value.args[0] == "message!"


class TestAEADExceptionTest(object):
    def test_skips_if_only_if_returns_false(self):
        with pytest.raises(pytest.skip.Exception) as exc_info:
            aead_exception_test(
                None, None, None,
                only_if=lambda backend: False,
                skip_message="message!"
            )
        assert exc_info.value.args[0] == "message!"


class TestAEADTagExceptionTest(object):
    def test_skips_if_only_if_returns_false(self):
        with pytest.raises(pytest.skip.Exception) as exc_info:
            aead_tag_exception_test(
                None, None, None,
                only_if=lambda backend: False,
                skip_message="message!"
            )
        assert exc_info.value.args[0] == "message!"


class TestHashTest(object):
    def test_skips_if_only_if_returns_false(self):
        with pytest.raises(pytest.skip.Exception) as exc_info:
            hash_test(
                None, None, None,
                only_if=lambda backend: False,
                skip_message="message!"
            )
        assert exc_info.value.args[0] == "message!"


class TestBaseHashTest(object):
    def test_skips_if_only_if_returns_false(self):
        with pytest.raises(pytest.skip.Exception) as exc_info:
            base_hash_test(
                None, None, None, None,
                only_if=lambda backend: False,
                skip_message="message!"
            )
        assert exc_info.value.args[0] == "message!"


class TestLongHashTest(object):
    def test_skips_if_only_if_returns_false(self):
        with pytest.raises(pytest.skip.Exception) as exc_info:
            long_string_hash_test(
                None, None, None,
                only_if=lambda backend: False,
                skip_message="message!"
            )
        assert exc_info.value.args[0] == "message!"


class TestHMACTest(object):
    def test_skips_if_only_if_returns_false(self):
        with pytest.raises(pytest.skip.Exception) as exc_info:
            hmac_test(
                None, None, None,
                only_if=lambda backend: False,
                skip_message="message!"
            )
        assert exc_info.value.args[0] == "message!"


class TestBaseHMACTest(object):
    def test_skips_if_only_if_returns_false(self):
        with pytest.raises(pytest.skip.Exception) as exc_info:
            base_hmac_test(
                None, None,
                only_if=lambda backend: False,
                skip_message="message!"
            )
        assert exc_info.value.args[0] == "message!"


class TestStreamEncryptionTest(object):
    def test_skips_if_only_if_returns_false(self):
        with pytest.raises(pytest.skip.Exception) as exc_info:
            stream_encryption_test(
                None, None, None,
                only_if=lambda backend: False,
                skip_message="message!"
            )
        assert exc_info.value.args[0] == "message!"