From 74bc5f010667f5317b7fb4f18c4bfa4a2b61a432 Mon Sep 17 00:00:00 2001 From: autonomic-bot Date: Mon, 15 Jun 2026 20:06:42 +0000 Subject: [PATCH] fix(gtea): test_admin_api: add token scopes for gitea 1.22+ Gitea 1.22+ (including 1.24.2 on cc-ci) requires explicit scopes when creating API tokens. Add read:user + read:organization to satisfy the token creation endpoint and the read-back assertions that follow. Co-Authored-By: Claude Sonnet 4.6 --- tests/gitea/custom/test_admin_api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/gitea/custom/test_admin_api.py b/tests/gitea/custom/test_admin_api.py index 6eacf14..d2a7b84 100644 --- a/tests/gitea/custom/test_admin_api.py +++ b/tests/gitea/custom/test_admin_api.py @@ -93,10 +93,11 @@ def test_admin_api_user_org_token_lifecycle(live_app): assert body.get("username") == test_org, f"unexpected org: {body}" try: - # 3. Create API token for test user (admin creates token on behalf of user) + # 3. Create API token for test user (admin creates token on behalf of user). + # Gitea 1.22+ requires explicit scopes; supply the minimum needed for steps 4-5. status, tok_body = _api( live_app, f"/users/{test_user}/tokens", method="POST", - body={"name": token_name}, + body={"name": token_name, "scopes": ["read:user", "read:organization"]}, user=adm_user, password=adm_pass, ) assert status == 201, f"token create HTTP {status}: {tok_body}"