test(api): gated-project member-read positive path; guard config_json parse

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ben Stull
2026-06-03 23:44:51 -07:00
parent 07e003e5fc
commit e8ce3cd228
2 changed files with 23 additions and 1 deletions
+19
View File
@@ -76,3 +76,22 @@ def test_projects_id_unknown_returns_404_for_anon(app_with_fake_gitea):
app, _ = app_with_fake_gitea
with TestClient(app) as client:
assert client.get("/api/projects/nope").status_code == 404
def test_gated_project_visible_and_readable_to_member(app_with_fake_gitea):
from app import db
app, _ = app_with_fake_gitea
with TestClient(app) as client:
_add_project("teamx", "Team X", "gated")
provision_user_row(user_id=5, login="mia", role="contributor")
db.conn().execute(
"INSERT INTO project_members (project_id, user_id, role) VALUES ('teamx', 5, 'project_viewer')"
)
sign_in_as(client, user_id=5, gitea_login="mia", display_name="Mia", role="contributor")
# member sees the gated project in the deployment directory
ids = {p["id"] for p in client.get("/api/deployment").json()["projects"]}
assert "teamx" in ids
# member can read it directly
r = client.get("/api/projects/teamx")
assert r.status_code == 200
assert r.json()["id"] == "teamx"