fix(gtea): test_admin_api: add token scopes for gitea 1.22+
Some checks failed
continuous-integration/drone/push Build is failing

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 <noreply@anthropic.com>
This commit is contained in:
autonomic-bot
2026-06-15 20:06:42 +00:00
parent 3cc8338a78
commit 74bc5f0106

View File

@ -93,10 +93,11 @@ def test_admin_api_user_org_token_lifecycle(live_app):
assert body.get("username") == test_org, f"unexpected org: {body}" assert body.get("username") == test_org, f"unexpected org: {body}"
try: 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( status, tok_body = _api(
live_app, f"/users/{test_user}/tokens", method="POST", 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, user=adm_user, password=adm_pass,
) )
assert status == 201, f"token create HTTP {status}: {tok_body}" assert status == 201, f"token create HTTP {status}: {tok_body}"