Implement Lab 2 grade 4 messenger service
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-10-22 23:58:55 +03:00
parent 65003b6119
commit 191e88136c
24 changed files with 1428 additions and 112 deletions
+14
View File
@@ -171,6 +171,20 @@ class Client:
self.call('GET','/health/live',schema='Health')
self.call('GET','/health/ready',schema='Health')
alice, bob, eve = (self.user(label) for label in ('alice','bob','eve'))
if LAB >= 2:
# Grade-4 runs with a 10-second TTL. Creating and authenticating the
# other users can outlive Alice's initial session before chat creation.
registration = alice['registration']
credential = base64.b64encode(
(registration['username'] + ':' + registration['password']).encode()
).decode()
session = self.call(
'POST', '/api/v1/auth/sessions', 201,
headers={'Authorization':'Basic ' + credential}, schema='Session'
)['json']
check(session['user'] == alice['user'], 'session user mismatch')
check(timestamp(session['expires_at']) > dt.datetime.now(dt.timezone.utc), 'session already expired')
alice['token'] = session['token']
chat = self.call('POST','/api/v1/chats',201,actor=alice,body={'title':'Контрактный тест','member_ids':[alice['id'],bob['id']]},schema='Chat')['json']
check(set(chat['member_ids'])=={alice['id'],bob['id']},'chat member mismatch')
return alice,bob,eve,chat