fix: explicitly recreate deleted task captures
This commit is contained in:
1 parent
bd54b5f06a
commit
e27c023d66
7 files changed
+138
-6
No files matched your search
@@ -6,6 +6,7 @@ import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import threading
|
||||
import uuid
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
|
||||
binary=str(Path(sys.argv[1]).resolve())
|
||||
@@ -23,6 +24,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||
item=json.loads(body)
|
||||
captures.append(item.copy())
|
||||
if item.get('wiki_prefix')=='/rejected':self.reply({'error':'invalid'},422);return
|
||||
if item.get('wiki_prefix')=='/deleted' and not item.get('replaces_deleted'):self.reply({'error':'deleted'},410);return
|
||||
if item.get('replaces_deleted') and item['request_id']!=str(uuid.uuid5(uuid.NAMESPACE_URL,'pages:task-recreate:'+item['replaces_deleted'])):self.send_error(422);return
|
||||
if item.get('wiki_body') != 'Message-ID: <smoke@example.invalid>\n\nPRIVATE BODY':self.send_error(422);return
|
||||
item.pop('wiki_body');self.reply({'item':item,'page_path':'/private/mail/synthetic'})
|
||||
else:self.send_error(404)
|
||||
@@ -53,6 +56,10 @@ try:
|
||||
captured=run('task','from-mail','--wiki-prefix','/private/mail',stdin=mail)
|
||||
if len(captures)!=2 or captures[0]['request_id']!=captures[1]['request_id'] or captures[1]['wiki_prefix']!='/private/mail':raise AssertionError('Retained draft was not overwritten under the same request ID')
|
||||
if 'Mail task' not in captured or 'PRIVATE BODY' in captured:raise AssertionError('Mail privacy')
|
||||
run('task','from-mail','--wiki-prefix','/deleted',stdin=mail,success=False)
|
||||
deleted_id=captures[-1]['request_id']
|
||||
restored=json.loads(run('task','retry',deleted_id,'--recreate-deleted'))['item']
|
||||
if restored['request_id']!=str(uuid.uuid5(uuid.NAMESPACE_URL,'pages:task-recreate:'+deleted_id)) or restored['replaces_deleted']!=deleted_id:raise AssertionError('Recreation identity')
|
||||
contact=run('contacts','query','--neomutt','--','--name')
|
||||
if 'person@example.invalid\tSynthetic Person\tTest' not in contact:raise AssertionError('NeoMutt query')
|
||||
run('shell',stdin='pwd\nexit\n')
|
||||
@@ -62,5 +69,5 @@ try:
|
||||
profile.chmod(0o644);run('task','list',success=False);profile.chmod(0o600)
|
||||
run('logout')
|
||||
if not seen:raise AssertionError('No HTTP request')
|
||||
print('Packaged CLI: configure/login/task-list/mail-capture/draft-overwrite/neomutt-query/shell/permissions/logout passed')
|
||||
print('Packaged CLI: configure/login/task-list/mail-capture/draft-overwrite/deleted-recreation/neomutt-query/shell/permissions/logout passed')
|
||||
finally:server.shutdown();server.server_close();thread.join()
|
||||
Reference in new issue
Block a user