去敏感提交
This commit is contained in:
@@ -12,7 +12,7 @@ from referee.interface import handle_raw
|
||||
|
||||
|
||||
def payload(request_id="e", **extra):
|
||||
return dict(arena_id="default", robot_id="2026001", request_id=request_id, **extra)
|
||||
return dict(arena_id="default", robot_id="TEAM-0001", request_id=request_id, **extra)
|
||||
|
||||
|
||||
def post(sim, path, body=None, headers=None, method="POST", target=None):
|
||||
@@ -22,7 +22,7 @@ def post(sim, path, body=None, headers=None, method="POST", target=None):
|
||||
|
||||
|
||||
def test_raw_json_format_errors():
|
||||
sim = LocalSimulator([])
|
||||
sim = LocalSimulator([], robot_id="TEAM-0001")
|
||||
cases = [
|
||||
(b'{"request_id":"a","request_id":"b"}', 400), # 重复键
|
||||
(b'{"position":{"x":1,"x":2}}', 400), # 嵌套重复键
|
||||
@@ -41,7 +41,7 @@ def test_raw_json_format_errors():
|
||||
|
||||
|
||||
def test_raw_size_and_depth_boundaries_are_inclusive():
|
||||
sim = LocalSimulator([])
|
||||
sim = LocalSimulator([], robot_id="TEAM-0001")
|
||||
headers = [("Content-Type", "application/json")]
|
||||
deep = b'{"extra":' + b'[' * 15 + b'0' + b']' * 15 + b'}' # 深度 16 合法
|
||||
body = json.dumps({**payload(), **json.loads(deep)}).encode()
|
||||
@@ -67,21 +67,21 @@ def test_raw_size_and_depth_boundaries_are_inclusive():
|
||||
("POST", "/enter", [("content-type", 'application/json;charset="utf-8"')], 200),
|
||||
])
|
||||
def test_http_boundary(method, path, headers, status):
|
||||
sim = LocalSimulator([])
|
||||
sim = LocalSimulator([], robot_id="TEAM-0001")
|
||||
raw = json.dumps(payload()).encode()
|
||||
result = handle_raw(sim, method, path, headers or [("Content-Type", "application/json")], raw)
|
||||
assert result.status == status
|
||||
|
||||
|
||||
def test_closed_simulator_raises_connection_level_error():
|
||||
sim = LocalSimulator([], clock=lambda: 9999, window_started_at=0)
|
||||
sim = LocalSimulator([], clock=lambda: 9999, window_started_at=0, robot_id="TEAM-0001")
|
||||
with pytest.raises(SimulatorClosed):
|
||||
handle_raw(sim, "POST", "/enter",
|
||||
[("Content-Type", "application/json")], json.dumps(payload()).encode())
|
||||
|
||||
|
||||
def test_on_request_callback_receives_parsed_payload():
|
||||
sim = LocalSimulator([])
|
||||
sim = LocalSimulator([], robot_id="TEAM-0001")
|
||||
seen = []
|
||||
raw = json.dumps(payload("enter-1")).encode()
|
||||
handle_raw(sim, "POST", "/enter", [("Content-Type", "application/json")], raw,
|
||||
|
||||
Reference in New Issue
Block a user