Skip to content

Commit

Permalink
reformatted files
Browse files Browse the repository at this point in the history
  • Loading branch information
Lion Holler authored and Lion Holler committed Jun 26, 2024
1 parent 4e437b1 commit 31c8847
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 36 deletions.
4 changes: 1 addition & 3 deletions tests/check_gpg_available.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ class TestGpgAvailable(unittest.TestCase):

def test_gpg_available(self):
"""Test that GPG is available."""
self.assertTrue(
securesystemslib._gpg.constants.have_gpg()
)
self.assertTrue(securesystemslib._gpg.constants.have_gpg())


if __name__ == "__main__":
Expand Down
34 changes: 11 additions & 23 deletions tests/test_gpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from copy import deepcopy
from unittest.mock import patch

# ruff: noqa: I001
import cryptography.hazmat.primitives.hashes as hashing
from cryptography.hazmat import backends
from cryptography.hazmat.primitives import serialization
Expand Down Expand Up @@ -368,9 +369,7 @@ def test_assign_certified_key_info_errors(self):
msg = str(mock_log.info.call_args[0][0])
self.assertTrue(
expected_msg in msg,
"'{}' not in '{}'".format(
expected_msg, msg
),
"'{}' not in '{}'".format(expected_msg, msg),
)

def test_assign_certified_key_info_expiration(self):
Expand Down Expand Up @@ -485,9 +484,7 @@ def test_get_verified_subkeys_errors(self):
msg = str(mock_log.info.call_args[0][0])
self.assertTrue(
expected_msg in msg,
"'{}' not in '{}'".format(
expected_msg, msg
),
"'{}' not in '{}'".format(expected_msg, msg),
)

def test_get_verified_subkeys(self):
Expand All @@ -504,9 +501,9 @@ def test_get_verified_subkeys(self):

# Test subkey without validity period, i.e. it does not expire
self.assertTrue(
subkeys[
"70cfabf1e2f1dc60ac5c7bca10cd20d3d5bcb6ef"
].get("validity_period")
subkeys["70cfabf1e2f1dc60ac5c7bca10cd20d3d5bcb6ef"].get(
"validity_period"
)
is None
)

Expand Down Expand Up @@ -565,7 +562,7 @@ class TestGPGRSA(unittest.TestCase):
unsupported_subkey_keyid = "611A9B648E16F54E8A7FAD5DA51E8CDF3B06524F"
expired_key_keyid = "E8AC80C924116DABB51D4B987CB07D6D2C199C7C"

keyid_768C43 = "7B3ABB26B97B655AB9296BD15B0BD02E1C768C43"
keyid_768C43 = "7B3ABB26B97B655AB9296BD15B0BD02E1C768C43" # noqa: N815

@classmethod
def setUpClass(self):
Expand Down Expand Up @@ -610,9 +607,7 @@ def test_export_pubkey(self):

# load the equivalent ssh key, and make sure that we get the same RSA key
# parameters
ssh_key_basename = "{}.ssh".format(
self.default_keyid
)
ssh_key_basename = "{}.ssh".format(self.default_keyid)
ssh_key_path = os.path.join(self.gnupg_home, ssh_key_basename)
with open(ssh_key_path, "rb") as fp:
keydata = fp.read()
Expand Down Expand Up @@ -708,9 +703,7 @@ def test_create_signature_with_expired_key(self):
expected = "returned non-zero exit status '2'"
self.assertTrue(
expected in str(ctx.exception),
"{} not in {}".format(
expected, ctx.exception
),
"{} not in {}".format(expected, ctx.exception),
)

def test_verify_signature_with_expired_key(self):
Expand All @@ -733,10 +726,7 @@ def test_verify_signature_with_expired_key(self):
)
self.assertTrue(
expected == str(ctx.exception),
"\nexpected: {}"
"\ngot: {}".format(
expected, ctx.exception
),
"\nexpected: {}" "\ngot: {}".format(expected, ctx.exception),
)


Expand Down Expand Up @@ -782,9 +772,7 @@ def test_export_pubkey(self):
our_exported_key = dsa_create_pubkey(key_data)

# load same key, pre-exported with 3rd-party tooling
pem_key_basename = "{}.pem".format(
self.default_keyid
)
pem_key_basename = "{}.pem".format(self.default_keyid)
pem_key_path = os.path.join(self.gnupg_home, pem_key_basename)
with open(pem_key_path, "rb") as fp:
keydata = fp.read()
Expand Down
5 changes: 1 addition & 4 deletions tests/test_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@
logger = logging.getLogger(__name__)


if (
"hashlib"
not in securesystemslib.hash.SUPPORTED_LIBRARIES
):
if "hashlib" not in securesystemslib.hash.SUPPORTED_LIBRARIES:
logger.warning("Not testing hashlib: could not be imported.")


Expand Down
4 changes: 1 addition & 3 deletions tests/test_signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,7 @@ def test_verify_invalid_keytype_scheme(self):
for keytype, scheme, val in test_data:
key = SSlibKey("fake", keytype, scheme, {"public": val})
with self.assertRaises(ValueError):
key._verify(
b"fakesig", b"fakedata"
)
key._verify(b"fakesig", b"fakedata")


class TestSigner(unittest.TestCase):
Expand Down
4 changes: 1 addition & 3 deletions tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def setUp(self):
self.filepath = os.path.join(self.temp_dir, "testfile")
with open(self.filepath, "wb") as test:
test.write(b"testing")
self.fileobj = open(
self.filepath, "rb"
)
self.fileobj = open(self.filepath, "rb")

def tearDown(self):
self.fileobj.close()
Expand Down

0 comments on commit 31c8847

Please sign in to comment.