diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2022-12-20 21:44:47 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-21 09:44:47 +0700 |
| commit | 7ff729ecf2ffeffc8442811a7ad5c8a9ab24351c (patch) | |
| tree | d76a1971dcfa7ccf567bae9032799c475a955207 /tests | |
| parent | 4868142f4193c441b4995f54c70caad7b06dc093 (diff) | |
| download | cryptography-7ff729ecf2ffeffc8442811a7ad5c8a9ab24351c.tar.gz | |
Switch from flake8 to ruff (#7920)
It's more than 60x faster.
Diffstat (limited to 'tests')
55 files changed, 67 insertions, 113 deletions
diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index a747f4d03..9879ca984 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -21,7 +21,6 @@ from cryptography.hazmat.primitives.ciphers import Cipher from cryptography.hazmat.primitives.ciphers.algorithms import AES from cryptography.hazmat.primitives.ciphers.modes import CBC -from ..primitives.fixtures_rsa import RSA_KEY_2048, RSA_KEY_512 from ...doubles import ( DummyAsymmetricPadding, DummyBlockCipherAlgorithm, @@ -34,6 +33,7 @@ from ...utils import ( load_vectors_from_file, raises_unsupported_algorithm, ) +from ..primitives.fixtures_rsa import RSA_KEY_2048, RSA_KEY_512 def skip_if_libre_ssl(openssl_version): diff --git a/tests/hazmat/backends/test_openssl_memleak.py b/tests/hazmat/backends/test_openssl_memleak.py index e23054a6e..ad5c4eb70 100644 --- a/tests/hazmat/backends/test_openssl_memleak.py +++ b/tests/hazmat/backends/test_openssl_memleak.py @@ -13,7 +13,6 @@ import pytest from cryptography.hazmat.bindings.openssl.binding import Binding - MEMORY_LEAK_SCRIPT = """ import sys diff --git a/tests/hazmat/primitives/fixtures_dsa.py b/tests/hazmat/primitives/fixtures_dsa.py index eca0ec431..6675a2c10 100644 --- a/tests/hazmat/primitives/fixtures_dsa.py +++ b/tests/hazmat/primitives/fixtures_dsa.py @@ -9,7 +9,6 @@ from cryptography.hazmat.primitives.asymmetric.dsa import ( DSAPublicNumbers, ) - DSA_KEY_1024 = DSAPrivateNumbers( public_numbers=DSAPublicNumbers( parameter_numbers=DSAParameterNumbers( diff --git a/tests/hazmat/primitives/fixtures_ec.py b/tests/hazmat/primitives/fixtures_ec.py index 317c2ab24..fa671ac55 100644 --- a/tests/hazmat/primitives/fixtures_ec.py +++ b/tests/hazmat/primitives/fixtures_ec.py @@ -5,7 +5,6 @@ from cryptography.hazmat.primitives.asymmetric import ec - EC_KEY_SECT571R1 = ec.EllipticCurvePrivateNumbers( private_value=int( "213997069697108634621868251335076179190383272087548888968788698953" diff --git a/tests/hazmat/primitives/fixtures_rsa.py b/tests/hazmat/primitives/fixtures_rsa.py index f6b5c3b9f..09b32ab00 100644 --- a/tests/hazmat/primitives/fixtures_rsa.py +++ b/tests/hazmat/primitives/fixtures_rsa.py @@ -8,7 +8,6 @@ from cryptography.hazmat.primitives.asymmetric.rsa import ( RSAPublicNumbers, ) - RSA_KEY_512 = RSAPrivateNumbers( p=int( "d57846898d5c0de249c08467586cb458fa9bc417cdf297f73cfc52281b787cd9", 16 diff --git a/tests/hazmat/primitives/test_3des.py b/tests/hazmat/primitives/test_3des.py index ea39a2102..007ecfe21 100644 --- a/tests/hazmat/primitives/test_3des.py +++ b/tests/hazmat/primitives/test_3des.py @@ -14,8 +14,8 @@ import pytest from cryptography.hazmat.primitives.ciphers import algorithms, modes -from .utils import generate_encrypt_test from ...utils import load_nist_vectors +from .utils import generate_encrypt_test @pytest.mark.supported( diff --git a/tests/hazmat/primitives/test_aead.py b/tests/hazmat/primitives/test_aead.py index b7a4aedf3..98ebae866 100644 --- a/tests/hazmat/primitives/test_aead.py +++ b/tests/hazmat/primitives/test_aead.py @@ -17,13 +17,13 @@ from cryptography.hazmat.primitives.ciphers.aead import ( ChaCha20Poly1305, ) -from .utils import _load_all_params from ...utils import ( load_nist_ccm_vectors, load_nist_vectors, load_vectors_from_file, raises_unsupported_algorithm, ) +from .utils import _load_all_params class FakeData(bytes): diff --git a/tests/hazmat/primitives/test_aes.py b/tests/hazmat/primitives/test_aes.py index 9d68ef202..5798aefc6 100644 --- a/tests/hazmat/primitives/test_aes.py +++ b/tests/hazmat/primitives/test_aes.py @@ -10,9 +10,9 @@ import pytest from cryptography.hazmat.primitives.ciphers import algorithms, base, modes -from .utils import _load_all_params, generate_encrypt_test from ...doubles import DummyMode from ...utils import load_nist_vectors +from .utils import _load_all_params, generate_encrypt_test @pytest.mark.supported( diff --git a/tests/hazmat/primitives/test_aes_gcm.py b/tests/hazmat/primitives/test_aes_gcm.py index 9220e9e09..c1154a962 100644 --- a/tests/hazmat/primitives/test_aes_gcm.py +++ b/tests/hazmat/primitives/test_aes_gcm.py @@ -10,8 +10,8 @@ import pytest from cryptography.hazmat.primitives.ciphers import algorithms, base, modes -from .utils import generate_aead_test from ...utils import load_nist_vectors +from .utils import generate_aead_test @pytest.mark.supported( diff --git a/tests/hazmat/primitives/test_arc4.py b/tests/hazmat/primitives/test_arc4.py index 5bc23f92e..b589518ad 100644 --- a/tests/hazmat/primitives/test_arc4.py +++ b/tests/hazmat/primitives/test_arc4.py @@ -10,8 +10,8 @@ import pytest from cryptography.hazmat.primitives.ciphers import algorithms -from .utils import generate_stream_encryption_test from ...utils import load_nist_vectors +from .utils import generate_stream_encryption_test @pytest.mark.supported( diff --git a/tests/hazmat/primitives/test_block.py b/tests/hazmat/primitives/test_block.py index fa2c4f52a..b831de176 100644 --- a/tests/hazmat/primitives/test_block.py +++ b/tests/hazmat/primitives/test_block.py @@ -15,12 +15,12 @@ from cryptography.hazmat.primitives.ciphers import ( modes, ) +from ...doubles import DummyCipherAlgorithm, DummyMode +from ...utils import raises_unsupported_algorithm from .utils import ( generate_aead_exception_test, generate_aead_tag_exception_test, ) -from ...doubles import DummyCipherAlgorithm, DummyMode -from ...utils import raises_unsupported_algorithm class TestCipher: diff --git a/tests/hazmat/primitives/test_blowfish.py b/tests/hazmat/primitives/test_blowfish.py index 4ff8c1f2c..b8f34dfce 100644 --- a/tests/hazmat/primitives/test_blowfish.py +++ b/tests/hazmat/primitives/test_blowfish.py @@ -10,8 +10,8 @@ import pytest from cryptography.hazmat.primitives.ciphers import algorithms, modes -from .utils import generate_encrypt_test from ...utils import load_nist_vectors +from .utils import generate_encrypt_test @pytest.mark.supported( diff --git a/tests/hazmat/primitives/test_camellia.py b/tests/hazmat/primitives/test_camellia.py index 8ec75510b..d6f1fca86 100644 --- a/tests/hazmat/primitives/test_camellia.py +++ b/tests/hazmat/primitives/test_camellia.py @@ -10,8 +10,8 @@ import pytest from cryptography.hazmat.primitives.ciphers import algorithms, modes -from .utils import generate_encrypt_test from ...utils import load_cryptrec_vectors, load_nist_vectors +from .utils import generate_encrypt_test @pytest.mark.supported( diff --git a/tests/hazmat/primitives/test_cast5.py b/tests/hazmat/primitives/test_cast5.py index 6c6f0c884..a6f186a3c 100644 --- a/tests/hazmat/primitives/test_cast5.py +++ b/tests/hazmat/primitives/test_cast5.py @@ -10,8 +10,8 @@ import pytest from cryptography.hazmat.primitives.ciphers import algorithms, modes -from .utils import generate_encrypt_test from ...utils import load_nist_vectors +from .utils import generate_encrypt_test @pytest.mark.supported( diff --git a/tests/hazmat/primitives/test_chacha20.py b/tests/hazmat/primitives/test_chacha20.py index 4dd1b08cd..5337465b9 100644 --- a/tests/hazmat/primitives/test_chacha20.py +++ b/tests/hazmat/primitives/test_chacha20.py @@ -11,8 +11,8 @@ import pytest from cryptography.hazmat.primitives.ciphers import Cipher, algorithms -from .utils import _load_all_params from ...utils import load_nist_vectors +from .utils import _load_all_params @pytest.mark.supported( diff --git a/tests/hazmat/primitives/test_cmac.py b/tests/hazmat/primitives/test_cmac.py index 9596705b1..c9e7fdd88 100644 --- a/tests/hazmat/primitives/test_cmac.py +++ b/tests/hazmat/primitives/test_cmac.py @@ -7,10 +7,7 @@ import binascii import pytest -from cryptography.exceptions import ( - AlreadyFinalized, - InvalidSignature, -) +from cryptography.exceptions import AlreadyFinalized, InvalidSignature from cryptography.hazmat.primitives.ciphers.algorithms import ( AES, ARC4, @@ -18,11 +15,7 @@ from cryptography.hazmat.primitives.ciphers.algorithms import ( ) from cryptography.hazmat.primitives.cmac import CMAC -from ...utils import ( - load_nist_vectors, - load_vectors_from_file, -) - +from ...utils import load_nist_vectors, load_vectors_from_file vectors_aes128 = load_vectors_from_file( "CMAC/nist-800-38b-aes128.txt", load_nist_vectors diff --git a/tests/hazmat/primitives/test_concatkdf.py b/tests/hazmat/primitives/test_concatkdf.py index bd0117ce1..f0dd18828 100644 --- a/tests/hazmat/primitives/test_concatkdf.py +++ b/tests/hazmat/primitives/test_concatkdf.py @@ -9,8 +9,10 @@ import pytest from cryptography.exceptions import AlreadyFinalized, InvalidKey from cryptography.hazmat.primitives import hashes -from cryptography.hazmat.primitives.kdf.concatkdf import ConcatKDFHMAC -from cryptography.hazmat.primitives.kdf.concatkdf import ConcatKDFHash +from cryptography.hazmat.primitives.kdf.concatkdf import ( + ConcatKDFHash, + ConcatKDFHMAC, +) class TestConcatKDFHash: diff --git a/tests/hazmat/primitives/test_dh.py b/tests/hazmat/primitives/test_dh.py index 6e708676b..9a28d6114 100644 --- a/tests/hazmat/primitives/test_dh.py +++ b/tests/hazmat/primitives/test_dh.py @@ -13,9 +13,9 @@ import pytest from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric import dh -from .fixtures_dh import FFDH3072_P from ...doubles import DummyKeySerializationEncryption from ...utils import load_nist_vectors, load_vectors_from_file +from .fixtures_dh import FFDH3072_P # RFC 3526 P_1536 = int( diff --git a/tests/hazmat/primitives/test_dsa.py b/tests/hazmat/primitives/test_dsa.py index 424ffcee5..4ad4e9317 100644 --- a/tests/hazmat/primitives/test_dsa.py +++ b/tests/hazmat/primitives/test_dsa.py @@ -17,14 +17,14 @@ from cryptography.hazmat.primitives.asymmetric.utils import ( encode_dss_signature, ) -from .fixtures_dsa import DSA_KEY_1024, DSA_KEY_2048, DSA_KEY_3072 -from .utils import skip_fips_traditional_openssl from ...doubles import DummyHashAlgorithm, DummyKeySerializationEncryption from ...utils import ( load_fips_dsa_key_pair_vectors, load_fips_dsa_sig_vectors, load_vectors_from_file, ) +from .fixtures_dsa import DSA_KEY_1024, DSA_KEY_2048, DSA_KEY_3072 +from .utils import skip_fips_traditional_openssl _ALGORITHMS_DICT: typing.Dict[str, hashes.HashAlgorithm] = { "SHA1": hashes.SHA1(), diff --git a/tests/hazmat/primitives/test_ec.py b/tests/hazmat/primitives/test_ec.py index 3d488be17..142024459 100644 --- a/tests/hazmat/primitives/test_ec.py +++ b/tests/hazmat/primitives/test_ec.py @@ -20,8 +20,6 @@ from cryptography.hazmat.primitives.asymmetric.utils import ( encode_dss_signature, ) -from .fixtures_ec import EC_KEY_SECP384R1 -from .utils import skip_fips_traditional_openssl from ...doubles import DummyKeySerializationEncryption from ...utils import ( load_fips_ecdsa_key_pair_vectors, @@ -31,6 +29,8 @@ from ...utils import ( load_vectors_from_file, raises_unsupported_algorithm, ) +from .fixtures_ec import EC_KEY_SECP384R1 +from .utils import skip_fips_traditional_openssl _HASH_TYPES: typing.Dict[str, typing.Type[hashes.HashAlgorithm]] = { "SHA-1": hashes.SHA1, diff --git a/tests/hazmat/primitives/test_hash_vectors.py b/tests/hazmat/primitives/test_hash_vectors.py index d5916f061..bde811186 100644 --- a/tests/hazmat/primitives/test_hash_vectors.py +++ b/tests/hazmat/primitives/test_hash_vectors.py @@ -10,8 +10,8 @@ import pytest from cryptography.hazmat.primitives import hashes -from .utils import _load_all_params, generate_hash_test from ...utils import load_hash_vectors, load_nist_vectors +from .utils import _load_all_params, generate_hash_test @pytest.mark.supported( diff --git a/tests/hazmat/primitives/test_hashes.py b/tests/hazmat/primitives/test_hashes.py index 37744e745..1d096772a 100644 --- a/tests/hazmat/primitives/test_hashes.py +++ b/tests/hazmat/primitives/test_hashes.py @@ -10,9 +10,9 @@ import pytest from cryptography.exceptions import AlreadyFinalized, _Reasons from cryptography.hazmat.primitives import hashes -from .utils import generate_base_hash_test from ...doubles import DummyHashAlgorithm from ...utils import raises_unsupported_algorithm +from .utils import generate_base_hash_test class TestHashContext: diff --git a/tests/hazmat/primitives/test_hkdf.py b/tests/hazmat/primitives/test_hkdf.py index cc001baf5..0bd5c97c4 100644 --- a/tests/hazmat/primitives/test_hkdf.py +++ b/tests/hazmat/primitives/test_hkdf.py @@ -12,10 +12,7 @@ from cryptography.exceptions import AlreadyFinalized, InvalidKey from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.kdf.hkdf import HKDF, HKDFExpand -from ...utils import ( - load_nist_vectors, - load_vectors_from_file, -) +from ...utils import load_nist_vectors, load_vectors_from_file class TestHKDF: diff --git a/tests/hazmat/primitives/test_hkdf_vectors.py b/tests/hazmat/primitives/test_hkdf_vectors.py index 711d1b5ec..080aa1b5b 100644 --- a/tests/hazmat/primitives/test_hkdf_vectors.py +++ b/tests/hazmat/primitives/test_hkdf_vectors.py @@ -9,8 +9,8 @@ import pytest from cryptography.hazmat.primitives import hashes -from .utils import generate_hkdf_test from ...utils import load_nist_vectors +from .utils import generate_hkdf_test @pytest.mark.supported( diff --git a/tests/hazmat/primitives/test_hmac.py b/tests/hazmat/primitives/test_hmac.py index 414385c5d..818ff2a7d 100644 --- a/tests/hazmat/primitives/test_hmac.py +++ b/tests/hazmat/primitives/test_hmac.py @@ -14,9 +14,9 @@ from cryptography.exceptions import ( ) from cryptography.hazmat.primitives import hashes, hmac -from .utils import generate_base_hmac_test from ...doubles import DummyHashAlgorithm from ...utils import raises_unsupported_algorithm +from .utils import generate_base_hmac_test @pytest.mark.supported( diff --git a/tests/hazmat/primitives/test_hmac_vectors.py b/tests/hazmat/primitives/test_hmac_vectors.py index 703065a55..790993a34 100644 --- a/tests/hazmat/primitives/test_hmac_vectors.py +++ b/tests/hazmat/primitives/test_hmac_vectors.py @@ -9,8 +9,8 @@ import pytest from cryptography.hazmat.primitives import hashes, hmac -from .utils import generate_hmac_test from ...utils import load_hash_vectors +from .utils import generate_hmac_test @pytest.mark.supported( diff --git a/tests/hazmat/primitives/test_idea.py b/tests/hazmat/primitives/test_idea.py index d591fe4e7..9817d5444 100644 --- a/tests/hazmat/primitives/test_idea.py +++ b/tests/hazmat/primitives/test_idea.py @@ -10,8 +10,8 @@ import pytest from cryptography.hazmat.primitives.ciphers import algorithms, modes -from .utils import generate_encrypt_test from ...utils import load_nist_vectors +from .utils import generate_encrypt_test @pytest.mark.supported( diff --git a/tests/hazmat/primitives/test_kbkdf.py b/tests/hazmat/primitives/test_kbkdf.py index bb8ebea0d..4329e3df6 100644 --- a/tests/hazmat/primitives/test_kbkdf.py +++ b/tests/hazmat/primitives/test_kbkdf.py @@ -11,9 +11,9 @@ from cryptography.exceptions import AlreadyFinalized, InvalidKey, _Reasons from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.ciphers import algorithms from cryptography.hazmat.primitives.kdf.kbkdf import ( - CounterLocation, KBKDFCMAC, KBKDFHMAC, + CounterLocation, Mode, ) diff --git a/tests/hazmat/primitives/test_kbkdf_vectors.py b/tests/hazmat/primitives/test_kbkdf_vectors.py index fef75fe21..cab817bf4 100644 --- a/tests/hazmat/primitives/test_kbkdf_vectors.py +++ b/tests/hazmat/primitives/test_kbkdf_vectors.py @@ -5,8 +5,8 @@ import os -from .utils import generate_kbkdf_counter_mode_test from ...utils import load_nist_kbkdf_vectors +from .utils import generate_kbkdf_counter_mode_test class TestCounterKDFCounterMode: diff --git a/tests/hazmat/primitives/test_keywrap.py b/tests/hazmat/primitives/test_keywrap.py index b2fa05d74..7dfb80901 100644 --- a/tests/hazmat/primitives/test_keywrap.py +++ b/tests/hazmat/primitives/test_keywrap.py @@ -11,8 +11,8 @@ import pytest from cryptography.hazmat.primitives import keywrap from cryptography.hazmat.primitives.ciphers import algorithms, modes -from .utils import _load_all_params from ...utils import load_nist_vectors +from .utils import _load_all_params class TestAESKeyWrap: diff --git a/tests/hazmat/primitives/test_pbkdf2hmac_vectors.py b/tests/hazmat/primitives/test_pbkdf2hmac_vectors.py index f092894f5..60d2f864d 100644 --- a/tests/hazmat/primitives/test_pbkdf2hmac_vectors.py +++ b/tests/hazmat/primitives/test_pbkdf2hmac_vectors.py @@ -7,8 +7,8 @@ import pytest from cryptography.hazmat.primitives import hashes -from .utils import generate_pbkdf2_test from ...utils import load_nist_vectors +from .utils import generate_pbkdf2_test @pytest.mark.supported( diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py index 7a4b2f1e3..919331caf 100644 --- a/tests/hazmat/primitives/test_rsa.py +++ b/tests/hazmat/primitives/test_rsa.py @@ -15,16 +15,25 @@ from cryptography.exceptions import ( _Reasons, ) from cryptography.hazmat.primitives import hashes, serialization -from cryptography.hazmat.primitives.asymmetric import ( - padding, - rsa, - utils as asym_utils, -) +from cryptography.hazmat.primitives.asymmetric import padding, rsa +from cryptography.hazmat.primitives.asymmetric import utils as asym_utils from cryptography.hazmat.primitives.asymmetric.rsa import ( RSAPrivateNumbers, RSAPublicNumbers, ) +from ...doubles import ( + DummyAsymmetricPadding, + DummyHashAlgorithm, + DummyKeySerializationEncryption, +) +from ...utils import ( + load_nist_vectors, + load_pkcs1_vectors, + load_rsa_nist_vectors, + load_vectors_from_file, + raises_unsupported_algorithm, +) from .fixtures_rsa import ( RSA_KEY_1024, RSA_KEY_1025, @@ -48,18 +57,6 @@ from .utils import ( generate_rsa_verification_test, skip_fips_traditional_openssl, ) -from ...doubles import ( - DummyAsymmetricPadding, - DummyHashAlgorithm, - DummyKeySerializationEncryption, -) -from ...utils import ( - load_nist_vectors, - load_pkcs1_vectors, - load_rsa_nist_vectors, - load_vectors_from_file, - raises_unsupported_algorithm, -) class DummyMGF(padding.MGF): diff --git a/tests/hazmat/primitives/test_scrypt.py b/tests/hazmat/primitives/test_scrypt.py index 6e95a1f26..4b4641854 100644 --- a/tests/hazmat/primitives/test_scrypt.py +++ b/tests/hazmat/primitives/test_scrypt.py @@ -8,12 +8,8 @@ import os import pytest -from cryptography.exceptions import ( - AlreadyFinalized, - InvalidKey, -) -from cryptography.hazmat.primitives.kdf.scrypt import Scrypt, _MEM_LIMIT - +from cryptography.exceptions import AlreadyFinalized, InvalidKey +from cryptography.hazmat.primitives.kdf.scrypt import _MEM_LIMIT, Scrypt from tests.utils import ( load_nist_vectors, load_vectors_from_file, diff --git a/tests/hazmat/primitives/test_seed.py b/tests/hazmat/primitives/test_seed.py index eb0b88c2a..9f68bc3fb 100644 --- a/tests/hazmat/primitives/test_seed.py +++ b/tests/hazmat/primitives/test_seed.py @@ -10,8 +10,8 @@ import pytest from cryptography.hazmat.primitives.ciphers import algorithms, modes -from .utils import generate_encrypt_test from ...utils import load_nist_vectors +from .utils import generate_encrypt_test @pytest.mark.supported( diff --git a/tests/hazmat/primitives/test_serialization.py b/tests/hazmat/primitives/test_serialization.py index 3a08d5570..3f1a55c23 100644 --- a/tests/hazmat/primitives/test_serialization.py +++ b/tests/hazmat/primitives/test_serialization.py @@ -39,15 +39,11 @@ from cryptography.hazmat.primitives.serialization import ( ) from cryptography.hazmat.primitives.serialization.pkcs12 import PBES - -from .fixtures_rsa import RSA_KEY_2048 -from .test_ec import _skip_curve_unsupported -from .utils import ( - _check_dsa_private_numbers, - _check_rsa_private_numbers, -) from ...doubles import DummyKeySerializationEncryption from ...utils import load_vectors_from_file, raises_unsupported_algorithm +from .fixtures_rsa import RSA_KEY_2048 +from .test_ec import _skip_curve_unsupported +from .utils import _check_dsa_private_numbers, _check_rsa_private_numbers def _skip_fips_format(key_path, password, backend): diff --git a/tests/hazmat/primitives/test_sm4.py b/tests/hazmat/primitives/test_sm4.py index 07b0cc7f7..13d9b5051 100644 --- a/tests/hazmat/primitives/test_sm4.py +++ b/tests/hazmat/primitives/test_sm4.py @@ -9,8 +9,8 @@ import pytest from cryptography.hazmat.primitives.ciphers import algorithms, modes -from .utils import generate_encrypt_test from ...utils import load_nist_vectors +from .utils import generate_encrypt_test @pytest.mark.supported( diff --git a/tests/hazmat/primitives/twofactor/test_hotp.py b/tests/hazmat/primitives/twofactor/test_hotp.py index d1c6cb530..31e01a495 100644 --- a/tests/hazmat/primitives/twofactor/test_hotp.py +++ b/tests/hazmat/primitives/twofactor/test_hotp.py @@ -12,10 +12,7 @@ from cryptography.hazmat.primitives.hashes import MD5, SHA1 from cryptography.hazmat.primitives.twofactor import InvalidToken from cryptography.hazmat.primitives.twofactor.hotp import HOTP -from ....utils import ( - load_nist_vectors, - load_vectors_from_file, -) +from ....utils import load_nist_vectors, load_vectors_from_file vectors = load_vectors_from_file("twofactor/rfc-4226.txt", load_nist_vectors) diff --git a/tests/hazmat/primitives/twofactor/test_totp.py b/tests/hazmat/primitives/twofactor/test_totp.py index 3c8d6b372..f68a8339c 100644 --- a/tests/hazmat/primitives/twofactor/test_totp.py +++ b/tests/hazmat/primitives/twofactor/test_totp.py @@ -9,10 +9,7 @@ from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.twofactor import InvalidToken from cryptography.hazmat.primitives.twofactor.totp import TOTP -from ....utils import ( - load_nist_vectors, - load_vectors_from_file, -) +from ....utils import load_nist_vectors, load_vectors_from_file vectors = load_vectors_from_file("twofactor/rfc-6238.txt", load_nist_vectors) diff --git a/tests/hazmat/primitives/utils.py b/tests/hazmat/primitives/utils.py index c8021cc2f..aac7296e6 100644 --- a/tests/hazmat/primitives/utils.py +++ b/tests/hazmat/primitives/utils.py @@ -26,9 +26,9 @@ from cryptography.hazmat.primitives.ciphers import ( from cryptography.hazmat.primitives.ciphers.modes import GCM from cryptography.hazmat.primitives.kdf.hkdf import HKDF, HKDFExpand from cryptography.hazmat.primitives.kdf.kbkdf import ( - CounterLocation, KBKDFCMAC, KBKDFHMAC, + CounterLocation, Mode, ) from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC diff --git a/tests/test_fernet.py b/tests/test_fernet.py index 58dd77296..d4b1561a0 100644 --- a/tests/test_fernet.py +++ b/tests/test_fernet.py @@ -10,16 +10,13 @@ import os import time import iso8601 - import pretend - import pytest +import cryptography_vectors from cryptography.fernet import Fernet, InvalidToken, MultiFernet from cryptography.hazmat.primitives.ciphers import algorithms, modes -import cryptography_vectors - def json_parametrize(keys, filename): vector_file = cryptography_vectors.open_vector_file( diff --git a/tests/test_utils.py b/tests/test_utils.py index 8b07c91b0..9f6e27150 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -9,14 +9,12 @@ import os import textwrap import pretend - import pytest import cryptography import cryptography.utils -from cryptography.exceptions import UnsupportedAlgorithm, _Reasons - import cryptography_vectors +from cryptography.exceptions import UnsupportedAlgorithm, _Reasons from . import deprecated_module from .utils import ( diff --git a/tests/utils.py b/tests/utils.py index 6119d3f4d..405cfbc78 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -13,10 +13,8 @@ from contextlib import contextmanager import pytest -from cryptography.exceptions import UnsupportedAlgorithm - import cryptography_vectors - +from cryptography.exceptions import UnsupportedAlgorithm HashVector = collections.namedtuple("HashVector", ["message", "digest"]) KeyedHashVector = collections.namedtuple( diff --git a/tests/wycheproof/test_aes.py b/tests/wycheproof/test_aes.py index 891d8df43..ce83fe3c0 100644 --- a/tests/wycheproof/test_aes.py +++ b/tests/wycheproof/test_aes.py @@ -12,8 +12,8 @@ from cryptography.hazmat.primitives import padding from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from cryptography.hazmat.primitives.ciphers.aead import AESCCM, AESGCM -from .utils import wycheproof_tests from ..hazmat.primitives.test_aead import _aead_supported +from .utils import wycheproof_tests @wycheproof_tests("aes_cbc_pkcs5_test.json") diff --git a/tests/wycheproof/test_chacha20poly1305.py b/tests/wycheproof/test_chacha20poly1305.py index 7cb8ff50f..06d6fc76a 100644 --- a/tests/wycheproof/test_chacha20poly1305.py +++ b/tests/wycheproof/test_chacha20poly1305.py @@ -10,8 +10,8 @@ import pytest from cryptography.exceptions import InvalidTag from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305 -from .utils import wycheproof_tests from ..hazmat.primitives.test_aead import _aead_supported +from .utils import wycheproof_tests @pytest.mark.skipif( diff --git a/tests/wycheproof/test_dsa.py b/tests/wycheproof/test_dsa.py index 3d31ee170..b7da82dc3 100644 --- a/tests/wycheproof/test_dsa.py +++ b/tests/wycheproof/test_dsa.py @@ -13,7 +13,6 @@ from cryptography.hazmat.primitives.asymmetric import dsa from .utils import wycheproof_tests - _DIGESTS = { "SHA-1": hashes.SHA1(), "SHA-224": hashes.SHA224(), diff --git a/tests/wycheproof/test_ecdh.py b/tests/wycheproof/test_ecdh.py index 672863fe7..1de26cb26 100644 --- a/tests/wycheproof/test_ecdh.py +++ b/tests/wycheproof/test_ecdh.py @@ -11,9 +11,8 @@ from cryptography.exceptions import UnsupportedAlgorithm from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric import ec -from .utils import wycheproof_tests from ..hazmat.primitives.test_ec import _skip_exchange_algorithm_unsupported - +from .utils import wycheproof_tests _CURVES = { "secp224r1": ec.SECP224R1(), diff --git a/tests/wycheproof/test_ecdsa.py b/tests/wycheproof/test_ecdsa.py index b2ec9dfec..ffdfcc461 100644 --- a/tests/wycheproof/test_ecdsa.py +++ b/tests/wycheproof/test_ecdsa.py @@ -13,7 +13,6 @@ from cryptography.hazmat.primitives.asymmetric import ec from .utils import wycheproof_tests - _DIGESTS = { "SHA-1": hashes.SHA1(), "SHA-224": hashes.SHA224(), diff --git a/tests/wycheproof/test_hkdf.py b/tests/wycheproof/test_hkdf.py index 4886be0fe..3d54e44ff 100644 --- a/tests/wycheproof/test_hkdf.py +++ b/tests/wycheproof/test_hkdf.py @@ -12,7 +12,6 @@ from cryptography.hazmat.primitives.kdf.hkdf import HKDF from .utils import wycheproof_tests - _HASH_ALGORITHMS = { "HKDF-SHA-1": hashes.SHA1(), "HKDF-SHA-256": hashes.SHA256(), diff --git a/tests/wycheproof/test_hmac.py b/tests/wycheproof/test_hmac.py index 84b0c19a0..49fe772cb 100644 --- a/tests/wycheproof/test_hmac.py +++ b/tests/wycheproof/test_hmac.py @@ -12,7 +12,6 @@ from cryptography.hazmat.primitives import hashes, hmac from .utils import wycheproof_tests - _HMAC_ALGORITHMS = { "HMACSHA1": hashes.SHA1(), "HMACSHA224": hashes.SHA224(), diff --git a/tests/wycheproof/test_rsa.py b/tests/wycheproof/test_rsa.py index e2b8426fd..56ec21bc0 100644 --- a/tests/wycheproof/test_rsa.py +++ b/tests/wycheproof/test_rsa.py @@ -13,7 +13,6 @@ from cryptography.hazmat.primitives.asymmetric import padding, rsa from .utils import wycheproof_tests - _DIGESTS = { "SHA-1": hashes.SHA1(), "SHA-224": hashes.SHA224(), diff --git a/tests/x509/test_ocsp.py b/tests/x509/test_ocsp.py index 9090e5205..ade916195 100644 --- a/tests/x509/test_ocsp.py +++ b/tests/x509/test_ocsp.py @@ -15,9 +15,9 @@ from cryptography.hazmat.primitives.asymmetric import ec, ed25519, ed448, rsa from cryptography.hazmat.primitives.asymmetric.padding import PKCS1v15 from cryptography.x509 import ocsp -from .test_x509 import DummyExtension, _load_cert from ..hazmat.primitives.fixtures_ec import EC_KEY_SECP256R1 from ..utils import load_vectors_from_file, raises_unsupported_algorithm +from .test_x509 import DummyExtension, _load_cert def _load_data(filename, loader): diff --git a/tests/x509/test_x509.py b/tests/x509/test_x509.py index 8a92c297c..1de0f6c45 100644 --- a/tests/x509/test_x509.py +++ b/tests/x509/test_x509.py @@ -12,7 +12,6 @@ import os import typing import pytest - import pytz from cryptography import utils, x509 diff --git a/tests/x509/test_x509_crlbuilder.py b/tests/x509/test_x509_crlbuilder.py index e3e34285d..5960cdd3b 100644 --- a/tests/x509/test_x509_crlbuilder.py +++ b/tests/x509/test_x509_crlbuilder.py @@ -6,7 +6,6 @@ import datetime import pytest - import pytz from cryptography import x509 @@ -18,11 +17,11 @@ from cryptography.x509.oid import ( SignatureAlgorithmOID, ) -from .test_x509 import DummyExtension from ..hazmat.primitives.fixtures_dsa import DSA_KEY_2048 from ..hazmat.primitives.fixtures_ec import EC_KEY_SECP256R1 from ..hazmat.primitives.fixtures_rsa import RSA_KEY_2048, RSA_KEY_512 from ..hazmat.primitives.test_ec import _skip_curve_unsupported +from .test_x509 import DummyExtension class TestCertificateRevocationListBuilder: diff --git a/tests/x509/test_x509_ext.py b/tests/x509/test_x509_ext.py index 7284a73be..d3276b7cd 100644 --- a/tests/x509/test_x509_ext.py +++ b/tests/x509/test_x509_ext.py @@ -10,7 +10,6 @@ import os import typing import pretend - import pytest from cryptography import x509 @@ -37,10 +36,10 @@ from cryptography.x509.oid import ( SubjectInformationAccessOID, ) -from .test_x509 import _load_cert from ..hazmat.primitives.fixtures_rsa import RSA_KEY_2048 from ..hazmat.primitives.test_ec import _skip_curve_unsupported from ..utils import load_vectors_from_file +from .test_x509 import _load_cert def _make_certbuilder(private_key): diff --git a/tests/x509/test_x509_revokedcertbuilder.py b/tests/x509/test_x509_revokedcertbuilder.py index b2facfa51..83a71ff9b 100644 --- a/tests/x509/test_x509_revokedcertbuilder.py +++ b/tests/x509/test_x509_revokedcertbuilder.py @@ -6,7 +6,6 @@ import datetime import pytest - import pytz from cryptography import x509 |
