Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: minor fixes for endorser and taa fixtures #4

Merged
merged 1 commit into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 28 additions & 26 deletions int/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
3 changes: 2 additions & 1 deletion int/tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down