aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2019-07-06 21:20:45 -0400
committerPaul Kehrer <paul.l.kehrer@gmail.com>2019-07-06 21:20:45 -0400
commit1e8c5a64190db6611889f45f7f8af543b291383b (patch)
tree00c6055c321ab9aa1c2546e5d272cd1fad2b0c41 /tests
parenta15986844e3ebd71efb7b8183733dd661ce75768 (diff)
downloadcryptography-1e8c5a64190db6611889f45f7f8af543b291383b.tar.gz
cryptography-1e8c5a64190db6611889f45f7f8af543b291383b.tar.bz2
cryptography-1e8c5a64190db6611889f45f7f8af543b291383b.zip
Write a test for an uncovered line (#4940)
Diffstat (limited to 'tests')
-rw-r--r--tests/x509/test_x509.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/x509/test_x509.py b/tests/x509/test_x509.py
index 27062918..cd756b6b 100644
--- a/tests/x509/test_x509.py
+++ b/tests/x509/test_x509.py
@@ -2158,6 +2158,30 @@ class TestCertificateBuilder(object):
with pytest.raises(TypeError):
builder.sign(private_key, algorithm, backend)
+ @pytest.mark.supported(
+ only_if=lambda backend: backend.ed25519_supported(),
+ skip_message="Requires OpenSSL with Ed25519 support"
+ )
+ @pytest.mark.requires_backend_interface(interface=X509Backend)
+ def test_sign_with_unsupported_hash_ed25519(self, backend):
+ private_key = ed25519.Ed25519PrivateKey.generate()
+ builder = x509.CertificateBuilder().subject_name(
+ x509.Name([x509.NameAttribute(NameOID.COUNTRY_NAME, u'US')])
+ ).issuer_name(
+ x509.Name([x509.NameAttribute(NameOID.COUNTRY_NAME, u'US')])
+ ).serial_number(
+ 1
+ ).public_key(
+ private_key.public_key()
+ ).not_valid_before(
+ datetime.datetime(2002, 1, 1, 12, 1)
+ ).not_valid_after(
+ datetime.datetime(2032, 1, 1, 12, 1)
+ )
+
+ with pytest.raises(ValueError):
+ builder.sign(private_key, hashes.SHA256(), backend)
+
@pytest.mark.requires_backend_interface(interface=RSABackend)
@pytest.mark.requires_backend_interface(interface=X509Backend)
def test_sign_rsa_with_md5(self, backend):