Skip to content
This repository has been archived by the owner on Sep 22, 2023. It is now read-only.

Commit

Permalink
feat:added presentation exchange flow integration test
Browse files Browse the repository at this point in the history
Signed-off-by: PeterStrob <peter@indicio.tech>
  • Loading branch information
PeterStrob committed Oct 29, 2021
1 parent cea2ef3 commit 34577b3
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Fields:
def __init__(self, record: PresExRecord, **kwargs):
super().__init__(**kwargs)
self.raw_repr = record
self.presentation_request = record.presentation_request
self.presentation_request = record.presentation_request.serialize()
self.presentation_exchange_id = record.presentation_exchange_id
self.matching_credentials = []
self.page = None
Expand Down
2 changes: 1 addition & 1 deletion int/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
ACAPY_TOOLBOX_LOG_LEVEL: DEBUG
ports:
- "3001:3001"
command: start -it http 0.0.0.0 3000 -ot http -e http://acapy_plugin_agent:3000 --admin 0.0.0.0 3001 --admin-insecure-mode --plugin acapy_plugin_toolbox --genesis-url https://raw.githubusercontent.com/Indicio-tech/indicio-network/master/genesis_files/pool_transactions_testnet_genesis --wallet-type indy --wallet-name default --wallet-key "insecure, for use in testing only" --auto-provision --auto-ping-connection --monitor-ping
command: start -it http 0.0.0.0 3000 -ot http -e http://acapy_plugin_agent:3000 --admin 0.0.0.0 3001 --admin-insecure-mode --plugin acapy_plugin_toolbox --genesis-url https://raw.githubusercontent.com/Indicio-tech/indicio-network/master/genesis_files/pool_transactions_testnet_genesis --wallet-type indy --wallet-name default --wallet-key "insecure, for use in testing only" --auto-provision --auto-ping-connection --monitor-ping --auto-store-credential

echo:
image: echo-agent
Expand Down
77 changes: 77 additions & 0 deletions int/tests/test_presentation_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
from acapy_client.models.indy_proof_request import IndyProofRequest
from acapy_client.models.indy_proof_request_requested_attributes import (
IndyProofRequestRequestedAttributes,
)
from acapy_client.models.indy_proof_request_requested_predicates import (
IndyProofRequestRequestedPredicates,
)
from acapy_client.models.v10_presentation_send_request_request import (
V10PresentationSendRequestRequest,
)
from acapy_client.types import Unset
import pytest
from typing import cast
from acapy_client import Client
from acapy_client.models.conn_record import ConnRecord
from acapy_client.api.present_proof_v10 import send_proof_request

from tests.test_holder import issue_credential, issuer_holder_connection
from tests.conftest import connection


@pytest.mark.asyncio
async def test_presentation(
backchannel: Client,
issue_credential,
issuer_holder_connection,
wait_for_message,
connection,
):
"""Test the presentation message and notification flows."""
verifier, prover = issuer_holder_connection
verifier = cast(ConnRecord, verifier)
prover = cast(ConnRecord, prover)
assert not isinstance(verifier.connection_id, Unset)
assert not isinstance(prover.connection_id, Unset)
proof_req = await send_proof_request.asyncio(
client=backchannel,
json_body=V10PresentationSendRequestRequest(
connection_id=prover.connection_id,
proof_request=IndyProofRequest(
name="test-proof",
requested_attributes=IndyProofRequestRequestedAttributes.from_dict(
{"attr_1_0": {"name": "attr_1_0"}}
),
requested_predicates=IndyProofRequestRequestedPredicates(),
version="0.1",
),
),
)
presentation_request_received = await wait_for_message(
msg_type="did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/admin-holder/0.1/presentation-request-received"
)
assert presentation_request_received["matching_credentials"]
await connection.send_async(
{
"@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/admin-holder/0.1/presentation-request-approve",
"@id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"presentation_exchange_id": presentation_request_received[
"presentation_exchange_id"
],
"self_attested_attributes": {},
"requested_attributes": {
"attr_1_0": {
"cred_id": presentation_request_received["matching_credentials"][0][
"cred_info"
]["referent"],
"revealed": True,
}
},
"requested_predicates": {},
"comment": "It's dangerous to go alone. Take this!",
}
)
pres_sent = await wait_for_message(
msg_type="did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/admin-holder/0.1/presentation-sent"
)
assert pres_sent["presentation_exchange_id"]

0 comments on commit 34577b3

Please sign in to comment.