ЛР6: наблюдаемость, SLO и диагностика отказов
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
from client import Client, check, run
|
||||
from pathlib import Path
|
||||
from urllib.parse import quote
|
||||
|
||||
|
||||
def main():
|
||||
c = Client(base_url="http://127.0.0.1:18085", timeout=30)
|
||||
a, b, e, chat = c.bootstrap()
|
||||
body = Path("tests/fixtures/sample.png").read_bytes()
|
||||
path = "/api/v1/chats/" + chat["id"] + "/attachments?filename="
|
||||
for name in ["a" * 255, "\U0001f600" * 255]:
|
||||
attachment = c.call(
|
||||
"POST",
|
||||
path + quote(name),
|
||||
202,
|
||||
actor=a,
|
||||
raw=body,
|
||||
headers={"Content-Type": "image/png"},
|
||||
schema="Attachment",
|
||||
)["json"]
|
||||
check(attachment["filename"] == name, "filename changed")
|
||||
c.wait_ready(a, attachment)
|
||||
result = c.call("GET", "/api/v1/attachments/" + attachment["id"] + "/content", actor=b)
|
||||
check(result["bytes"] == body, "Unicode filename download failed")
|
||||
c.call(
|
||||
"POST",
|
||||
path + quote("\U0001f600" * 256),
|
||||
400,
|
||||
actor=a,
|
||||
raw=body,
|
||||
headers={"Content-Type": "image/png"},
|
||||
)
|
||||
print(
|
||||
"PASS filename code-point limits: 255 ASCII and 255 emoji -> 202 and download 200; 256 emoji -> 400; long Content-Disposition accepted by LB"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run(main)
|
||||
Reference in New Issue
Block a user