blob: 9fde1be19e6b25a62aa863657284ea2faf8ed007 [file] [log] [blame]
Paul Kehrer8cf26422015-03-21 09:50:24 -05001# This file is dual licensed under the terms of the Apache License, Version
2# 2.0, and the BSD License. See the LICENSE file in the root of this repository
3# for complete details.
4
5from __future__ import absolute_import, division, print_function
6
7import pytest
8
9from cryptography import x509
10
11
12class TestBasicConstraints(object):
13 def test_ca_not_boolean(self):
14 with pytest.raises(TypeError):
15 x509.BasicConstraints("notbool", None, False)
16
17 def test_critical_not_boolean(self):
18 with pytest.raises(TypeError):
19 x509.BasicConstraints(False, None, "notbool")
20
21 def test_path_length_not_ca(self):
22 with pytest.raises(ValueError):
23 x509.BasicConstraints(False, 0, True)
24
25 def test_path_length_not_int(self):
26 with pytest.raises(TypeError):
27 x509.BasicConstraints(True, 1.1, True)
28
29 with pytest.raises(TypeError):
30 x509.BasicConstraints(True, "notint", True)
31
32 def test_path_length_negative(self):
33 with pytest.raises(TypeError):
34 x509.BasicConstraints(True, -1, True)
35
36 def test_repr(self):
37 na = x509.BasicConstraints(True, None, True)
38 assert repr(na) == (
39 "<BasicConstraints(ca=True, path_length=None, critical=True)>"
40 )