fix(пополнение): тестовая пара ключей и приёмочный список учёток

Тестовый режим берёт ROBOKASSA_TEST_PASS1/2, боевые не использует;
TOPUP_WHITELIST открывает кнопку и создание только названным учёткам,
включая владельца, — общий приём остаётся выключенным до чека.
Receipt проверен на проводном виде, уведомление и ack защищены от
пустого тела. План дополнен шагами приёмки.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
anor
2026-11-20 23:11:01 +10:00
co-authored by Claude Code
parent 3db3b454d6
commit d5b2d42112
5 changed files with 68 additions and 11 deletions
+16
View File
@@ -42,6 +42,8 @@ def env(tmp_path, monkeypatch):
monkeypatch.setenv("ROBOKASSA_LOGIN", "shop")
monkeypatch.setenv("ROBOKASSA_PASS1", "test-pass-one")
monkeypatch.setenv("ROBOKASSA_PASS2", P2)
monkeypatch.setenv("ROBOKASSA_TEST_PASS1", "test-pass-one")
monkeypatch.setenv("ROBOKASSA_TEST_PASS2", P2)
monkeypatch.setenv("ROBOKASSA_TEST", "1")
monkeypatch.setenv("ROBOKASSA_HASH", "sha256")
# Stand in test mode: its order numbers must not reach the live range (OpStateExt code 4).
@@ -386,3 +388,17 @@ def test_payment_result_page_has_all_states(env):
assert text in r.text, text
for word in ("robokassa", "webhook"):
assert word not in r.text.lower()
def test_whitelist_trial_opens_only_named_user(env, monkeypatch):
"""Приёмочный платёж: глобальный флаг 0, но именованная учётка видит кнопку и платит."""
import topup
db, auth, main, client, robo = env
monkeypatch.setenv("TOPUP_ENABLED", "0")
monkeypatch.setenv("TOPUP_WHITELIST", USER)
assert topup.person_block(USER)["enabled"] is True
assert topup.person_block(OTHER) is None
r = client.post("/api/topups", headers=_h(auth), json={"amount": "1000"})
assert r.status_code == 200
r2 = client.post("/api/topups", headers=_h(auth, OTHER), json={"amount": "1000"})
assert r2.status_code == 503