Проверить ЛР4: сборка MinIO из исходников и результаты полного прогона

This commit is contained in:
Алиса Шурман
2026-11-12 23:01:59 +03:00
parent 7fbdef3a6a
commit 59fc7b96ec
22 changed files with 368 additions and 27 deletions
+14 -1
View File
@@ -1,11 +1,13 @@
"""Black-box grade-4 checks; creates only synthetic data on the local lab."""
from concurrent.futures import ThreadPoolExecutor
import hashlib
import io
import json
from pathlib import Path
import sys
import threading
import uuid
from PIL import Image
from urllib.parse import quote
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
from client import Client, check
@@ -14,6 +16,17 @@ c = Client(timeout=45)
a,b,e,chat = c.bootstrap()
base = '/api/v1/chats/' + chat['id']
att, png = c.attachment(a, chat)
# Exercise the second supported format through both stores, not only Pillow.
jpeg_file = io.BytesIO()
Image.new('RGB', (320, 200), (20, 30, 40)).save(jpeg_file, 'JPEG')
jpeg = jpeg_file.getvalue()
jpeg_att = c.call('POST', base+'/attachments?filename=photo.jpg', 201, actor=a,
raw=jpeg, headers={'Content-Type': 'image/jpeg'}, schema='Attachment')['json']
check(jpeg_att['sha256'] == hashlib.sha256(jpeg).hexdigest(), 'JPEG checksum differs')
check(jpeg_att['size_bytes'] == len(jpeg), 'JPEG length differs')
jpeg_download = c.call('GET', '/api/v1/attachments/'+jpeg_att['id']+'/content', actor=b)
check(jpeg_download['bytes'] == jpeg, 'JPEG original differs')
check(jpeg_download['headers'].get_content_type() == 'image/jpeg', 'JPEG MIME differs')
for name in ['../x.png', 'a\\b.png', '\x00.png', '\n.png']:
c.call('POST', base+'/attachments?filename='+quote(name, safe=''), 400, actor=a,
raw=png, headers={'Content-Type':'image/png'})
@@ -43,4 +56,4 @@ c.call('POST',base+'/messages',409,actor=a,body={'text':'different'},headers={'I
# Default [] and explicit [] are equivalent.
c.call('POST',base+'/messages',201,actor=a,body={'text':'one logical message','attachment_ids':[]},
headers={'Idempotency-Key':key},schema='Message')
print('PASS: invalid files, ACL, cross-chat references, concurrent idempotency')
print('PASS: JPEG round-trip, invalid files, ACL, cross-chat references, concurrent idempotency')