Retain old JWT paths for LTS tests (#5711)

This commit is contained in:
Eddy Ashton 2023-10-04 18:04:05 +01:00 коммит произвёл GitHub
Родитель e73cf2f4cf
Коммит cf8b57bde7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 32 добавлений и 17 удалений

Просмотреть файл

@ -216,23 +216,38 @@ class JwtIssuer:
kid_ = kid or self.default_kid kid_ = kid or self.default_kid
primary, _ = network.find_nodes() primary, _ = network.find_nodes()
end_time = time.time() + timeout end_time = time.time() + timeout
with primary.api_versioned_client( if primary.version_after("ccf-5.0.0-rc3"):
network.consortium.get_any_active_member().local_id, with primary.api_versioned_client(
api_version=args.gov_api_version, network.consortium.get_any_active_member().local_id,
) as c: api_version=args.gov_api_version,
while time.time() < end_time: ) as c:
logs = [] while time.time() < end_time:
r = c.get("/gov/service/jwk", log_capture=logs) logs = []
assert r.status_code == 200, r r = c.get("/gov/service/jwk", log_capture=logs)
body = r.body.json() assert r.status_code == 200, r
LOG.warning(body) body = r.body.json()
keys = body["keys"] LOG.warning(body)
if kid_ in keys: keys = body["keys"]
stored_cert = keys[kid_]["certificate"] if kid_ in keys:
if self.cert_pem == stored_cert: stored_cert = keys[kid_]["certificate"]
flush_info(logs) if self.cert_pem == stored_cert:
return flush_info(logs)
time.sleep(0.1) return
time.sleep(0.1)
else:
with primary.client(
network.consortium.get_any_active_member().local_id
) as c:
while time.time() < end_time:
logs = []
r = c.get("/gov/jwt_keys/all", log_capture=logs)
assert r.status_code == 200, r
if kid_ in r.body.json():
stored_cert = r.body.json()[kid_]["cert"]
if self.cert_pem == stored_cert:
flush_info(logs)
return
time.sleep(0.1)
flush_info(logs) flush_info(logs)
raise TimeoutError( raise TimeoutError(
f"JWT public signing keys were not refreshed after {timeout}s" f"JWT public signing keys were not refreshed after {timeout}s"