fix(api): pattern-constrain humiliations id; broaden canon log boundary tests
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import copy
|
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@@ -56,3 +55,16 @@ def test_empty_optional_arrays_are_allowed():
|
|||||||
doc["active_quests"] = []
|
doc["active_quests"] = []
|
||||||
doc["humiliations"] = []
|
doc["humiliations"] = []
|
||||||
assert validate_canon_log(doc) == []
|
assert validate_canon_log(doc) == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_root_level_stray_field_is_rejected():
|
||||||
|
# §2/§7: stats/HP/inventory must never enter the log — additionalProperties:false at root.
|
||||||
|
doc = _valid()
|
||||||
|
doc["hp"] = 10
|
||||||
|
assert validate_canon_log(doc) != []
|
||||||
|
|
||||||
|
|
||||||
|
def test_negative_turn_is_rejected():
|
||||||
|
doc = _valid()
|
||||||
|
doc["humiliations"][0]["turn"] = -1
|
||||||
|
assert validate_canon_log(doc) != []
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": ["id", "text", "weight", "turn"],
|
"required": ["id", "text", "weight", "turn"],
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": { "type": "string", "minLength": 1 },
|
"id": { "type": "string", "minLength": 1, "pattern": "^[a-z0-9_]+$" },
|
||||||
"text": { "type": "string", "minLength": 1 },
|
"text": { "type": "string", "minLength": 1 },
|
||||||
"weight": { "type": "integer", "minimum": 1, "maximum": 10 },
|
"weight": { "type": "integer", "minimum": 1, "maximum": 10 },
|
||||||
"turn": { "type": "integer", "minimum": 0 }
|
"turn": { "type": "integer", "minimum": 0 }
|
||||||
|
|||||||
Reference in New Issue
Block a user