"""Verify attachment and user access controls over HTTPS.""" import sys import uuid from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "tests")) from client import Client, arguments, run def main(): args = arguments(__doc__) client = Client(args.base_url, args.ca_file) alice, bob, eve, chat = client.bootstrap() attachment, _ = client.attachment(alice, chat) attachment = client.wait_ready(alice, attachment) base = "/api/v1/attachments/" + attachment["id"] for suffix in ("", "/content"): client.call("GET", base + suffix, 404, actor=eve, headers={"X-User-Id": alice["id"]}) other = client.call("POST", "/api/v1/chats", 201, actor=bob, body={ "title": "Separate chat", "member_ids": [bob["id"]], }, schema="Chat")["json"] client.call("POST", f"/api/v1/chats/{other['id']}/messages", 404, actor=bob, body={ "text": "", "attachment_ids": [attachment["id"]], }, headers={"Idempotency-Key": uuid.uuid4().hex}) client.call("GET", "/api/v1/users/me", 401, headers={"X-User-Id": alice["id"]}) client.call("DELETE", "/api/v1/auth/sessions/current", 204, actor=alice) client.call("GET", "/api/v1/users/me", 401, actor=alice) print("PASS: private attachment metadata/content, cross-chat reference, Bearer precedence and logout") if __name__ == "__main__": run(main)