From ccd34da1b3ff4e3d282d821c50e5bf3310358432 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Tue, 13 Jul 2021 22:11:07 -0400 Subject: [PATCH] fix: minor fixes for endorser and taa fixtures Signed-off-by: Daniel Bluhm --- int/tests/conftest.py | 54 ++++++++++++++++++++------------------- int/tests/test_schemas.py | 3 ++- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/int/tests/conftest.py b/int/tests/conftest.py index 13ba9f3c..433213ff 100644 --- a/int/tests/conftest.py +++ b/int/tests/conftest.py @@ -6,6 +6,7 @@ import base64 from typing import Iterator, Optional from acapy_backchannel.models.conn_record import ConnRecord +from acapy_backchannel.models.did import DID import pytest import hashlib import httpx @@ -182,52 +183,53 @@ async def http_endpoint(agent: BaseAgent): @pytest.fixture -async def make_did(): +async def make_did(backchannel): """DID factory fixture""" async def _make_did(): - return await create_did.asyncio(client=backchannel) + return (await create_did.asyncio(client=backchannel)).result yield _make_did # TODO create DID deletion method +@pytest.fixture(scope="session") +async def accepted_taa(backchannel): + result = (await fetch_taa.asyncio(client=backchannel)).result + result = await accept_taa.asyncio( + client=backchannel, + json_body=TAAAccept( + mechanism="on_file", + text=result.taa_record.text, + version=result.taa_record.version, + ), + ) + + @pytest.fixture -async def make_endorser_did(make_did): +async def make_endorser_did(make_did, backchannel, accepted_taa): """Endorser DID factory fixture""" - def _make_endorser_did(): - did = make_did() + async def _make_endorser_did(): + did: DID = await make_did() LOGGER.info("Publishing DID through https://selfserve.indiciotech.io") response = httpx.post( url="https://selfserve.indiciotech.io/nym", json={ "network": "testnet", - "did": did.result.did, - "verkey": did.result.verkey, + "did": did.did, + "verkey": did.verkey, }, ) if response.is_error: - raise response.error("Failed to publish DID:", response.text) - return + raise Exception("Failed to publish DID:", response.text) + LOGGER.info("DID Published") + result = await set_public_did.asyncio_detailed( + client=backchannel, + did=did.did, + ) + assert result.status_code == 200 return did yield _make_endorser_did - - -@pytest.fixture(scope="session") -async def accept_taa(): - result = await fetch_taa.asyncio(client=issuer).result - result = await accept_taa.asyncio( - client=issuer, - json_body=TAAAccept( - mechanism="on_file", - text=result.taa_record.text, - version=result.taa_record.version, - ), - ) - result = await set_public_did.asyncio( - client=issuer, - did=did_info.did, - ).result diff --git a/int/tests/test_schemas.py b/int/tests/test_schemas.py index 0aba044e..b2548a24 100644 --- a/int/tests/test_schemas.py +++ b/int/tests/test_schemas.py @@ -5,8 +5,9 @@ @pytest.mark.asyncio -async def test_send_schema(connection): +async def test_send_schema(connection, make_endorser_did): """Send a schema and verify message type""" + await make_endorser_did() try: schema = await connection.send_and_await_reply_async( {