fix(work): return approval state cards directly from callbacks

This commit is contained in:
ex_tianzy
2026-11-18 10:00:55 +08:00
parent 7d2a15eaba
commit 61db139c72
11 changed files with 165 additions and 25 deletions
@@ -22,7 +22,7 @@ async def test_same_intent_cannot_get_new_card_by_changing_operation_id(pair,cho
other='new-operation-id'
action['params']['idempotency_key']=hashlib.sha256(canonical(['ou_a',other])).hexdigest()
path='/work/v2/approvals/create'
response=await e['client'].post(path,json=wire(e,path,task_id='task-approval',operation_id=other,action=action,ttl=120))
response=await e['client'].post(path,json=wire(e,path,task_id=('msg_'+'a'*64),operation_id=other,action=action,ttl=120))
assert response.status_code==409
assert e['store'].db.execute('SELECT COUNT(*) n FROM work_approvals_v3').fetchone()['n']==1
assert len(p['calls'])==(1 if choice=='allow'else 0)
@@ -51,12 +51,12 @@ async def test_changed_action_same_id_rejected_but_distinct_new_action_can_confi
action=json.loads(ledger.keyring.decrypt(row['key_id'],row['ciphertext'],ledger._aad(row)))['action']
action['body']['summary']='真正不同的合成动作'
path='/work/v2/approvals/create'
same=await e['client'].post(path,json=wire(e,path,task_id='task-approval',
same=await e['client'].post(path,json=wire(e,path,task_id=('msg_'+'a'*64),
operation_id='operation-synthetic',action=action,ttl=120))
assert same.status_code==409
other='distinct-operation'
action['params']['idempotency_key']=hashlib.sha256(canonical(['ou_a',other])).hexdigest()
distinct=await e['client'].post(path,json=wire(e,path,task_id='task-approval',
distinct=await e['client'].post(path,json=wire(e,path,task_id=('msg_'+'a'*64),
operation_id=other,action=action,ttl=120))
assert distinct.status_code==200 and distinct.json()['state']=='pending'
assert not p['calls']