Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#855)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 22.12.0 → 23.1.0](psf/black@22.12.0...23.1.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Feb 7, 2023
1 parent 1623dc8 commit 9695f4c
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
args: ["--target-version=py37"]
Expand Down
1 change: 0 additions & 1 deletion jwt/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ def verify(self, msg, key, sig):

@staticmethod
def to_jwk(key_obj):

if isinstance(key_obj, EllipticCurvePrivateKey):
public_numbers = key_obj.public_key().public_numbers()
elif isinstance(key_obj, EllipticCurvePublicKey):
Expand Down
1 change: 0 additions & 1 deletion jwt/jwk_set_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def get(self) -> Optional[PyJWKSet]:
return self.jwk_set_with_timestamp.get_jwk_set()

def is_expired(self) -> bool:

return (
self.jwk_set_with_timestamp is not None
and self.lifespan > -1
Expand Down
6 changes: 3 additions & 3 deletions tests/test_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def test_ec_jwk_public_and_private_keys_should_parse_and_verify(self):
"P-521": ECAlgorithm.SHA512,
"secp256k1": ECAlgorithm.SHA256,
}
for (curve, hash) in tests.items():
for curve, hash in tests.items():
algo = ECAlgorithm(hash)

with open(key_path(f"jwk_ec_pub_{curve}.json")) as keyfile:
Expand Down Expand Up @@ -236,7 +236,7 @@ def test_ec_jwk_fails_on_invalid_json(self):
)

# EC private key length invalid
for (curve, point) in valid_points.items():
for curve, point in valid_points.items():
with pytest.raises(InvalidKeyError):
algo.from_jwk(
f'{{"kty": "EC", "crv": "{curve}", "x": "{point["x"]}", "y": "{point["y"]}", "d": "dGVzdA=="}}'
Expand Down Expand Up @@ -318,7 +318,7 @@ def test_ec_to_jwk_with_valid_curves(self):
"P-521": ECAlgorithm.SHA512,
"secp256k1": ECAlgorithm.SHA256,
}
for (curve, hash) in tests.items():
for curve, hash in tests.items():
algo = ECAlgorithm(hash)

with open(key_path(f"jwk_ec_pub_{curve}.json")) as keyfile:
Expand Down
10 changes: 0 additions & 10 deletions tests/test_api_jwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def test_should_load_key_from_jwk_data_json_string(self):

@crypto_required
def test_should_load_key_without_alg_from_dict(self):

with open(key_path("jwk_rsa_pub.json")) as keyfile:
key_data = json.loads(keyfile.read())

Expand All @@ -69,7 +68,6 @@ def test_should_load_key_without_alg_from_dict(self):

@crypto_required
def test_should_load_key_from_dict_with_algorithm(self):

with open(key_path("jwk_rsa_pub.json")) as keyfile:
key_data = json.loads(keyfile.read())

Expand All @@ -81,7 +79,6 @@ def test_should_load_key_from_dict_with_algorithm(self):

@crypto_required
def test_should_load_key_ec_p256_from_dict(self):

with open(key_path("jwk_ec_pub_P-256.json")) as keyfile:
key_data = json.loads(keyfile.read())

Expand All @@ -93,7 +90,6 @@ def test_should_load_key_ec_p256_from_dict(self):

@crypto_required
def test_should_load_key_ec_p384_from_dict(self):

with open(key_path("jwk_ec_pub_P-384.json")) as keyfile:
key_data = json.loads(keyfile.read())

Expand All @@ -105,7 +101,6 @@ def test_should_load_key_ec_p384_from_dict(self):

@crypto_required
def test_should_load_key_ec_p521_from_dict(self):

with open(key_path("jwk_ec_pub_P-521.json")) as keyfile:
key_data = json.loads(keyfile.read())

Expand All @@ -117,7 +112,6 @@ def test_should_load_key_ec_p521_from_dict(self):

@crypto_required
def test_should_load_key_ec_secp256k1_from_dict(self):

with open(key_path("jwk_ec_pub_secp256k1.json")) as keyfile:
key_data = json.loads(keyfile.read())

Expand All @@ -129,7 +123,6 @@ def test_should_load_key_ec_secp256k1_from_dict(self):

@crypto_required
def test_should_load_key_hmac_from_dict(self):

with open(key_path("jwk_hmac.json")) as keyfile:
key_data = json.loads(keyfile.read())

Expand All @@ -141,7 +134,6 @@ def test_should_load_key_hmac_from_dict(self):

@crypto_required
def test_should_load_key_hmac_without_alg_from_dict(self):

with open(key_path("jwk_hmac.json")) as keyfile:
key_data = json.loads(keyfile.read())

Expand All @@ -154,7 +146,6 @@ def test_should_load_key_hmac_without_alg_from_dict(self):

@crypto_required
def test_should_load_key_okp_without_alg_from_dict(self):

with open(key_path("jwk_okp_pub_Ed25519.json")) as keyfile:
key_data = json.loads(keyfile.read())

Expand All @@ -165,7 +156,6 @@ def test_should_load_key_okp_without_alg_from_dict(self):

@crypto_required
def test_from_dict_should_throw_exception_if_arg_is_invalid(self):

with open(key_path("jwk_rsa_pub.json")) as keyfile:
valid_rsa_pub = json.loads(keyfile.read())
with open(key_path("jwk_ec_pub_P-256.json")) as keyfile:
Expand Down
1 change: 0 additions & 1 deletion tests/test_api_jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ def test_decode_with_non_mapping_header_throws_exception(self, jws):
assert str(exception) == "Invalid header string: must be a json object"

def test_encode_algorithm_param_should_be_case_sensitive(self, jws, payload):

jws.encode(payload, "secret", algorithm="HS256")

with pytest.raises(NotImplementedError) as context:
Expand Down
1 change: 0 additions & 1 deletion tests/test_api_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ def test_decode_with_invalid_aud_list_member_throws_exception(self, jwt):
assert str(exception) == "Invalid claim format in token"

def test_encode_bad_type(self, jwt):

types = ["string", tuple(), list(), 42, set()]

for t in types:
Expand Down

0 comments on commit 9695f4c

Please sign in to comment.