fix: correct "bugs" to "issues" in routing table and README references across multiple documentation files
This commit is contained in:
+39
-27
@@ -85,6 +85,15 @@ def _call(endpoint, headers):
|
||||
elif data:
|
||||
kwargs["data"] = data
|
||||
return requests.request(endpoint["method"], f"{BASE_URL}{path}", **kwargs)
|
||||
def _clear_probe_jobs():
|
||||
from devplacepy.database import refresh_snapshot
|
||||
|
||||
refresh_snapshot()
|
||||
jobs = get_table("jobs")
|
||||
for row in list(jobs.find()):
|
||||
jobs.delete(uid=row["uid"])
|
||||
|
||||
|
||||
def _redirects_to(response, target):
|
||||
return response.status_code in (
|
||||
302,
|
||||
@@ -110,38 +119,41 @@ def test_documented_minimal_role_matches_enforcement(seeded_db):
|
||||
assert len(endpoints) >= 50
|
||||
|
||||
failures = []
|
||||
for endpoint in endpoints:
|
||||
auth = endpoint["auth"]
|
||||
label = (
|
||||
f"{endpoint['method']} {endpoint['path']} ({endpoint['id']}, doc={auth})"
|
||||
)
|
||||
anon = _call(endpoint, JSON_auth_matrix)
|
||||
|
||||
if auth == "public":
|
||||
if not _is_allowed(anon):
|
||||
failures.append(
|
||||
f"{label}: public but anonymous was rejected ({anon.status_code})"
|
||||
)
|
||||
continue
|
||||
|
||||
if not _is_auth_rejected(anon):
|
||||
failures.append(
|
||||
f"{label}: requires {auth} but anonymous was NOT rejected ({anon.status_code})"
|
||||
try:
|
||||
for endpoint in endpoints:
|
||||
auth = endpoint["auth"]
|
||||
label = (
|
||||
f"{endpoint['method']} {endpoint['path']} ({endpoint['id']}, doc={auth})"
|
||||
)
|
||||
anon = _call(endpoint, JSON_auth_matrix)
|
||||
|
||||
if auth == "user" and endpoint["method"] == "GET":
|
||||
mem = _call(endpoint, member)
|
||||
if not _is_allowed(mem):
|
||||
if auth == "public":
|
||||
if not _is_allowed(anon):
|
||||
failures.append(
|
||||
f"{label}: public but anonymous was rejected ({anon.status_code})"
|
||||
)
|
||||
continue
|
||||
|
||||
if not _is_auth_rejected(anon):
|
||||
failures.append(
|
||||
f"{label}: documented user but a member was rejected ({mem.status_code})"
|
||||
f"{label}: requires {auth} but anonymous was NOT rejected ({anon.status_code})"
|
||||
)
|
||||
|
||||
if auth == "admin":
|
||||
mem = _call(endpoint, member)
|
||||
if not _is_role_rejected(mem):
|
||||
failures.append(
|
||||
f"{label}: documented admin but a non-admin member was NOT rejected ({mem.status_code})"
|
||||
)
|
||||
if auth == "user" and endpoint["method"] == "GET":
|
||||
mem = _call(endpoint, member)
|
||||
if not _is_allowed(mem):
|
||||
failures.append(
|
||||
f"{label}: documented user but a member was rejected ({mem.status_code})"
|
||||
)
|
||||
|
||||
if auth == "admin":
|
||||
mem = _call(endpoint, member)
|
||||
if not _is_role_rejected(mem):
|
||||
failures.append(
|
||||
f"{label}: documented admin but a non-admin member was NOT rejected ({mem.status_code})"
|
||||
)
|
||||
finally:
|
||||
_clear_probe_jobs()
|
||||
|
||||
assert not failures, "Auth enforcement does not match documentation:\n" + "\n".join(
|
||||
failures
|
||||
|
||||
Reference in New Issue
Block a user