diff options
author | Ian Cordasco <graffatcolmingov@gmail.com> | 2015-08-01 23:07:19 -0500 |
---|---|---|
committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2015-08-01 23:07:19 -0500 |
commit | b4a155d4e343a68ae0e53b728ae148dfab6a27d5 (patch) | |
tree | 557a7dae1e9d3143d9f0da9a1edd2c31f8de9648 /tests | |
parent | 91a461e39d943b0672dbb920cc85bf3f85aa04c1 (diff) | |
download | cryptography-b4a155d4e343a68ae0e53b728ae148dfab6a27d5.tar.gz cryptography-b4a155d4e343a68ae0e53b728ae148dfab6a27d5.tar.bz2 cryptography-b4a155d4e343a68ae0e53b728ae148dfab6a27d5.zip |
Add some extra test coverage
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_x509.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py index 7274fd7e..088e617d 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -881,6 +881,15 @@ class TestCertificateBuilder(object): with pytest.raises(TypeError): x509.CertificateBuilder().serial_number(10.0) + def test_serial_number_must_be_non_negative(self): + with pytest.raises(ValueError): + x509.CertificateBuilder().serial_number(-10) + + def test_serial_number_must_be_less_than_160_bits_long(self): + with pytest.raises(ValueError): + # 2 raised to the 160th power is actually 161 bits + x509.CertificateBuilder().serial_number(2 ** 160) + def test_serial_number_may_only_be_set_once(self): builder = x509.CertificateBuilder().serial_number(10) @@ -894,6 +903,11 @@ class TestCertificateBuilder(object): with pytest.raises(TypeError): x509.CertificateBuilder().not_valid_after(datetime.time()) + with pytest.raises(ValueError): + x509.CertificateBuilder().not_valid_after( + datetime.datetime(1960, 8, 10) + ) + def test_not_valid_after_may_only_be_set_once(self): builder = x509.CertificateBuilder().not_valid_after( datetime.datetime.now() @@ -911,6 +925,11 @@ class TestCertificateBuilder(object): with pytest.raises(TypeError): x509.CertificateBuilder().not_valid_before(datetime.time()) + with pytest.raises(ValueError): + x509.CertificateBuilder().not_valid_before( + datetime.datetime(1960, 8, 10) + ) + def test_not_valid_before_may_only_be_set_once(self): builder = x509.CertificateBuilder().not_valid_before( datetime.datetime.now() |