From 3b029927fa2f5f1c2706d6716755cc2588caee3f Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Fri, 25 Mar 2022 18:20:37 -0400 Subject: Refactor sha1 test skipping a tad --- tests/test_client.py | 6 +----- tests/test_pkey.py | 6 +----- tests/test_transport.py | 6 +----- tests/util.py | 4 ++++ 4 files changed, 7 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/test_client.py b/tests/test_client.py index a0a321ce..1c28d824 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -41,17 +41,13 @@ from paramiko import SSHClient from paramiko.pkey import PublicBlob from paramiko.ssh_exception import SSHException, AuthenticationException -from .util import _support, sha1_signing_unsupported, slow +from .util import _support, requires_sha1_signing, slow requires_gss_auth = unittest.skipUnless( paramiko.GSS_AUTH_AVAILABLE, "GSS auth not available" ) -requires_sha1_signing = unittest.skipIf( - sha1_signing_unsupported(), "SHA-1 signing not supported" -) - FINGERPRINTS = { "ssh-dss": b"\x44\x78\xf0\xb9\xa2\x3c\xc5\x18\x20\x09\xff\x75\x5b\xc1\xd2\x6c", # noqa "ssh-rsa": b"\x60\x73\x38\x44\xcb\x51\x86\x65\x7f\xde\xda\xa2\x2b\x5a\x57\xd5", # noqa diff --git a/tests/test_pkey.py b/tests/test_pkey.py index e0d1b0ac..44ab688f 100644 --- a/tests/test_pkey.py +++ b/tests/test_pkey.py @@ -44,13 +44,9 @@ from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateNumbers from mock import patch, Mock import pytest -from .util import _support, is_low_entropy, sha1_signing_unsupported +from .util import _support, is_low_entropy, requires_sha1_signing -requires_sha1_signing = unittest.skipIf( - sha1_signing_unsupported(), "SHA-1 signing not supported" -) - # from openssh's ssh-keygen PUB_RSA = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEA049W6geFpmsljTwfvI1UmKWWJPNFI74+vNKTk4dmzkQY2yAMs6FhlvhlI8ysU4oj71ZsRYMecHbBbxdN79+JRFVYTKaLqjwGENeTd+yv4q+V2PvZv3fLnzApI3l7EJCqhWwJUHJ1jAkZzqDx0tyOL4uoZpww3nmE0kb3y21tH4c=" # noqa PUB_DSS = "ssh-dss AAAAB3NzaC1kc3MAAACBAOeBpgNnfRzr/twmAQRu2XwWAp3CFtrVnug6s6fgwj/oLjYbVtjAy6pl/h0EKCWx2rf1IetyNsTxWrniA9I6HeDj65X1FyDkg6g8tvCnaNB8Xp/UUhuzHuGsMIipRxBxw9LF608EqZcj1E3ytktoW5B5OcjrkEoz3xG7C+rpIjYvAAAAFQDwz4UnmsGiSNu5iqjn3uTzwUpshwAAAIEAkxfFeY8P2wZpDjX0MimZl5wkoFQDL25cPzGBuB4OnB8NoUk/yjAHIIpEShw8V+LzouMK5CTJQo5+Ngw3qIch/WgRmMHy4kBq1SsXMjQCte1So6HBMvBPIW5SiMTmjCfZZiw4AYHK+B/JaOwaG9yRg2Ejg4Ok10+XFDxlqZo8Y+wAAACARmR7CCPjodxASvRbIyzaVpZoJ/Z6x7dAumV+ysrV1BVYd0lYukmnjO1kKBWApqpH1ve9XDQYN8zgxM4b16L21kpoWQnZtXrY3GZ4/it9kUgyB7+NwacIBlXa8cMDL7Q/69o0d54U0X/NeX5QxuYR6OMJlrkQB7oiW/P/1mwjQgE=" # noqa diff --git a/tests/test_transport.py b/tests/test_transport.py index b9daec60..52a49b0e 100644 --- a/tests/test_transport.py +++ b/tests/test_transport.py @@ -61,7 +61,7 @@ from paramiko.common import ( from paramiko.py3compat import bytes, byte_chr from paramiko.message import Message -from .util import needs_builtin, _support, sha1_signing_unsupported, slow +from .util import needs_builtin, _support, requires_sha1_signing, slow from .loop import LoopSocket @@ -77,10 +77,6 @@ Note: An SSH banner may eventually appear. Maybe. """ -requires_sha1_signing = unittest.skipIf( - sha1_signing_unsupported(), "SHA-1 signing not supported" -) - class NullServer(ServerInterface): paranoid_did_password = False diff --git a/tests/util.py b/tests/util.py index 4bf73949..542a0671 100644 --- a/tests/util.py +++ b/tests/util.py @@ -171,3 +171,7 @@ def sha1_signing_unsupported(): return False except UnsupportedAlgorithm as e: return e._reason is _Reasons.UNSUPPORTED_HASH + +requires_sha1_signing = unittest.skipIf( + sha1_signing_unsupported(), "SHA-1 signing not supported" +) -- cgit v1.2.3