Skip to content

Commit 013d278

Browse files
committed
rename accept_invalid_keys to ignore_invalid_keys
1 parent 53a3565 commit 013d278

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/cryptojwt/key_bundle.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def __init__(
162162
keytype="RSA",
163163
keyusage=None,
164164
kid="",
165-
accept_invalid_keys=True,
165+
ignore_invalid_keys=True,
166166
httpc=None,
167167
httpc_params=None,
168168
):
@@ -182,7 +182,7 @@ def __init__(
182182
presently 'rsa' and 'ec' are supported.
183183
:param keyusage: What the key loaded from file should be used for.
184184
Only applicable for DER files
185-
:param accept_invalid_keys: Accept invalid keys
185+
:param ignore_invalid_keys: Ignore invalid keys
186186
:param httpc: A HTTP client function
187187
:param httpc_params: Additional parameters to pass to the HTTP client
188188
function
@@ -204,7 +204,7 @@ def __init__(
204204
self.last_updated = 0
205205
self.last_remote = None # HTTP Date of last remote update
206206
self.last_local = None # UNIX timestamp of last local update
207-
self.accept_invalid_keys = accept_invalid_keys
207+
self.ignore_invalid_keys = ignore_invalid_keys
208208

209209
if httpc:
210210
self.httpc = httpc
@@ -277,7 +277,7 @@ def do_keys(self, keys):
277277
elif inst["kty"].upper() in K2C:
278278
inst["kty"] = inst["kty"].upper()
279279
else:
280-
if not self.accept_invalid_keys:
280+
if not self.ignore_invalid_keys:
281281
raise UnknownKeyType(inst)
282282
LOGGER.warning("While loading keys, unknown key type: %s", inst["kty"])
283283
continue
@@ -295,17 +295,17 @@ def do_keys(self, keys):
295295
try:
296296
_key = K2C[_typ](use=_use, **inst)
297297
except KeyError:
298-
if not self.accept_invalid_keys:
298+
if not self.ignore_invalid_keys:
299299
raise UnknownKeyType(inst)
300300
_error = "UnknownKeyType: {}".format(_typ)
301301
continue
302302
except (UnsupportedECurve, UnsupportedAlgorithm) as err:
303-
if not self.accept_invalid_keys:
303+
if not self.ignore_invalid_keys:
304304
raise err
305305
_error = str(err)
306306
break
307307
except JWKException as err:
308-
if not self.accept_invalid_keys:
308+
if not self.ignore_invalid_keys:
309309
raise err
310310
LOGGER.warning("While loading keys: %s", err)
311311
_error = str(err)

tests/test_03_key_bundle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,12 +1070,12 @@ def test_ignore_errors_period():
10701070
assert res == True
10711071

10721072

1073-
def test_accept_invalid_keys():
1073+
def test_ignore_invalid_keys():
10741074
rsa_key_dict = new_rsa_key().serialize()
10751075
rsa_key_dict["kty"] = "b0rken"
10761076

1077-
kb = KeyBundle(keys={"keys": [rsa_key_dict]}, accept_invalid_keys=True)
1077+
kb = KeyBundle(keys={"keys": [rsa_key_dict]}, ignore_invalid_keys=True)
10781078
assert len(kb) == 0
10791079

10801080
with pytest.raises(UnknownKeyType):
1081-
KeyBundle(keys={"keys": [rsa_key_dict]}, accept_invalid_keys=False)
1081+
KeyBundle(keys={"keys": [rsa_key_dict]}, ignore_invalid_keys=False)

0 commit comments

Comments
 (0)