forked from mtusi2026/mtusi2026lab3
20 lines
974 B
Python
20 lines
974 B
Python
#!/usr/bin/env python3
|
|
"""Small defense demonstration; outputs aliases and synthetic data, no credentials."""
|
|
import json
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
|
|
from client import Client, check
|
|
|
|
c = Client()
|
|
alice, bob, _, chat = c.bootstrap()
|
|
instances = sorted({c.call('GET', '/api/v1/users/me', actor=alice, schema='User')['headers']['X-Instance-Id']
|
|
for _ in range(20)})
|
|
check(len(instances) >= 2, 'Expected >=2 replicas with the SAME session')
|
|
message = c.message(alice, chat, 'Одно сообщение через общий LB')['json']
|
|
page = c.call('GET', '/api/v1/chats/' + chat['id'] + '/messages', actor=bob, schema='MessagePage')['json']
|
|
check(message in page['items'], 'Message not visible to another member')
|
|
print(json.dumps({'same_session_served_by': instances, 'message': message,
|
|
'visible_to_second_member': True}, ensure_ascii=False, indent=2))
|