Skip to content

Commit d3fa5a1

Browse files
author
Vijay Kumar Soni
committed
fixed JSON-LD regression test failure
Signed-off-by: Vijay Kumar Soni <vijaysoni@sonivijay.com>
1 parent ad718db commit d3fa5a1

File tree

2 files changed

+81
-5
lines changed

2 files changed

+81
-5
lines changed

scenarios/examples/json_ld/example.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
from acapy_controller.protocols import (
1616
didexchange,
1717
jsonld_issue_credential,
18-
jsonld_present_proof,
1918
params,
2019
)
2120
from aiohttp import ClientSession
21+
from examples.util import jsonld_present_proof_v2
2222

2323
ALICE = getenv("ALICE", "http://alice:3001")
2424
BOB = getenv("BOB", "http://bob:3001")
@@ -159,7 +159,7 @@ async def main():
159159
pause_for_input()
160160

161161
with section("Present example ED25519 credential"):
162-
alice_pres_ex, bob_pres_ex = await jsonld_present_proof(
162+
alice_pres_ex, bob_pres_ex = await jsonld_present_proof_v2(
163163
alice,
164164
bob,
165165
alice_conn.connection_id,
@@ -241,7 +241,7 @@ async def main():
241241
pause_for_input()
242242

243243
with section("Present example P256 credential"):
244-
alice_pres_ex, bob_pres_ex = await jsonld_present_proof(
244+
alice_pres_ex, bob_pres_ex = await jsonld_present_proof_v2(
245245
alice,
246246
bob,
247247
alice_conn.connection_id,
@@ -327,7 +327,7 @@ async def main():
327327
pause_for_input()
328328

329329
with section("Present ED25519 quick context credential"):
330-
alice_pres_ex, bob_pres_ex = await jsonld_present_proof(
330+
alice_pres_ex, bob_pres_ex = await jsonld_present_proof_v2(
331331
alice,
332332
bob,
333333
alice_conn.connection_id,
@@ -405,7 +405,7 @@ async def main():
405405
pause_for_input()
406406

407407
with section("Present BBS+ Credential with SD"):
408-
alice_pres_ex, bob_pres_ex = await jsonld_present_proof(
408+
alice_pres_ex, bob_pres_ex = await jsonld_present_proof_v2(
409409
alice,
410410
bob,
411411
alice_conn.connection_id,

scenarios/examples/util.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,82 @@ async def indy_present_proof_v2(
313313
return holder_pres_ex, verifier_pres_ex
314314

315315

316+
async def jsonld_present_proof_v2(
317+
holder: Controller,
318+
verifier: Controller,
319+
holder_connection_id: str,
320+
verifier_connection_id: str,
321+
*,
322+
presentation_definition: Mapping[str, Any],
323+
domain: Optional[str] = None,
324+
challenge: Optional[str] = None,
325+
comment: Optional[str] = None,
326+
):
327+
"""Present a credential using present proof v2 (DIF/JSON-LD)."""
328+
dif_options: Dict[str, Any] = {"challenge": challenge or str(uuid4())}
329+
if domain:
330+
dif_options["domain"] = domain
331+
332+
verifier_pres_ex = await verifier.post(
333+
"/present-proof-2.0/send-request",
334+
json={
335+
"auto_verify": False,
336+
"comment": comment or "Presentation request from minimal",
337+
"connection_id": verifier_connection_id,
338+
"presentation_request": {
339+
"dif": {
340+
"presentation_definition": dict(presentation_definition),
341+
"options": dif_options,
342+
}
343+
},
344+
"trace": False,
345+
},
346+
response=V20PresExRecord,
347+
)
348+
verifier_pres_ex_id = verifier_pres_ex.pres_ex_id
349+
350+
holder_pres_ex = await holder.event_with_values(
351+
topic="present_proof_v2_0",
352+
event_type=V20PresExRecord,
353+
connection_id=holder_connection_id,
354+
state="request-received",
355+
)
356+
holder_pres_ex_id = holder_pres_ex.pres_ex_id
357+
358+
await holder.post(
359+
f"/present-proof-2.0/records/{holder_pres_ex_id}/send-presentation",
360+
json={"dif": {}},
361+
response=V20PresExRecord,
362+
)
363+
364+
await verifier.event_with_values(
365+
topic="present_proof_v2_0",
366+
event_type=V20PresExRecord,
367+
pres_ex_id=verifier_pres_ex_id,
368+
state="presentation-received",
369+
)
370+
await verifier.post(
371+
f"/present-proof-2.0/records/{verifier_pres_ex_id}/verify-presentation",
372+
json={},
373+
response=V20PresExRecord,
374+
)
375+
verifier_pres_ex = await verifier.event_with_values(
376+
topic="present_proof_v2_0",
377+
event_type=V20PresExRecord,
378+
pres_ex_id=verifier_pres_ex_id,
379+
state="done",
380+
)
381+
382+
holder_pres_ex = await holder.event_with_values(
383+
topic="present_proof_v2_0",
384+
event_type=V20PresExRecord,
385+
pres_ex_id=holder_pres_ex_id,
386+
state="done",
387+
)
388+
389+
return holder_pres_ex, verifier_pres_ex
390+
391+
316392
async def anoncreds_issue_credential_v2(
317393
issuer: Controller,
318394
holder: Controller,

0 commit comments

Comments
 (0)