feat(work): add signed task progress and durable status cards
This commit is contained in:
@@ -16,6 +16,40 @@ async def upload(env,turn='task-durable',text='synthetic-private-result'):
|
||||
return await env['client'].post(path,json=wire(env,path,task_id=turn,result=text))
|
||||
|
||||
|
||||
async def test_execution_status_order_replay_terminal_and_delivery_are_separate(env):
|
||||
task(env)
|
||||
path='/work/v2/tasks/progress'
|
||||
async def report(state,sequence,turn='task-durable'):
|
||||
return await env['client'].post(path,json=wire(env,path,task_id=turn,
|
||||
execution_state=state,status_sequence=sequence))
|
||||
assert (await report('running',1)).json()['execution_state']=='running'
|
||||
waiting=await report('waiting_for_approval',2)
|
||||
assert waiting.json()['status_sequence']==2
|
||||
assert (await report('running',1)).json()['execution_state']=='waiting_for_approval'
|
||||
assert (await report('waiting_for_approval',2)).status_code==200
|
||||
assert (await report('running',2)).status_code==409
|
||||
completed=await report('completed',3)
|
||||
assert completed.json()['execution_state']=='completed'
|
||||
assert not completed.json()['result_received']
|
||||
assert (await report('running',4)).status_code==409
|
||||
await upload(env)
|
||||
assert (await report('completed',3)).json()['result_received']
|
||||
|
||||
|
||||
async def test_execution_state_auth_binding_and_parameter_validation(env):
|
||||
task(env)
|
||||
path='/work/v2/tasks/progress'
|
||||
missing=await env['client'].post(path,json=wire(env,path,task_id='task-durable',execution_state='running'))
|
||||
assert missing.status_code==422
|
||||
task(env,'foreign-task','ou_b','b'*32)
|
||||
foreign=await env['client'].post(path,json=wire(env,path,task_id='foreign-task',execution_state='running',status_sequence=1))
|
||||
assert foreign.status_code==403
|
||||
env['store'].unbind('ou_a')
|
||||
revoked=await env['client'].post(path,json=wire(env,path,task_id='task-durable',execution_state='running',status_sequence=1))
|
||||
assert revoked.status_code==403
|
||||
assert not env['store'].db.execute('SELECT * FROM work_execution_state_v3').fetchall()
|
||||
|
||||
|
||||
async def test_result_is_encrypted_durable_and_delivered_once_after_worker_loss(env):
|
||||
task(env)
|
||||
api=env['app'].state.deliveries
|
||||
|
||||
Reference in New Issue
Block a user