fix: reject noncanonical cursors and verify storage failover
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
"""Black-box regressions derived from the contract and teacher review comments."""
|
||||
|
||||
import base64
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import struct
|
||||
import uuid
|
||||
@@ -243,3 +245,37 @@ def test_parallel_same_key_across_replicas(scenario):
|
||||
assert len({r["headers"]["X-Instance-Id"] for r in responses}) >= 2
|
||||
history = c.call("GET", path, actor=alice, schema="MessagePage")["json"]["items"]
|
||||
assert sum(m["id"] == responses[0]["json"]["id"] for m in history) == 1
|
||||
|
||||
|
||||
def test_exact_pixel_boundary_is_accepted(scenario):
|
||||
uploaded = upload(scenario, data=image_bytes(size=(8000, 5000)))["json"]
|
||||
assert uploaded["status"] == "ready"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"version,date",
|
||||
[
|
||||
(True, "2026-01-01T00:00:00Z"),
|
||||
(1.0, "2026-01-01T00:00:00Z"),
|
||||
(1, "2026-W01-1T00:00:00Z"),
|
||||
(1, "20260101T000000Z"),
|
||||
(1, "2026-01-01 00:00:00Z"),
|
||||
(1, "2026-01-01X00:00:00Z"),
|
||||
(1, "2026-02-30T00:00:00Z"),
|
||||
(1, "2026-01-01T00:00:00.1234567Z"),
|
||||
(1, "0000-01-01T00:00:00Z"),
|
||||
(1, "2026-01-01T24:00:00Z"),
|
||||
],
|
||||
)
|
||||
def test_noncanonical_cursor_over_http(scenario, version, date):
|
||||
c, alice, _, _, chat = scenario
|
||||
for path, scope in [
|
||||
("/api/v1/chats", "chats:" + alice["id"]),
|
||||
(f"/api/v1/chats/{chat['id']}/messages", "messages:" + chat["id"]),
|
||||
]:
|
||||
cursor = (
|
||||
base64.urlsafe_b64encode(json.dumps([version, scope, date, str(uuid.uuid4())]).encode())
|
||||
.decode()
|
||||
.rstrip("=")
|
||||
)
|
||||
c.call("GET", path + "?cursor=" + cursor, 400, actor=alice)
|
||||
|
||||
Reference in New Issue
Block a user