fix: persist room operation cancellation across lost admission acknowledgments
This commit is contained in:
1 parent
523f6cbbf9
commit
2ad9f36f4f
3 files changed
+62
No files matched your search
@@ -31,3 +31,26 @@ def test_event_capacity_failure_persists_stop_and_reserved_terminal(tmp_path):
|
||||
assert store.events(owner['id'],rid)[-1]['event'] == 'done'
|
||||
accounts.close()
|
||||
asyncio.run(scenario())
|
||||
|
||||
|
||||
def test_cancel_key_before_admission_never_starts_and_is_owner_scoped(tmp_path):
|
||||
async def scenario():
|
||||
accounts = Accounts(str(tmp_path/'cancel.db'))
|
||||
user = accounts.create('test','Test','admin','offline-test-password')
|
||||
other = accounts.create('other','Other','user','offline-test-password')
|
||||
token, _ = accounts.issue_session(user['id'],3600,user['password_hash'])
|
||||
store = ChatStore(accounts)
|
||||
cid = store.create_conversation(user['id'])['id']
|
||||
runs = ChatRuns(accounts,store,adapter=object())
|
||||
assert await runs.cancel_operation(user['id'],cid,'uncertain-key') == {'ok':True,'run':None}
|
||||
operation = await runs.send(user['id'],cid,token,content='Hi',idempotency_key='uncertain-key')
|
||||
assert operation['run']['status'] == 'cancelled'
|
||||
assert runs.tasks == {}
|
||||
assert (await runs.send(user['id'],cid,token,content='Hi',idempotency_key='uncertain-key'))['run']['id'] == operation['run']['id']
|
||||
try:
|
||||
await runs.cancel_operation(other['id'],cid,'uncertain-key')
|
||||
assert False, 'Foreign owner cancellation was accepted'
|
||||
except KeyError:
|
||||
pass
|
||||
accounts.close()
|
||||
asyncio.run(scenario())
|
||||
Reference in new issue
Block a user