Files
mtusi2026lab5-fork/student_tests/broker-payload.py
T
2026-11-16 20:30:12 +03:00

25 lines
962 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""В Stream нет filename/URL/секретов — только id/version/attempt."""
import json, sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from tests.client import Client, check
from student_tests.common import upload, wait_status, docker, ok, fail
def main():
c = Client()
a, b, e, ch = c.bootstrap()
content = Path('tests/fixtures/sample.png').read_bytes()
upload(c, a, ch, content)
raw = docker('exec', '-T', 'redis', 'redis-cli', '--raw', 'XRANGE', 'attachment.jobs', '-', '+')
ok('stream sample:\n' + raw)
lower = raw.lower()
for bad in ('filename', 'sample.png', 'staging/', 'final/', 'http', 'secret'):
check(bad not in lower, 'broker payload contains forbidden token: %s' % bad)
ok('broker payload has only ids/version/attempt')
if __name__ == '__main__':
try:
main()
except Exception as exc:
fail(str(exc))