forked from mtusi2026/mtusi2026lab2
21 lines
1.1 KiB
Python
21 lines
1.1 KiB
Python
import sys,base64,uuid
|
|
from pathlib import Path
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'tests'))
|
|
from client import Client,check
|
|
c=Client()
|
|
a,b,e,chat=c.bootstrap()
|
|
path='/api/v1/chats/'+chat['id']
|
|
results={'contract_extra':{}}
|
|
# Full UTF-8 password range, including a colon; malformed JSON and invalid limits.
|
|
unicode_name='utf_'+uuid.uuid4().hex[:16]
|
|
unicode_password='🔑'*120+':пароль!'
|
|
check(len(unicode_password)==128,'password fixture length')
|
|
c.call('POST','/api/v1/users',201,body={'username':unicode_name,'display_name':'UTF-8','password':unicode_password},schema='User')
|
|
credential=base64.b64encode((unicode_name+':'+unicode_password).encode()).decode()
|
|
c.call('POST','/api/v1/auth/sessions',201,headers={'Authorization':'Basic '+credential},schema='Session')
|
|
c.call('POST','/api/v1/users',400,raw=b'{',headers={'Content-Type':'application/json'})
|
|
c.call('GET',path+'/messages?limit='+('9'*100),400,actor=a)
|
|
results['contract_extra']['utf8_128_password_with_colon']=True
|
|
|
|
print('PASS: 128-codepoint UTF-8 password with colon; malformed JSON and oversized limit rejected')
|