import pytest
from app.tests.conftest import headers
@pytest.mark.asyncio
async def test_callback_replay(client):
    await client.post("/api/v1/tenant-bundles",headers=headers(),json={"bundle_code":"payment.byo_psp.basic","is_active":True})
    connection=(await client.post("/api/v1/psp-connections",headers=headers(),json={"provider_code":"mock"})).json()
    req=(await client.post("/api/v1/payment-requests",headers={**headers(),"Idempotency-Key":"cb"},json={"amount_minor":25})).json()
    body={"payment_request_id":req["id"],"provider_transaction_id":"trx-1","normalized_status":"paid","signature":"mock-valid"}
    path=f"/api/v1/callbacks/mock/{connection['id']}"
    assert (await client.post(path,headers=headers(),json=body)).json()["status"]=="processed"
    assert (await client.post(path,headers=headers(),json=body)).json()["status"]=="duplicate"
