test: the test client starts the sign-in count again when the suite reaches the API's limit
All checks were successful
Build and deploy / Validate source (push) Successful in 7s
Build and deploy / Integration suite on a real stack (push) Successful in 6m37s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m14s

CI run 315 failed in label_test with the API's own 429 on
/operator/login: the whole suite signs in from one address and crossed
the 60 sign-ins per 15 min of app/core/auth.py. A test that did not ask
for the limit now clears login_attempts once and signs in again; tests
that expect the 429 still get it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-16 16:31:14 -03:00
parent 5cf8cd1d54
commit 5ca4872e79

View File

@@ -57,6 +57,7 @@ class Client:
self.operator_client=Client()
self.operator_client.call('/operator/login',{'email':os.environ.get('OPERATOR_EMAIL','operator@example.test'),'password':os.environ.get('OPERATOR_PASSWORD','local-operator-only')})
return self.operator_client.call(path,body,expected=expected,method=method)
reset=False
for attempt in range(20):
request=Request(BASE+'/api'+path,data=None if body is None else json.dumps(body).encode(),
headers=headers,method=method)
@@ -71,6 +72,14 @@ class Client:
# an HTML page, not the API's JSON: a fast suite waits for it.
if exc.code==429 and text.lstrip().startswith('<html') and attempt<19:
time.sleep(1);continue
# The API allows 60 sign-ins per address in 15 min (app/core/auth.py
# throttle), and the whole suite signs in from one address: a test
# that did not ask for the limit starts the count again.
if exc.code==429 and path=='/operator/login' and not reset:
from app.core import db
with db.connect() as c:
c.execute('DELETE FROM dtf_local.login_attempts')
reset=True;continue
raise AssertionError((path,exc.code,text)) from exc
def register(client, customer, password):