Реализована проверка версионности и требование soft\force обновлений приложения

This commit is contained in:
mi
2026-09-03 19:12:38 +03:00
parent 465a70d488
commit 44db38f6fe
37 changed files with 3057 additions and 53 deletions
@@ -17,6 +17,17 @@ def test_production_like_seed_contains_all_mandatory_settings() -> None:
assert values["otp.phone.ttl_seconds"] == "60"
assert values["otp.phone.sms_order_timeout_ms"] == "3000"
assert values["chat.message.max_length"] == "4000"
assert values["mobile_update.google_play.latest_build"] == "2"
assert values["mobile_update.google_play.minimum_build"] == "1"
assert values["mobile_update.google_play.latest_version"] == "1.0.1"
assert values["mobile_update.rustore.latest_build"] == "2"
assert values["mobile_update.rustore.store_url"] == (
"https://www.rustore.ru/catalog/app/ru.han.chat"
)
assert values["mobile_update.rustore.release_notes"] == ""
assert values["mobile_update.app_store.enabled"] == "false"
assert values["mobile_update.app_store.latest_build"] == ""
assert values["security.public_cache.max_age_seconds"] == "60"
def test_seed_rejects_invalid_typed_value(tmp_path: Path) -> None:
@@ -76,3 +87,98 @@ def test_seed_rejects_invalid_chat_message_max_length(tmp_path: Path, value: int
with pytest.raises(ValueError, match="value must be between 1 and 10000"):
load_seed(path)
def _mobile_policy_yaml(
*,
store: str = "google_play",
enabled: bool = True,
latest_build: int = 2,
minimum_build: int = 1,
store_url: str = "https://play.google.com/store/apps/details?id=ru.han.chat",
) -> str:
enabled_yaml = str(enabled).lower()
return (
"schema_version: 1\nsettings:\n"
f" mobile_update.{store}.enabled: "
f"{{type: boolean, value: {enabled_yaml}, public: true}}\n"
f" mobile_update.{store}.latest_build: "
f"{{type: integer, value: {latest_build}, public: true}}\n"
f" mobile_update.{store}.minimum_build: "
f"{{type: integer, value: {minimum_build}, public: true}}\n"
f' mobile_update.{store}.latest_version: '
'{type: string, value: "1.0.1", public: true}\n'
f' mobile_update.{store}.store_url: '
f'{{type: string, value: "{store_url}", public: true}}\n'
f' mobile_update.{store}.release_notes: '
'{type: string, value: "", public: true}\n'
)
def test_seed_rejects_inverted_mobile_build_thresholds(tmp_path: Path) -> None:
path = tmp_path / "settings.yaml"
path.write_text(
_mobile_policy_yaml(latest_build=1, minimum_build=2),
encoding="utf-8",
)
with pytest.raises(ValueError, match="minimum_build must not exceed latest_build"):
load_seed(path)
def test_seed_rejects_wrong_mobile_store_url(tmp_path: Path) -> None:
path = tmp_path / "settings.yaml"
path.write_text(
_mobile_policy_yaml(
store_url="https://play.google.com/store/apps/details?id=other.package"
),
encoding="utf-8",
)
with pytest.raises(ValueError, match="does not match the google_play application"):
load_seed(path)
def test_seed_rejects_non_https_mobile_store_url(tmp_path: Path) -> None:
path = tmp_path / "settings.yaml"
path.write_text(
_mobile_policy_yaml(
store_url="http://play.google.com/store/apps/details?id=ru.han.chat"
),
encoding="utf-8",
)
with pytest.raises(ValueError, match="absolute HTTPS URL expected"):
load_seed(path)
def test_seed_accepts_canonical_rustore_url(tmp_path: Path) -> None:
path = tmp_path / "settings.yaml"
path.write_text(
_mobile_policy_yaml(
store="rustore",
store_url="https://www.rustore.ru/catalog/app/ru.han.chat",
),
encoding="utf-8",
)
rows = load_seed(path)
assert any(
row["setting_key"] == "mobile_update.rustore.store_url"
and row["setting_value"] == "https://www.rustore.ru/catalog/app/ru.han.chat"
for row in rows
)
def test_seed_rejects_legacy_rustore_url(tmp_path: Path) -> None:
path = tmp_path / "settings.yaml"
path.write_text(
_mobile_policy_yaml(
store="rustore",
store_url="https://apps.rustore.ru/app/ru.han.chat",
),
encoding="utf-8",
)
with pytest.raises(ValueError, match="does not match the rustore application"):
load_seed(path)