fix(applications): reject boolean numeric input
This commit is contained in:
1 parent
093e0f6f73
commit
947cebc256
3 files changed
+12
No files matched your search
@@ -29,6 +29,8 @@ class ApplicationError(ValueError):
|
||||
|
||||
|
||||
def _positive_id(value: Any, label: str) -> int:
|
||||
if isinstance(value, bool):
|
||||
raise ApplicationError(f"{label} должно быть числом")
|
||||
try:
|
||||
result = int(value)
|
||||
except (TypeError, ValueError) as exc:
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
- 2026-08-25: `BelkiHTTPServer` supersedes the unbounded standard threaded server. It rejects oversized declared JSON before reading, times out a slow client after 15 seconds, and serves at most 32 concurrent connections.
|
||||
- 2026-08-25: long-lived authenticated admin refresh WebSockets now have a separate eight-connection pool, so they cannot consume all 32 request workers; additional connections receive an explicit temporary-unavailable response.
|
||||
- 2026-08-25: application validation now bounds names, attachment and feather rows, and descriptive text for both web and VK submissions. Stored attachment and review links must be HTTPS; the optional profile link is restricted to a real VK host.
|
||||
- 2026-08-25: application numeric fields explicitly reject JSON booleans, which Python would otherwise coerce to `1` or `0`.
|
||||
- 2026-08-25: admin history sorting now tolerates legacy records whose IDs were stored as strings, preserving numeric order for valid IDs instead of failing the complete history view.
|
||||
- 2026-08-25: coaching sessions now validate a real calendar date in `ДД.ММ` form before any calculation or persistence; free-form dates remain accepted after parser normalization.
|
||||
- 2026-08-25: one-line VK/web recognition now gives explicit role labels priority over position. `сопровождающий`/`наставник`/`учитель` identify the escort, while `ученик`/`котёнок`/`бельчонок`/`подопечный` identify the ward; unlabeled pairs retain the original order-based fallback.
|
||||
|
||||
@@ -36,6 +36,15 @@ class ApplicationTests(unittest.TestCase):
|
||||
"practiced_before": False, "vk_link": link,
|
||||
})
|
||||
|
||||
def test_application_rejects_boolean_character_and_feather_ids(self) -> None:
|
||||
with self.assertRaisesRegex(ApplicationError, "ID персонажа должно быть числом"):
|
||||
validate_application({"type": "kitten", "name": "Муся", "character_id": True, "attachments": [{"url": "https://img.example.test/a.jpg"}]})
|
||||
with self.assertRaisesRegex(ApplicationError, "Количество перьев должно быть числом"):
|
||||
validate_application({
|
||||
"type": "feather_donation", "name": "Муся", "character_id": 1337,
|
||||
"feathers": [{"amount": True, "color": "синее", "source": "запасы"}],
|
||||
})
|
||||
|
||||
def test_application_bounds_attachment_and_feather_fan_out(self) -> None:
|
||||
too_many_attachments = [{"url": "https://img.example.test/photo.jpg"}] * (MAX_APPLICATION_ATTACHMENTS + 1)
|
||||
with self.assertRaisesRegex(ApplicationError, "не более"):
|
||||
|
||||
Reference in new issue
Block a user