Created At: 2026-11-18T08:43:44Z Completed At: 2026-11-18T08:43:51Z Command exited with code 1. Command output: ============================= test session starts ============================== platform linux -- Python 3.12.3, pytest-9.2.0, pluggy-1.7.0 -- /root/telegram-saas/.venv/bin/python3 cachedir: .pytest_cache rootdir: /root/telegram-saas configfile: pyproject.toml plugins: anyio-4.16.0, asyncio-1.5.0 asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=function, asyncio_default_test_loop_scope=function collecting ... collected 9 items tests/unit/test_billing_gateways.py::test_razorpay_payment_signature_verification PASSED [ 11%] tests/unit/test_billing_gateways.py::test_razorpay_webhook_signature_verification PASSED [ 22%] tests/unit/test_billing_gateways.py::test_stripe_webhook_signature_verification PASSED [ 33%] tests/unit/test_billing_gateways.py::test_gateway_factory_resolution PASSED [ 44%] tests/unit/test_wallet_and_ledger.py::test_wallet_credit_debit_and_immutable_checksum PASSED [ 55%] tests/unit/test_coupons_and_entitlements.py::test_coupon_validation_and_discounts PASSED [ 66%] tests/unit/test_coupons_and_entitlements.py::test_entitlement_enforcement_and_feature_gates PASSED [ 77%] tests/integration/test_billing_checkout_and_lifecycle.py::test_full_billing_lifecycle_and_security FAILED [ 88%] tests/integration/test_billing_webhooks.py::test_razorpay_and_stripe_webhooks_and_deduplication PASSED [100%] =================================== FAILURES =================================== ___________________ test_full_billing_lifecycle_and_security ___________________ async_client = db_session = @pytest.mark.asyncio async def test_full_billing_lifecycle_and_security(async_client: AsyncClient, db_session: AsyncSession): settings = get_settings() # 1. Register new user email = f"billing_user_{uuid.uuid4().hex[:6]}@example.com" reg_resp = await async_client.post( "/api/v1/auth/register", json={"email": email, "password": "Password123!", "full_name": "Billing Admin"}, ) assert reg_resp.status_code == 201 token = reg_resp.json()["data"]["access_token"] headers = {"Authorization": f"Bearer {token}"} # Create Tenant for user slug = f"billing-tenant-{uuid.uuid4().hex[:6]}" create_t_resp = await async_client.post( "/api/v1/tenants", headers=headers, json={"name": "Billing Tenant Corp", "slug": slug}, ) assert create_t_resp.status_code == 201 tenant_id = create_t_resp.json()["data"]["id"] headers["X-Tenant-ID"] = tenant_id # 2. List available plans plans_resp = await async_client.get("/api/v1/billing/plans") assert plans_resp.status_code == 200 plans = plans_resp.json()["data"] assert len(plans) >= 4 plan_ids = [p["id"] for p in plans] assert "free" in plan_ids assert "starter" in plan_ids assert "pro" in plan_ids assert "enterprise" in plan_ids # 3. Verify initial subscription is Free sub_resp = await async_client.get("/api/v1/billing/subscription", headers=headers) assert sub_resp.status_code == 200 assert sub_resp.json()["data"]["plan_id"] == "free" # 4. Create coupon for discount verification b_service = BillingService(db_session) coupon_code = f"LAUNCH_{uuid.uuid4().hex[:4].upper()}" coupon = Coupon( id=uuid.uuid4(), code=coupon_code, discount_type="fixed_amount", discount_value=50000, # ₹500 min_order_amount=50000, is_active=True, ) await b_service.coupons.repo.create_coupon(coupon) # 5. Create checkout order for Starter plan with coupon checkout_resp = await async_client.post( "/api/v1/billing/checkout", headers=headers, json={ "plan_id": "starter", "provider": "razorpay", "coupon_code": coupon_code, }, ) assert checkout_resp.status_code == 201 order_data = checkout_resp.json()["data"] order_id = order_data["order_id"] # Starter is ₹999 - ₹500 coupon = ₹499 (49900 paise) assert order_data["amount"] == 49900 assert order_data["status"] == "created" gateway_order_id = order_data["gateway_order_id"] assert gateway_order_id is not None # 6. Server-Side Verification Security Check: Tampered/Fake signature must fail fake_verify_resp = await async_client.post( "/api/v1/billing/checkout/verify", headers=headers, json={ "order_id": order_id, "payment_id": "pay_fake_attacker_123", "signature": "forged_invalid_signature_hex", "provider": "razorpay", }, ) assert fake_verify_resp.status_code == 400 > assert "Cryptographic payment signature verification failed" in fake_verify_resp.json()["detail"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E KeyError: 'detail' tests/integration/test_billing_checkout_and_lifecycle.py:99: KeyError ----------------------------- Captured stdout call ----------------------------- 2026-11-18 08:43:50 [info ] dispatching_domain_event event_id=b5af76c0-efe6-4d83-a8e6-994dc09e3e16 event_type=UserRegisteredEvent handlers_count=0 2026-11-18 08:43:50 [info ] dispatching_domain_event event_id=0c00a6af-f99e-4314-a627-e215e7079b5e event_type=TenantCreatedEvent handlers_count=0 2026-11-18 08:43:50 [warning ] payment_signature_verification_failed order_id=0fca382c-aa9c-422f-9ab9-22ad4b7850ce payment_id=pay_fake_attacker_123 2026-11-18 08:43:50 [warning ] app_exception_handled error_code=PAYMENT_ERROR message='Cryptographic payment signature verification failed' method=POST path=/api/v1/billing/checkout/verify =========================== short test summary info ============================ FAILED tests/integration/test_billing_checkout_and_lifecycle.py::test_full_billing_lifecycle_and_security ========================= 1 failed, 8 passed in 0.94s ==========================