diff options
| author | Mathias Ertl <mati@er.tl> | 2021-03-15 23:44:02 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-15 18:44:02 -0400 |
| commit | 8d41a94bba7674cfcb120ce7a76b7c3df5c2bb73 (patch) | |
| tree | 3ff165eb8711231b59f6e50ff5dda0c6c021a484 /tests | |
| parent | cd2ab9ec6c14333e10fb161295d5ae355c4a8f96 (diff) | |
| download | cryptography-8d41a94bba7674cfcb120ce7a76b7c3df5c2bb73.tar.gz | |
typehint x509.base (#5899)
* start typing x509.base
* statically type x509.base
* typehint X509Backend interface
* typehint at least the X509Backend interface
* make _CertificateRevocationList/_CertificateSigningRequest actual subclasses of the interface (as done before for Certificate in f16bff2cb)
* tell mypy to ignore lines with deliberately wrong types
* signature_hash_algorithm always returns a hash algorithm (it's not optional)
* Revert "signature_hash_algorithm always returns a hash algorithm (it's not optional)"
This reverts commit f6a5b172b416f8ddea561203c0cf03b55e4ec50e.
* hash algorithm is actually optional
* fix import style
* typehint parsed_version to int, which it de facto always is
* minimize changes
* break import cycle with conditional imports
* ignore access to private members of openssl implementation
* reformat code with Black
* test check for missing public key
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/hazmat/backends/test_openssl.py | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index e6abadbd0..a559998f1 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -478,7 +478,20 @@ class TestOpenSSLSignX509Certificate(object): with pytest.raises(TypeError): backend.create_x509_certificate( - object(), private_key, DummyHashAlgorithm() + object(), # type: ignore[arg-type] + private_key, + DummyHashAlgorithm(), + ) + + def test_builder_requires_public_key(self): + builder = x509.CertificateBuilder() + private_key = RSA_KEY_2048.private_key(backend) + + with pytest.raises(TypeError): + backend.create_x509_certificate( + builder, + private_key, + DummyHashAlgorithm(), ) @@ -488,7 +501,9 @@ class TestOpenSSLSignX509CSR(object): with pytest.raises(TypeError): backend.create_x509_csr( - object(), private_key, DummyHashAlgorithm() + object(), # type: ignore[arg-type] + private_key, + DummyHashAlgorithm(), ) @@ -497,13 +512,19 @@ class TestOpenSSLSignX509CertificateRevocationList(object): private_key = RSA_KEY_2048.private_key(backend) with pytest.raises(TypeError): - backend.create_x509_crl(object(), private_key, hashes.SHA256()) + backend.create_x509_crl( + object(), # type: ignore[arg-type] + private_key, + hashes.SHA256(), + ) class TestOpenSSLCreateRevokedCertificate(object): def test_invalid_builder(self): with pytest.raises(TypeError): - backend.create_x509_revoked_certificate(object()) + backend.create_x509_revoked_certificate( + object() # type: ignore[arg-type] + ) class TestOpenSSLSerializationWithOpenSSL(object): |
