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

Integration test for did:peer #2713

Merged
merged 6 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
11 changes: 11 additions & 0 deletions demo/INTEGRATION-TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ or:
BDD_EXTRA_AGENT_ARGS="{\"wallet-type\":\"askar\"}" ./run_bdd -t @taa_required
```

The agents run on a pre-defined set of ports, however occasionally your local system may already be using one of these ports. (For example MacOS recently decided to use 8021 for the ftp proxy service.)

To overriide the default port settings:

```bash
AGENT_PORT_OVERRIDE=8030 ./run_bdd -t <some tags>
```
ianco marked this conversation as resolved.
Show resolved Hide resolved

(Note that since the test run multiple agents you require up to 60 available ports.)


## Aca-py Integration Tests vs Aries Agent Test Harness (AATH)

Aca-py Behave tests are based on the interoperability tests that are implemented in the [Aries Agent Test Harness (AATH)](https://github.com/hyperledger/aries-agent-test-harness). Both use [Behave (Gherkin)](https://behave.readthedocs.io/en/stable/) to execute tests against a running aca-py agent (or in the case of AATH, against any compatible Aries agent), however the aca-py integration tests focus on aca-py specific features.
Expand Down
19 changes: 19 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ There are several demos available for ACA-Py mostly (but not only) aimed at deve
- [Multi-ledger](#multi-ledger)
- [Multi-tenancy](#multi-tenancy)
- [Multi-tenancy *with Mediation*!!!](#multi-tenancy-with-mediation)
- [Other Environment Settings](#other-environment-settings)
- [Learning about the Alice/Faber code](#learning-about-the-alicefaber-code)
- [OpenAPI (Swagger) Demo](#openapi-swagger-demo)
- [Performance Demo](#performance-demo)
Expand Down Expand Up @@ -396,6 +397,24 @@ Run the demo (Alice or Faber) specifying *both* options:

This works exactly as the *vanilla* multi-tenancy, except that all connections are mediated.

## Other Environment Settings

The agents run on a pre-defined set of ports, however occasionally your local system may already be using one of these ports. (For example MacOS recently decided to use 8021 for the ftp proxy service.)

To overriide the default port settings:

```bash
AGENT_PORT_OVERRIDE=8010 ./run_demo faber
```

(The agent requires up to 10 available ports.)

To pass extra arguements to the agent (for example):

```bash
DEMO_EXTRA_AGENT_ARGS="[\"--emit-did-peer-2\"]" ./run_demo faber --did-exchange --reuse-connections
```

## Learning about the Alice/Faber code

These Alice and Faber scripts (in the `demo/runners` folder) implement the controller and run the agent as a sub-process (see the documentation for `aca-py`). The controller publishes a REST service to receive web hook callbacks from their agent. Note that this architecture, running the agent as a sub-process, is a variation on the documented architecture of running the controller and agent as separate processes/containers.
Expand Down
4 changes: 4 additions & 0 deletions demo/features/0160-connection.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ Feature: RFC 0160 Aries agent connection functions
@GHA @UnqualifiedDids
Examples:
| Acme_capabilities | Acme_extra | Bob_capabilities | Bob_extra |
| --public-did --did-exchange | --emit-did-peer-2 | --did-exchange |--emit-did-peer-2 |
| --public-did --did-exchange | --emit-did-peer-4 | --did-exchange |--emit-did-peer-4 |
| --public-did --did-exchange | --emit-did-peer-2 | --did-exchange |--emit-did-peer-4 |
| --public-did --did-exchange | --emit-did-peer-4 | --did-exchange |--emit-did-peer-2 |
| --public-did --did-exchange --reuse-connections | --emit-did-peer-2 | --did-exchange |--emit-did-peer-4 |
| --public-did --did-exchange --reuse-connections | --emit-did-peer-4 | --did-exchange |--emit-did-peer-2 |
23 changes: 23 additions & 0 deletions demo/features/0454-present-proof.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,29 @@ Feature: RFC 0454 Aries agent present proof
| Faber | --public-did | --wallet-type askar-anoncreds | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 |


@T001-RFC0454-DID-PEER
Scenario Outline: Present Proof where the prover does not propose a presentation of the proof and is acknowledged
Given we have "2" agents
| name | role | capabilities | extra |
| Faber | verifier | <Acme_capabilities> | <Acme_extra> |
| Bob | prover | <Bob_capabilities> | <Bob_extra> |
And "<issuer>" and "Bob" have an existing connection
And "Bob" has an issued <Schema_name> credential <Credential_data> from "<issuer>"
And "Faber" and "Bob" have an existing connection
When "Faber" sends a request for proof presentation <Proof_request> to "Bob"
Then "Faber" has the proof verified

@WalletType_Askar
Examples:
| issuer | Acme_capabilities | Acme_extra | Bob_capabilities | Bob_extra | Schema_name | Credential_data | Proof_request |
| Faber | --public-did --did-exchange | --emit-did-peer-2 | --did-exchange | --emit-did-peer-2 | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 |

@WalletType_Askar_AnonCreds
Examples:
| issuer | Acme_capabilities | Acme_extra | Bob_capabilities | Bob_extra | Schema_name | Credential_data | Proof_request |
| Faber | --public-did --wallet-type askar-anoncreds | --emit-did-peer-2 | --wallet-type askar-anoncreds | --emit-did-peer-2 | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 |


@T001.1-RFC0454
Scenario Outline: Present Proof where the prover does not propose a presentation of the proof and is acknowledged
Given we have "3" agents
Expand Down
3 changes: 2 additions & 1 deletion demo/features/steps/0160-connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@


BDD_EXTRA_AGENT_ARGS = os.getenv("BDD_EXTRA_AGENT_ARGS")
AGENT_PORT = os.getenv("AGENT_PORT", "8020")


@given("{n} agents")
@given("we have {n} agents")
def step_impl(context, n):
"""Startup 'n' agents based on the options provided in the context table parameters."""

start_port = 8020
start_port = int(AGENT_PORT)

extra_args = None
if BDD_EXTRA_AGENT_ARGS:
Expand Down
6 changes: 6 additions & 0 deletions demo/run_bdd
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ done
AGENT_MODULE="agent_container"
AGENT_PORT=8020
AGENT_PORT_RANGE=8020-8079
# allow override for agent ports
if [ ! -z "$AGENT_PORT_OVERRIDE" ]; then
AGENT_PORT=$AGENT_PORT_OVERRIDE
AGENT_PORT_END=$(expr $AGENT_PORT_OVERRIDE + 59)
AGENT_PORT_RANGE="$AGENT_PORT-$AGENT_PORT_END"
fi

echo "Preparing agent image..."
docker build -q -t acapy-base -f ../docker/Dockerfile .. || exit 1
Expand Down
9 changes: 9 additions & 0 deletions demo/run_demo
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ else
echo "Please specify which agent you want to run. Choose from 'faber', 'alice', 'acme', or 'performance'."
exit 1
fi
# allow override for agent ports
if [ ! -z "$AGENT_PORT_OVERRIDE" ]; then
AGENT_PORT=$AGENT_PORT_OVERRIDE
AGENT_PORT_END=$(expr $AGENT_PORT_OVERRIDE + 9)
AGENT_PORT_RANGE="$AGENT_PORT-$AGENT_PORT_END"
fi

echo "Preparing agent image..."
docker build -q -t acapy-base -f ../docker/Dockerfile .. || exit 1
Expand Down Expand Up @@ -240,6 +246,9 @@ fi
if ! [ -z "$ACAPY_ARG_FILE" ]; then
DOCKER_ENV="${DOCKER_ENV} -e ACAPY_ARG_FILE=${ACAPY_ARG_FILE}"
fi
if ! [ -z "$DEMO_EXTRA_AGENT_ARGS" ]; then
DOCKER_ENV="${DOCKER_ENV} -e DEMO_EXTRA_AGENT_ARGS=${DEMO_EXTRA_AGENT_ARGS}"
fi

if ! [ -z "${ENABLE_PYDEVD_PYCHARM}" ]; then
DOCKER_ENV="${DOCKER_ENV} -e ENABLE_PYDEVD_PYCHARM=${ENABLE_PYDEVD_PYCHARM} -e PYDEVD_PYCHARM_CONTROLLER_PORT=${PYDEVD_PYCHARM_CONTROLLER_PORT} -e PYDEVD_PYCHARM_AGENT_PORT=${PYDEVD_PYCHARM_AGENT_PORT}"
Expand Down
2 changes: 1 addition & 1 deletion demo/runners/agent_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(
log_file: str = None,
log_config: str = None,
log_level: str = None,
extra_args: List[str] = None,
extra_args: List[str] = [],
**kwargs,
):
extra_args = extra_args or []
Expand Down
14 changes: 13 additions & 1 deletion demo/runners/alice.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
prompt_loop,
)


DEMO_EXTRA_AGENT_ARGS = os.getenv("DEMO_EXTRA_AGENT_ARGS")

logging.basicConfig(level=logging.WARNING)
LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -110,7 +113,15 @@ async def input_invitation(agent_container):


async def main(args):
alice_agent = await create_agent_with_args(args, ident="alice")
extra_args = None
if DEMO_EXTRA_AGENT_ARGS:
extra_args = json.loads(DEMO_EXTRA_AGENT_ARGS)
print("Got extra args:", extra_args)
alice_agent = await create_agent_with_args(
args,
ident="alice",
extra_args=extra_args,
)

try:
log_status(
Expand Down Expand Up @@ -139,6 +150,7 @@ async def main(args):
log_file=alice_agent.log_file,
log_config=alice_agent.log_config,
log_level=alice_agent.log_level,
extra_args=extra_args,
)

await alice_agent.initialize(the_agent=agent)
Expand Down
13 changes: 12 additions & 1 deletion demo/runners/faber.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
SELF_ATTESTED = os.getenv("SELF_ATTESTED")
TAILS_FILE_COUNT = int(os.getenv("TAILS_FILE_COUNT", 100))

DEMO_EXTRA_AGENT_ARGS = os.getenv("DEMO_EXTRA_AGENT_ARGS")

logging.basicConfig(level=logging.WARNING)
LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -381,7 +383,15 @@ def generate_proof_request_web_request(


async def main(args):
faber_agent = await create_agent_with_args(args, ident="faber")
extra_args = None
if DEMO_EXTRA_AGENT_ARGS:
extra_args = json.loads(DEMO_EXTRA_AGENT_ARGS)
print("Got extra args:", extra_args)
faber_agent = await create_agent_with_args(
args,
ident="faber",
extra_args=extra_args,
)

try:
log_status(
Expand Down Expand Up @@ -412,6 +422,7 @@ async def main(args):
log_file=faber_agent.log_file,
log_config=faber_agent.log_config,
log_level=faber_agent.log_level,
extra_args=extra_args,
)

faber_schema_name = "degree schema"
Expand Down