forked from mtusi2026/mtusi2026lab2
Implement Lab 2 grade 4 messenger service
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user