|
6 | 6 | import base64
|
7 | 7 | from typing import Iterator, Optional
|
8 | 8 | from acapy_backchannel.models.conn_record import ConnRecord
|
| 9 | +from acapy_backchannel.models.did import DID |
9 | 10 | import pytest
|
10 | 11 | import hashlib
|
11 | 12 | import httpx
|
@@ -182,52 +183,53 @@ async def http_endpoint(agent: BaseAgent):
|
182 | 183 |
|
183 | 184 |
|
184 | 185 | @pytest.fixture
|
185 |
| -async def make_did(): |
| 186 | +async def make_did(backchannel): |
186 | 187 | """DID factory fixture"""
|
187 | 188 |
|
188 | 189 | async def _make_did():
|
189 |
| - return await create_did.asyncio(client=backchannel) |
| 190 | + return (await create_did.asyncio(client=backchannel)).result |
190 | 191 |
|
191 | 192 | yield _make_did
|
192 | 193 | # TODO create DID deletion method
|
193 | 194 |
|
194 | 195 |
|
| 196 | +@pytest.fixture(scope="session") |
| 197 | +async def accepted_taa(backchannel): |
| 198 | + result = (await fetch_taa.asyncio(client=backchannel)).result |
| 199 | + result = await accept_taa.asyncio( |
| 200 | + client=backchannel, |
| 201 | + json_body=TAAAccept( |
| 202 | + mechanism="on_file", |
| 203 | + text=result.taa_record.text, |
| 204 | + version=result.taa_record.version, |
| 205 | + ), |
| 206 | + ) |
| 207 | + |
| 208 | + |
195 | 209 | @pytest.fixture
|
196 |
| -async def make_endorser_did(make_did): |
| 210 | +async def make_endorser_did(make_did, backchannel, accepted_taa): |
197 | 211 | """Endorser DID factory fixture"""
|
198 | 212 |
|
199 |
| - def _make_endorser_did(): |
200 |
| - did = make_did() |
| 213 | + async def _make_endorser_did(): |
| 214 | + did: DID = await make_did() |
201 | 215 | LOGGER.info("Publishing DID through https://selfserve.indiciotech.io")
|
202 | 216 | response = httpx.post(
|
203 | 217 | url="https://selfserve.indiciotech.io/nym",
|
204 | 218 | json={
|
205 | 219 | "network": "testnet",
|
206 |
| - "did": did.result.did, |
207 |
| - "verkey": did.result.verkey, |
| 220 | + "did": did.did, |
| 221 | + "verkey": did.verkey, |
208 | 222 | },
|
209 | 223 | )
|
210 | 224 | if response.is_error:
|
211 |
| - raise response.error("Failed to publish DID:", response.text) |
212 |
| - return |
| 225 | + raise Exception("Failed to publish DID:", response.text) |
| 226 | + |
213 | 227 | LOGGER.info("DID Published")
|
| 228 | + result = await set_public_did.asyncio_detailed( |
| 229 | + client=backchannel, |
| 230 | + did=did.did, |
| 231 | + ) |
| 232 | + assert result.status_code == 200 |
214 | 233 | return did
|
215 | 234 |
|
216 | 235 | yield _make_endorser_did
|
217 |
| - |
218 |
| - |
219 |
| -@pytest.fixture(scope="session") |
220 |
| -async def accept_taa(): |
221 |
| - result = await fetch_taa.asyncio(client=issuer).result |
222 |
| - result = await accept_taa.asyncio( |
223 |
| - client=issuer, |
224 |
| - json_body=TAAAccept( |
225 |
| - mechanism="on_file", |
226 |
| - text=result.taa_record.text, |
227 |
| - version=result.taa_record.version, |
228 |
| - ), |
229 |
| - ) |
230 |
| - result = await set_public_did.asyncio( |
231 |
| - client=issuer, |
232 |
| - did=did_info.did, |
233 |
| - ).result |
|
0 commit comments