Add SQLite web users, privileged account CLI and session editing claims

This commit is contained in:
Nico committed 2026-10-22 18:56:59 +02:00
1 parent 9fc5c1805c
commit 203e765992
18 files changed
+629 -60

No files matched your search

+15 -2
View File
@@ -21,9 +21,13 @@ def test_web_human_feedback_auth_scope_replay_and_resume(hypotheses,monkeypatch,
monkeypatch.setenv('OTHER_TOKEN','other_'+'x'*40)
config=APIConfig(store.workspace.root,(Project('p','wow','vcore'),Project('other','wow','vcore')),
(Client('tester','TESTER_TOKEN',('p',),tester=True),Client('capture','CAPTURE_TOKEN',('p',)),Client('other','OTHER_TOKEN',('other',),tester=True)))
client=TestClient(create_app(config));auth={'Authorization':'Bearer tester_'+'x'*40}
app=create_app(config);client=TestClient(app)
app.state.sessions.users.manage('create_user','alice','test-password')
url='/v1/test-requests';handle=case_key(*('case-A','stable-package'))
assert client.get(url).status_code==401
login=client.post('/v1/auth/login',json={'username':'alice','password':'test-password'})
assert login.status_code==200
auth={'X-CSRF-Token':login.json()['csrf']}
rows=client.get(url,headers=auth).json()
assert rows['can_answer'] and rows['requests'][0]['project_id']=='p'
answer={'request_id':request['request_id'],'analysis_revision':1,'outcome':outcome,
@@ -31,7 +35,16 @@ def test_web_human_feedback_auth_scope_replay_and_resume(hypotheses,monkeypatch,
assert client.post(url+'/'+handle,headers={'Authorization':'Bearer capture_'+'x'*40},json=answer).status_code==403
other={'Authorization':'Bearer other_'+'x'*40}
assert client.get(url,headers=other).json()['requests']==[]
assert client.post(url+'/'+handle,headers=other,json=answer).status_code==404
assert client.post(url+'/'+handle,headers=other,json=answer).status_code==403
claim={'request_id':request['request_id'],'analysis_revision':1,'action':'edit'}
assert client.post(url+'/'+handle,headers=auth,json=answer).status_code==409
assert client.post(url+'/'+handle+'/claim',headers=auth,json=claim).status_code==200
app.state.sessions.users.manage('create_user','bob','second-password')
second=TestClient(app)
info=second.post('/v1/auth/login',json={'username':'bob','password':'second-password'}).json()
second_auth={'X-CSRF-Token':info['csrf']}
assert second.post(url+'/'+handle+'/claim',headers=second_auth,json=claim).status_code==409
assert second.post(url+'/'+handle,headers=second_auth,json=answer).status_code==409
assert client.post(url+'/'+handle,headers=auth,json=answer|{'request_id':'wrong'}).status_code==409
assert client.post(url+'/'+handle,headers=auth,json=answer|{'confirmed':False}).status_code==422
response=client.post(url+'/'+handle,headers=auth,json=answer)