diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-03-22 13:19:31 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-03-22 13:19:31 -0500 |
commit | 8589466c0a12835cda03bf91043cf51b657d9e46 (patch) | |
tree | e85adc517329f5ea0dfb0330cf840973310d9fc8 /tests/test_x509_ext.py | |
parent | fd1444cfa97bb897eaee6ceca35175357317623b (diff) | |
download | cryptography-8589466c0a12835cda03bf91043cf51b657d9e46.tar.gz cryptography-8589466c0a12835cda03bf91043cf51b657d9e46.tar.bz2 cryptography-8589466c0a12835cda03bf91043cf51b657d9e46.zip |
rework BasicConstraints and Extension.
Diffstat (limited to 'tests/test_x509_ext.py')
-rw-r--r-- | tests/test_x509_ext.py | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py index 9fde1be1..de3ca312 100644 --- a/tests/test_x509_ext.py +++ b/tests/test_x509_ext.py @@ -9,32 +9,49 @@ import pytest from cryptography import x509 -class TestBasicConstraints(object): - def test_ca_not_boolean(self): +class TestExtension(object): + def test_not_an_oid(self): + bc = x509.BasicConstraints(False, None) with pytest.raises(TypeError): - x509.BasicConstraints("notbool", None, False) + x509.Extension("notanoid", True, bc) + + def test_critical_not_a_bool(self): + bc = x509.BasicConstraints(False, None) + with pytest.raises(TypeError): + x509.Extension(x509.OID_BASIC_CONSTRAINTS, "notabool", bc) + + def test_repr(self): + bc = x509.BasicConstraints(False, None) + ext = x509.Extension(x509.OID_BASIC_CONSTRAINTS, True, bc) + assert repr(ext) == ( + "<Extension(oid=<ObjectIdentifier(oid=2.5.29.19, name=basicConst" + "raints)>, critical=True, value=<BasicConstraints(ca=False, path" + "_length=None)>)>" + ) + - def test_critical_not_boolean(self): +class TestBasicConstraints(object): + def test_ca_not_boolean(self): with pytest.raises(TypeError): - x509.BasicConstraints(False, None, "notbool") + x509.BasicConstraints("notbool", None) def test_path_length_not_ca(self): with pytest.raises(ValueError): - x509.BasicConstraints(False, 0, True) + x509.BasicConstraints(False, 0) def test_path_length_not_int(self): with pytest.raises(TypeError): - x509.BasicConstraints(True, 1.1, True) + x509.BasicConstraints(True, 1.1) with pytest.raises(TypeError): - x509.BasicConstraints(True, "notint", True) + x509.BasicConstraints(True, "notint") def test_path_length_negative(self): with pytest.raises(TypeError): - x509.BasicConstraints(True, -1, True) + x509.BasicConstraints(True, -1) def test_repr(self): - na = x509.BasicConstraints(True, None, True) + na = x509.BasicConstraints(True, None) assert repr(na) == ( - "<BasicConstraints(ca=True, path_length=None, critical=True)>" + "<BasicConstraints(ca=True, path_length=None)>" ) |