From f818215d6bb315b379f84aeb765b6d7d4eaca0ac Mon Sep 17 00:00:00 2001 From: jamshale Date: Wed, 5 Nov 2025 23:27:48 +0000 Subject: [PATCH 1/3] test: kanon profile Signed-off-by: jamshale --- .github/workflows/scenario-integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scenario-integration-tests.yml b/.github/workflows/scenario-integration-tests.yml index c4f55ff4e2..4d41148795 100644 --- a/.github/workflows/scenario-integration-tests.yml +++ b/.github/workflows/scenario-integration-tests.yml @@ -26,7 +26,7 @@ jobs: test: runs-on: ubuntu-latest # Run on openwallet-foundation and non-draft PRs or on non-PR events - if: (github.repository == 'openwallet-foundation/acapy') && ((github.event_name == 'pull_request' && github.event.pull_request.draft == false) || (github.event_name != 'pull_request')) + if: (github.repository == 'jamshale/acapy') && ((github.event_name == 'pull_request' && github.event.pull_request.draft == false) || (github.event_name != 'pull_request')) steps: - name: checkout-acapy uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 From 3f5d2d59e3806c7d80f79584bd2b4c189d142917 Mon Sep 17 00:00:00 2001 From: jamshale Date: Fri, 21 Nov 2025 20:46:22 +0000 Subject: [PATCH 2/3] Delete other scenario tests Signed-off-by: jamshale --- .../docker-compose.yml | 124 ---- .../example.py | 558 ------------------ .../connectionless/docker-compose.yml | 91 --- scenarios/examples/connectionless/example.py | 297 ---------- .../docker-compose.yml | 89 --- .../example.py | 122 ---- scenarios/examples/json_ld/docker-compose.yml | 65 -- scenarios/examples/json_ld/example.py | 455 -------------- .../examples/mediation/docker-compose.yml | 105 ---- scenarios/examples/mediation/example.py | 39 -- .../examples/multitenancy/docker-compose.yml | 61 -- scenarios/examples/multitenancy/example.py | 112 ---- .../multiuse_invitations/docker-compose.yml | 91 --- .../examples/multiuse_invitations/example.py | 34 -- .../docker-compose.yml | 89 --- .../presenting_revoked_credential/example.py | 198 ------- .../docker-compose.yml | 208 ------- .../restart_anoncreds_upgrade/example.py | 500 ---------------- .../examples/self_attested/docker-compose.yml | 88 --- scenarios/examples/self_attested/example.py | 180 ------ scenarios/examples/simple/docker-compose.yml | 92 --- scenarios/examples/simple/example.py | 25 - .../simple_restart/docker-compose.yml | 163 ----- scenarios/examples/simple_restart/example.py | 255 -------- .../examples/vc_holder/docker-compose.yml | 45 -- scenarios/examples/vc_holder/example.py | 95 --- 26 files changed, 4181 deletions(-) delete mode 100644 scenarios/examples/anoncreds_issuance_and_revocation/docker-compose.yml delete mode 100644 scenarios/examples/anoncreds_issuance_and_revocation/example.py delete mode 100644 scenarios/examples/connectionless/docker-compose.yml delete mode 100644 scenarios/examples/connectionless/example.py delete mode 100644 scenarios/examples/did_indy_issuance_and_revocation/docker-compose.yml delete mode 100644 scenarios/examples/did_indy_issuance_and_revocation/example.py delete mode 100644 scenarios/examples/json_ld/docker-compose.yml delete mode 100644 scenarios/examples/json_ld/example.py delete mode 100644 scenarios/examples/mediation/docker-compose.yml delete mode 100644 scenarios/examples/mediation/example.py delete mode 100644 scenarios/examples/multitenancy/docker-compose.yml delete mode 100644 scenarios/examples/multitenancy/example.py delete mode 100644 scenarios/examples/multiuse_invitations/docker-compose.yml delete mode 100644 scenarios/examples/multiuse_invitations/example.py delete mode 100644 scenarios/examples/presenting_revoked_credential/docker-compose.yml delete mode 100644 scenarios/examples/presenting_revoked_credential/example.py delete mode 100644 scenarios/examples/restart_anoncreds_upgrade/docker-compose.yml delete mode 100644 scenarios/examples/restart_anoncreds_upgrade/example.py delete mode 100644 scenarios/examples/self_attested/docker-compose.yml delete mode 100644 scenarios/examples/self_attested/example.py delete mode 100644 scenarios/examples/simple/docker-compose.yml delete mode 100644 scenarios/examples/simple/example.py delete mode 100644 scenarios/examples/simple_restart/docker-compose.yml delete mode 100644 scenarios/examples/simple_restart/example.py delete mode 100644 scenarios/examples/vc_holder/docker-compose.yml delete mode 100644 scenarios/examples/vc_holder/example.py diff --git a/scenarios/examples/anoncreds_issuance_and_revocation/docker-compose.yml b/scenarios/examples/anoncreds_issuance_and_revocation/docker-compose.yml deleted file mode 100644 index 1515ea1c28..0000000000 --- a/scenarios/examples/anoncreds_issuance_and_revocation/docker-compose.yml +++ /dev/null @@ -1,124 +0,0 @@ - services: - agency: - image: acapy-test - ports: - - "3001:3001" - command: > - start - --label Agency - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://agency:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name agency - --wallet-key insecure - --auto-provision - --multitenant - --multitenant-admin - --jwt-secret insecure - --multitenancy-config wallet_type=single-wallet-askar key_derivation_method=RAW - --log-level info - --debug-webhooks - --notify-revocation - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - depends_on: - tails: - condition: service_started - - holder_anoncreds: - image: acapy-test - ports: - - "3002:3001" - command: > - start - --label Holder-AnonCreds - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://holder_anoncreds:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar-anoncreds - --wallet-name holder_anoncreds - --wallet-key insecure - --auto-provision - --log-level info - --debug-webhooks - --monitor-revocation-notification - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - - holder_indy: - image: acapy-test - ports: - - "3003:3001" - command: > - start - --label Holder-Indy - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://holder_indy:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name holder_indy - --wallet-key insecure - --auto-provision - --log-level info - --debug-webhooks - --monitor-revocation-notification - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - - example: - container_name: controller - build: - context: ../.. - environment: - - AGENCY=http://agency:3001 - - HOLDER_ANONCREDS=http://holder_anoncreds:3001 - - HOLDER_INDY=http://holder_indy:3001 - volumes: - - ./example.py:/usr/src/app/example.py:ro,z - command: python -m example - depends_on: - agency: - condition: service_healthy - holder_anoncreds: - condition: service_healthy - holder_indy: - condition: service_healthy - - tails: - image: ghcr.io/bcgov/tails-server:latest - ports: - - 6543:6543 - environment: - - GENESIS_URL=https://test.bcovrin.vonx.io/genesis - command: > - tails-server - --host 0.0.0.0 - --port 6543 - --storage-path /tmp/tails-files - --log-level INFO - diff --git a/scenarios/examples/anoncreds_issuance_and_revocation/example.py b/scenarios/examples/anoncreds_issuance_and_revocation/example.py deleted file mode 100644 index a9f7c6b4e7..0000000000 --- a/scenarios/examples/anoncreds_issuance_and_revocation/example.py +++ /dev/null @@ -1,558 +0,0 @@ -"""Minimal reproducible example script. - -This script is for you to use to reproduce a bug or demonstrate a feature. -""" - -import asyncio -from datetime import datetime -from os import getenv -from secrets import token_hex - -from acapy_controller import Controller -from acapy_controller.logging import logging_to_stdout -from acapy_controller.models import CreateWalletResponse -from acapy_controller.protocols import ( - DIDResult, - didexchange, - indy_anoncred_credential_artifacts, - params, -) -from aiohttp import ClientSession -from examples.util import ( - CredDefResultAnonCreds, - SchemaResultAnonCreds, - anoncreds_issue_credential_v2, - anoncreds_present_proof_v2, -) - -AGENCY = getenv("AGENCY", "http://agency:3001") -HOLDER_ANONCREDS = getenv("HOLDER_ANONCREDS", "http://holder_anoncreds:3001") -HOLDER_INDY = getenv("HOLDER_INDY", "http://holder_indy:3001") - - -async def main(): - """Test Controller protocols.""" - issuer_name = "issuer" + token_hex(8) - issuer_without_schema_name = "issuer" + token_hex(8) - async with Controller(base_url=AGENCY) as agency: - issuer = await agency.post( - "/multitenancy/wallet", - json={ - "label": issuer_name, - "wallet_name": issuer_name, - "wallet_type": "askar", - }, - response=CreateWalletResponse, - ) - issuer_without_schema = await agency.post( - "/multitenancy/wallet", - json={ - "label": issuer_without_schema_name, - "wallet_name": issuer_without_schema_name, - "wallet_type": "askar", - }, - response=CreateWalletResponse, - ) - - async with ( - Controller( - base_url=AGENCY, - wallet_id=issuer.wallet_id, - subwallet_token=issuer.token, - ) as issuer, - Controller( - base_url=AGENCY, - wallet_id=issuer_without_schema.wallet_id, - subwallet_token=issuer_without_schema.token, - ) as issuer_without_schema, - Controller(base_url=HOLDER_ANONCREDS) as holder_anoncreds, - Controller(base_url=HOLDER_INDY) as holder_indy, - ): - """ - This section of the test script demonstrates the issuance, presentation and - revocation of a credential where both the issuer is not anoncreds capable - (wallet type askar) and the holder is anoncreds capable - (wallet type askar-anoncreds). - """ - - # Connecting - issuer_conn_with_anoncreds_holder, holder_anoncreds_conn = await didexchange( - issuer, holder_anoncreds - ) - - # Issuance prep - config = (await issuer.get("/status/config"))["config"] - genesis_url = config.get("ledger.genesis_url") - public_did = (await issuer.get("/wallet/did/public", response=DIDResult)).result - if not public_did: - public_did = ( - await issuer.post( - "/wallet/did/create", - json={"method": "sov", "options": {"key_type": "ed25519"}}, - response=DIDResult, - ) - ).result - assert public_did - - async with ClientSession() as session: - register_url = genesis_url.replace("/genesis", "/register") - async with session.post( - register_url, - json={ - "did": public_did.did, - "verkey": public_did.verkey, - "alias": None, - "role": "ENDORSER", - }, - ) as resp: - assert resp.ok - - await issuer.post("/wallet/did/public", params=params(did=public_did.did)) - - schema_name = "anoncreds-test-" + token_hex(8) - schema_version = "1.0" - schema, cred_def = await indy_anoncred_credential_artifacts( - issuer, - ["firstname", "lastname"], - support_revocation=True, - schema_name=schema_name, - schema_version=schema_version, - ) - - # Issue a credential - issuer_cred_ex, _ = await anoncreds_issue_credential_v2( - issuer, - holder_anoncreds, - issuer_conn_with_anoncreds_holder.connection_id, - holder_anoncreds_conn.connection_id, - {"firstname": "AnonCreds", "lastname": "Holder"}, - cred_def_id=cred_def.credential_definition_id, - issuer_id=public_did.did, - schema_id=schema.schema_id, - schema_issuer_id=public_did.did, - schema_name=schema_name, - ) - - # Present the the credential's attributes - _, verifier_ex = await anoncreds_present_proof_v2( - holder_anoncreds, - issuer, - holder_anoncreds_conn.connection_id, - issuer_conn_with_anoncreds_holder.connection_id, - requested_attributes=[{"name": "firstname"}], - non_revoked={"to": int(datetime.now().timestamp())}, - cred_rev_id=issuer_cred_ex.details.cred_rev_id, - ) - assert verifier_ex.verified == "true" - - # Revoke credential - await issuer.post( - url="/revocation/revoke", - json={ - "connection_id": issuer_conn_with_anoncreds_holder.connection_id, - "rev_reg_id": issuer_cred_ex.details.rev_reg_id, - "cred_rev_id": issuer_cred_ex.details.cred_rev_id, - "publish": True, - "notify": True, - "notify_version": "v1_0", - }, - ) - - await holder_anoncreds.record(topic="revocation-notification") - - # Present the the credential's attributes - now = int(datetime.now().timestamp()) - _, verifier_ex = await anoncreds_present_proof_v2( - holder_anoncreds, - issuer, - holder_anoncreds_conn.connection_id, - issuer_conn_with_anoncreds_holder.connection_id, - requested_attributes=[{"name": "firstname"}], - non_revoked={"to": now}, - cred_rev_id=issuer_cred_ex.details.cred_rev_id, - ) - assert verifier_ex.verified == "false" - - # Issue another credential - issuer_cred_ex, _ = await anoncreds_issue_credential_v2( - issuer, - holder_anoncreds, - issuer_conn_with_anoncreds_holder.connection_id, - holder_anoncreds_conn.connection_id, - {"firstname": "AnonCreds", "lastname": "Holder"}, - cred_def_id=cred_def.credential_definition_id, - issuer_id=public_did.did, - schema_id=schema.schema_id, - schema_issuer_id=public_did.did, - schema_name=schema_name, - ) - - valid_anoncreds_holder_cred_rev_id = issuer_cred_ex.details.cred_rev_id - - # Holder has one revoked and one non-revoked credential - _, verifier_ex = await anoncreds_present_proof_v2( - holder_anoncreds, - issuer, - holder_anoncreds_conn.connection_id, - issuer_conn_with_anoncreds_holder.connection_id, - requested_attributes=[{"name": "firstname"}], - non_revoked={"to": now}, - cred_rev_id=issuer_cred_ex.details.cred_rev_id, - ) - assert verifier_ex.verified == "true" - - """ - This section of the test script demonstrates the issuance, presentation and - revocation of a credential where the issuer and holder are not anoncreds - capable. Both are askar wallet type. - """ - - # Connecting - issuer_conn_with_indy_holder, holder_indy_conn = await didexchange( - issuer, holder_indy - ) - - # Issue a credential - issuer_cred_ex, _ = await anoncreds_issue_credential_v2( - issuer, - holder_indy, - issuer_conn_with_indy_holder.connection_id, - holder_indy_conn.connection_id, - {"firstname": "Indy", "lastname": "Holder"}, - cred_def_id=cred_def.credential_definition_id, - issuer_id=public_did.did, - schema_id=schema.schema_id, - schema_issuer_id=public_did.did, - schema_name=schema_name, - ) - - # Present the the credential's attributes - _, verifier_ex = await anoncreds_present_proof_v2( - holder_indy, - issuer, - holder_indy_conn.connection_id, - issuer_conn_with_indy_holder.connection_id, - requested_attributes=[{"name": "firstname"}], - non_revoked={"to": int(datetime.now().timestamp())}, - cred_rev_id=issuer_cred_ex.details.cred_rev_id, - ) - assert verifier_ex.verified == "true" - - # Revoke credential - await issuer.post( - url="/revocation/revoke", - json={ - "connection_id": issuer_conn_with_indy_holder.connection_id, - "rev_reg_id": issuer_cred_ex.details.rev_reg_id, - "cred_rev_id": issuer_cred_ex.details.cred_rev_id, - "publish": True, - "notify": True, - "notify_version": "v1_0", - }, - ) - - await holder_indy.record(topic="revocation-notification") - - # Presentation after revocation should fail - now = int(datetime.now().timestamp()) - _, verifier_ex = await anoncreds_present_proof_v2( - holder_indy, - issuer, - holder_indy_conn.connection_id, - issuer_conn_with_indy_holder.connection_id, - requested_attributes=[{"name": "firstname"}], - non_revoked={"to": now}, - cred_rev_id=issuer_cred_ex.details.cred_rev_id, - ) - assert verifier_ex.verified == "false" - - # Add another credential to the holder and present it - issuer_cred_ex, _ = await anoncreds_issue_credential_v2( - issuer, - holder_indy, - issuer_conn_with_indy_holder.connection_id, - holder_indy_conn.connection_id, - {"firstname": "Indy", "lastname": "Holder"}, - cred_def_id=cred_def.credential_definition_id, - issuer_id=public_did.did, - schema_id=schema.schema_id, - schema_issuer_id=public_did.did, - schema_name=schema_name, - ) - - valid_indy_holder_cred_rev_id = issuer_cred_ex.details.cred_rev_id - - # Presentation with one revoked and one valid credential - _, verifier_ex = await anoncreds_present_proof_v2( - holder_indy, - issuer, - holder_indy_conn.connection_id, - issuer_conn_with_indy_holder.connection_id, - requested_attributes=[{"name": "firstname"}], - non_revoked={"to": now}, - cred_rev_id=issuer_cred_ex.details.cred_rev_id, - ) - assert verifier_ex.verified == "true" - - """ - Upgrade the issuer tenant to anoncreds capable wallet type. When upgrading a - tenant the agent doesn't require a restart. That is why the test is done - with multitenancy - """ - await issuer.post( - "/anoncreds/wallet/upgrade", - params={ - "wallet_name": issuer_name, - }, - ) - # Wait for the upgrade to complete - await asyncio.sleep(1) - - await issuer_without_schema.post( - "/anoncreds/wallet/upgrade", - params={ - "wallet_name": issuer_without_schema_name, - }, - ) - # Wait for the upgrade to complete - await asyncio.sleep(1) - - """ - Do issuance and presentation again after the upgrade. This time the issuer is - an anoncreds capable wallet (wallet type askar-anoncreds). - """ - # Presentation for anoncreds capable holder on existing credential - _, verifier_ex = await anoncreds_present_proof_v2( - holder_anoncreds, - issuer, - holder_anoncreds_conn.connection_id, - issuer_conn_with_anoncreds_holder.connection_id, - requested_attributes=[{"name": "firstname"}], - non_revoked={"to": now}, - cred_rev_id=valid_anoncreds_holder_cred_rev_id, - ) - assert verifier_ex.verified == "true" - - # Presentation for indy capable holder on existing credential - _, verifier_ex = await anoncreds_present_proof_v2( - holder_indy, - issuer, - holder_indy_conn.connection_id, - issuer_conn_with_indy_holder.connection_id, - requested_attributes=[{"name": "firstname"}], - non_revoked={"to": now}, - cred_rev_id=valid_indy_holder_cred_rev_id, - ) - assert verifier_ex.verified == "true" - - # Create a new schema and cred def with different attributes on new - # anoncreds endpoints - schema_name = "anoncreds-test-" + token_hex(8) - schema_version = "1.0" - schema = await issuer.post( - "/anoncreds/schema", - json={ - "schema": { - "name": schema_name, - "version": schema_version, - "attrNames": ["middlename"], - "issuerId": public_did.did, - } - }, - response=SchemaResultAnonCreds, - ) - cred_def = await issuer.post( - "/anoncreds/credential-definition", - json={ - "credential_definition": { - "issuerId": schema.schema_state["schema"]["issuerId"], - "schemaId": schema.schema_state["schema_id"], - "tag": token_hex(8), - }, - "options": {"support_revocation": True, "revocation_registry_size": 10}, - }, - response=CredDefResultAnonCreds, - ) - - # Issue a new credential to anoncreds holder - issuer_cred_ex, _ = await anoncreds_issue_credential_v2( - issuer, - holder_anoncreds, - issuer_conn_with_anoncreds_holder.connection_id, - holder_anoncreds_conn.connection_id, - {"middlename": "AnonCreds"}, - cred_def_id=cred_def.credential_definition_state["credential_definition_id"], - issuer_id=public_did.did, - schema_id=schema.schema_state["schema_id"], - schema_issuer_id=public_did.did, - schema_name=schema_name, - ) - # Presentation for anoncreds capable holder - _, verifier_ex = await anoncreds_present_proof_v2( - holder_anoncreds, - issuer, - holder_anoncreds_conn.connection_id, - issuer_conn_with_anoncreds_holder.connection_id, - requested_attributes=[{"name": "middlename"}], - non_revoked={"to": int(datetime.now().timestamp())}, - cred_rev_id=issuer_cred_ex.details.cred_rev_id, - ) - assert verifier_ex.verified == "true" - # Revoke credential - await issuer.post( - url="/anoncreds/revocation/revoke", - json={ - "connection_id": issuer_conn_with_anoncreds_holder.connection_id, - "rev_reg_id": issuer_cred_ex.details.rev_reg_id, - "cred_rev_id": issuer_cred_ex.details.cred_rev_id, - "publish": True, - "notify": True, - "notify_version": "v1_0", - }, - ) - await holder_anoncreds.record(topic="revocation-notification") - - _, verifier_ex = await anoncreds_present_proof_v2( - holder_anoncreds, - issuer, - holder_anoncreds_conn.connection_id, - issuer_conn_with_anoncreds_holder.connection_id, - requested_attributes=[{"name": "middlename"}], - non_revoked={"to": int(datetime.now().timestamp())}, - cred_rev_id=issuer_cred_ex.details.cred_rev_id, - ) - assert verifier_ex.verified == "false" - - # Issue a new credential to indy holder - issuer_cred_ex, _ = await anoncreds_issue_credential_v2( - issuer, - holder_indy, - issuer_conn_with_indy_holder.connection_id, - holder_indy_conn.connection_id, - {"middlename": "Indy"}, - cred_def_id=cred_def.credential_definition_state["credential_definition_id"], - issuer_id=public_did.did, - schema_id=schema.schema_state["schema_id"], - schema_issuer_id=public_did.did, - schema_name=schema_name, - ) - # Presentation for indy holder - _, verifier_ex = await anoncreds_present_proof_v2( - holder_indy, - issuer, - holder_indy_conn.connection_id, - issuer_conn_with_indy_holder.connection_id, - requested_attributes=[{"name": "middlename"}], - non_revoked={"to": int(datetime.now().timestamp())}, - cred_rev_id=issuer_cred_ex.details.cred_rev_id, - ) - assert verifier_ex.verified == "true" - # Revoke credential - await issuer.post( - url="/anoncreds/revocation/revoke", - json={ - "connection_id": issuer_conn_with_indy_holder.connection_id, - "rev_reg_id": issuer_cred_ex.details.rev_reg_id, - "cred_rev_id": issuer_cred_ex.details.cred_rev_id, - "publish": True, - "notify": True, - "notify_version": "v1_0", - }, - ) - - await holder_indy.record(topic="revocation-notification") - - _, verifier_ex = await anoncreds_present_proof_v2( - holder_indy, - issuer, - holder_indy_conn.connection_id, - issuer_conn_with_indy_holder.connection_id, - requested_attributes=[{"name": "middlename"}], - non_revoked={"to": int(datetime.now().timestamp())}, - cred_rev_id=issuer_cred_ex.details.cred_rev_id, - ) - assert verifier_ex.verified == "false" - - """ - This section of the test script demonstrates the issuance, presentation and - revocation of a credential where the issuer did not create the schema. - """ - print( - "***Begin issuance, presentation and revocation of " - "credential without schema***" - ) - issuer_conn_with_anoncreds_holder, holder_anoncreds_conn = await didexchange( - issuer_without_schema, holder_anoncreds - ) - - public_did = ( - await issuer_without_schema.post( - "/wallet/did/create", - json={"method": "sov", "options": {"key_type": "ed25519"}}, - response=DIDResult, - ) - ).result - assert public_did - - async with ClientSession() as session: - register_url = genesis_url.replace("/genesis", "/register") - async with session.post( - register_url, - json={ - "did": public_did.did, - "verkey": public_did.verkey, - "alias": None, - "role": "ENDORSER", - }, - ) as resp: - assert resp.ok - - await issuer_without_schema.post( - "/wallet/did/public", params=params(did=public_did.did) - ) - cred_def = await issuer_without_schema.post( - "/anoncreds/credential-definition", - json={ - "credential_definition": { - "issuerId": public_did.did, - "schemaId": schema.schema_state["schema_id"], - "tag": token_hex(8), - }, - "options": {"support_revocation": True, "revocation_registry_size": 10}, - }, - response=CredDefResultAnonCreds, - ) - issuer_cred_ex, _ = await anoncreds_issue_credential_v2( - issuer_without_schema, - holder_anoncreds, - issuer_conn_with_anoncreds_holder.connection_id, - holder_anoncreds_conn.connection_id, - {"middlename": "AnonCreds"}, - cred_def_id=cred_def.credential_definition_state["credential_definition_id"], - schema_id=schema.schema_state["schema_id"], - ) - await anoncreds_present_proof_v2( - holder_anoncreds, - issuer_without_schema, - holder_anoncreds_conn.connection_id, - issuer_conn_with_anoncreds_holder.connection_id, - requested_attributes=[{"name": "middlename"}], - ) - await issuer_without_schema.post( - url="/anoncreds/revocation/revoke", - json={ - "connection_id": issuer_conn_with_anoncreds_holder.connection_id, - "rev_reg_id": issuer_cred_ex.details.rev_reg_id, - "cred_rev_id": issuer_cred_ex.details.cred_rev_id, - "publish": True, - "notify": True, - "notify_version": "v1_0", - }, - ) - - await holder_anoncreds.record(topic="revocation-notification") - - -if __name__ == "__main__": - logging_to_stdout() - asyncio.run(main()) diff --git a/scenarios/examples/connectionless/docker-compose.yml b/scenarios/examples/connectionless/docker-compose.yml deleted file mode 100644 index 5011de3139..0000000000 --- a/scenarios/examples/connectionless/docker-compose.yml +++ /dev/null @@ -1,91 +0,0 @@ - services: - alice: - image: acapy-test - ports: - - "3001:3001" - environment: - RUST_LOG: 'aries-askar::log::target=error' - command: > - start - --label Alice - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://alice:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name alice - --wallet-key insecure - --auto-provision - --log-level debug - --debug-webhooks - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - depends_on: - tails: - condition: service_started - - bob: - image: acapy-test - ports: - - "3002:3001" - environment: - RUST_LOG: 'aries-askar::log::target=error' - command: > - start - --label Bob - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://bob:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name bob - --wallet-key insecure - --auto-provision - --log-level debug - --debug-webhooks - --monitor-revocation-notification - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - - tails: - image: ghcr.io/bcgov/tails-server:latest - ports: - - 6543:6543 - environment: - - GENESIS_URL=https://test.bcovrin.vonx.io/genesis - command: > - tails-server - --host 0.0.0.0 - --port 6543 - --storage-path /tmp/tails-files - --log-level INFO - - example: - container_name: controller - build: - context: ../.. - environment: - - ALICE=http://alice:3001 - - BOB=http://bob:3001 - volumes: - - ./example.py:/usr/src/app/example.py:ro,z - command: python -m example - depends_on: - alice: - condition: service_healthy - bob: - condition: service_healthy diff --git a/scenarios/examples/connectionless/example.py b/scenarios/examples/connectionless/example.py deleted file mode 100644 index 7c0d867461..0000000000 --- a/scenarios/examples/connectionless/example.py +++ /dev/null @@ -1,297 +0,0 @@ -"""Minimal reproducible example script. - -This script is for you to use to reproduce a bug or demonstrate a feature. -""" - -import asyncio -from dataclasses import dataclass -from os import getenv - -from acapy_controller import Controller -from acapy_controller.controller import Minimal -from acapy_controller.logging import logging_to_stdout -from acapy_controller.protocols import ( - DIDResult, - InvitationRecord, - V20CredExRecordDetail, - V20CredExRecordIndy, - indy_anoncred_credential_artifacts, - params, -) -from aiohttp import ClientSession - -ALICE = getenv("ALICE", "http://alice:3001") -BOB = getenv("BOB", "http://bob:3001") - - -@dataclass -class ConnectionlessV20CredExRecord(Minimal): - """Minimal record for connectionless v2 cred ex record.""" - - cred_ex_id: str - - -async def icv2(): - """Test Controller protocols.""" - async with Controller(base_url=ALICE) as alice, Controller(base_url=BOB) as bob: - config = (await alice.get("/status/config"))["config"] - genesis_url = config.get("ledger.genesis_url") - public_did = (await alice.get("/wallet/did/public", response=DIDResult)).result - - if not public_did: - public_did = ( - await alice.post( - "/wallet/did/create", - json={"method": "sov", "options": {"key_type": "ed25519"}}, - response=DIDResult, - ) - ).result - assert public_did - - async with ClientSession() as session: - print(genesis_url) - async with session.post( - genesis_url.replace("/genesis", "/register"), - json={ - "did": public_did.did, - "verkey": public_did.verkey, - "alias": None, - "role": "ENDORSER", - }, - ) as resp: - assert resp.ok - - await alice.post("/wallet/did/public", params=params(did=public_did.did)) - - _, cred_def = await indy_anoncred_credential_artifacts( - alice, ["firstname", "lastname"] - ) - - attributes = {"firstname": "Bob", "lastname": "Builder"} - offer = await alice.post( - "/issue-credential-2.0/create-offer", - json={ - "auto_issue": False, - "auto_remove": False, - "comment": "Credential from minimal example", - "trace": False, - "filter": {"indy": {"cred_def_id": cred_def.credential_definition_id}}, - "credential_preview": { - "type": "issue-credential-2.0/2.0/credential-preview", # pyright: ignore - "attributes": [ - { - "mime_type": None, - "name": name, - "value": value, - } - for name, value in attributes.items() - ], - }, - }, - response=ConnectionlessV20CredExRecord, - ) - invite = await alice.post( - "/out-of-band/create-invitation", - json={"attachments": [{"id": offer.cred_ex_id, "type": "credential-offer"}]}, - response=InvitationRecord, - ) - bob.event_queue.flush() - await bob.post("/out-of-band/receive-invitation", json=invite.invitation) - bob_cred_ex = await bob.event_with_values( - topic="issue_credential_v2_0", - state="offer-received", - event_type=ConnectionlessV20CredExRecord, - ) - bob_cred_ex_id = bob_cred_ex.cred_ex_id - - alice.event_queue.flush() - bob_cred_ex = await bob.post( - f"/issue-credential-2.0/records/{bob_cred_ex_id}/send-request", - response=ConnectionlessV20CredExRecord, - ) - - alice_cred_ex = await alice.event_with_values( - topic="issue_credential_v2_0", - state="request-received", - event_type=ConnectionlessV20CredExRecord, - ) - alice_cred_ex_id = alice_cred_ex.cred_ex_id - - alice_cred_ex = await alice.post( - f"/issue-credential-2.0/records/{alice_cred_ex_id}/issue", - json={}, - response=V20CredExRecordDetail, - ) - - await bob.event_with_values( - topic="issue_credential_v2_0", - cred_ex_id=bob_cred_ex_id, - state="credential-received", - ) - - bob_cred_ex = await bob.post( - f"/issue-credential-2.0/records/{bob_cred_ex_id}/store", - json={}, - response=V20CredExRecordDetail, - ) - alice_cred_ex = await alice.event_with_values( - topic="issue_credential_v2_0", - event_type=ConnectionlessV20CredExRecord, - cred_ex_id=alice_cred_ex_id, - state="done", - ) - await alice.event_with_values( - topic="issue_credential_v2_0_indy", - event_type=V20CredExRecordIndy, - ) - - bob_cred_ex = await bob.event_with_values( - topic="issue_credential_v2_0", - event_type=ConnectionlessV20CredExRecord, - cred_ex_id=bob_cred_ex_id, - state="done", - ) - await bob.event_with_values( - topic="issue_credential_v2_0_indy", - event_type=V20CredExRecordIndy, - ) - - -@dataclass -class ConnectionlessV10CredExRecord(Minimal): - """Minimal record for v1 cred ex record.""" - - credential_exchange_id: str - - -async def icv1(): - """Issue credential v1.""" - async with Controller(base_url=ALICE) as alice, Controller(base_url=BOB) as bob: - config = (await alice.get("/status/config"))["config"] - genesis_url = config.get("ledger.genesis_url") - public_did = (await alice.get("/wallet/did/public", response=DIDResult)).result - if not public_did: - public_did = ( - await alice.post( - "/wallet/did/create", - json={"method": "sov", "options": {"key_type": "ed25519"}}, - response=DIDResult, - ) - ).result - assert public_did - - async with ClientSession() as session: - register_url = genesis_url.replace("/genesis", "/register") - async with session.post( - register_url, - json={ - "did": public_did.did, - "verkey": public_did.verkey, - "alias": None, - "role": "ENDORSER", - }, - ) as resp: - if resp.ok: - return await resp.json() - - await alice.post("/wallet/did/public", params=params(did=public_did.did)) - - _, cred_def = await indy_anoncred_credential_artifacts( - alice, ["firstname", "lastname"] - ) - - attributes = {"firstname": "Bob", "lastname": "Builder"} - offer = await alice.post( - "/issue-credential/create-offer", - json={ - "auto_issue": False, - "auto_remove": False, - "comment": "Credential from minimal example", - "trace": False, - "cred_def_id": cred_def.credential_definition_id, - "credential_preview": { - "@type": "issue-credential/1.0/credential-preview", - "attributes": [ - { - "mime_type": None, - "name": name, - "value": value, - } - for name, value in attributes.items() - ], - }, - }, - response=ConnectionlessV10CredExRecord, - ) - invite = await alice.post( - "/out-of-band/create-invitation", - json={ - "attachments": [ - {"id": offer.credential_exchange_id, "type": "credential-offer"} - ] - }, - response=InvitationRecord, - ) - bob.event_queue.flush() - await bob.post("/out-of-band/receive-invitation", json=invite.invitation) - bob_cred_ex = await bob.event_with_values( - topic="issue_credential", - state="offer_received", - event_type=ConnectionlessV10CredExRecord, - ) - bob_cred_ex_id = bob_cred_ex.credential_exchange_id - - alice.event_queue.flush() - bob_cred_ex = await bob.post( - f"/issue-credential/records/{bob_cred_ex_id}/send-request", - response=ConnectionlessV10CredExRecord, - ) - - alice_cred_ex = await alice.event_with_values( - topic="issue_credential", - state="request_received", - event_type=ConnectionlessV10CredExRecord, - ) - alice_cred_ex_id = alice_cred_ex.credential_exchange_id - - alice_cred_ex = await alice.post( - f"/issue-credential/records/{alice_cred_ex_id}/issue", - json={}, - response=ConnectionlessV10CredExRecord, - ) - - await bob.event_with_values( - topic="issue_credential", - credential_exchange_id=bob_cred_ex_id, - state="credential_received", - ) - - bob_cred_ex = await bob.post( - f"/issue-credential/records/{bob_cred_ex_id}/store", - json={}, - response=ConnectionlessV10CredExRecord, - ) - alice_cred_ex = await alice.event_with_values( - topic="issue_credential", - event_type=ConnectionlessV10CredExRecord, - credential_exchange_id=alice_cred_ex_id, - state="credential_acked", - ) - - bob_cred_ex = await bob.event_with_values( - topic="issue_credential", - event_type=ConnectionlessV10CredExRecord, - credential_exchange_id=bob_cred_ex_id, - state="credential_acked", - ) - - -async def main(): - """Run.""" - await icv1() - await icv2() - - -if __name__ == "__main__": - logging_to_stdout() - asyncio.run(main()) diff --git a/scenarios/examples/did_indy_issuance_and_revocation/docker-compose.yml b/scenarios/examples/did_indy_issuance_and_revocation/docker-compose.yml deleted file mode 100644 index b3821248a3..0000000000 --- a/scenarios/examples/did_indy_issuance_and_revocation/docker-compose.yml +++ /dev/null @@ -1,89 +0,0 @@ - services: - alice: - image: acapy-test - ports: - - "3001:3001" - command: > - start - --label Alice - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://alice:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name alice - --wallet-key insecure - --auto-provision - --log-level info - --debug-webhooks - --notify-revocation - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - depends_on: - tails: - condition: service_started - - bob: - image: acapy-test - ports: - - "3002:3001" - command: > - start - --label Bob - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://bob:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name bob - --wallet-key insecure - --auto-provision - --log-level info - --debug-webhooks - --monitor-revocation-notification - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - - example: - container_name: controller - build: - context: ../.. - environment: - - ALICE=http://alice:3001 - - BOB=http://bob:3001 - volumes: - - ./example.py:/usr/src/app/example.py:ro,z - command: python -m example - depends_on: - alice: - condition: service_healthy - bob: - condition: service_healthy - - tails: - image: ghcr.io/bcgov/tails-server:latest - ports: - - 6543:6543 - environment: - - GENESIS_URL=https://test.bcovrin.vonx.io/genesis - command: > - tails-server - --host 0.0.0.0 - --port 6543 - --storage-path /tmp/tails-files - --log-level INFO - diff --git a/scenarios/examples/did_indy_issuance_and_revocation/example.py b/scenarios/examples/did_indy_issuance_and_revocation/example.py deleted file mode 100644 index 9fa5d5b5fe..0000000000 --- a/scenarios/examples/did_indy_issuance_and_revocation/example.py +++ /dev/null @@ -1,122 +0,0 @@ -"""Minimal reproducible example script. - -This script is for you to use to reproduce a bug or demonstrate a feature. -""" - -import asyncio -import json -from dataclasses import dataclass -from os import getenv - -from acapy_controller import Controller -from acapy_controller.logging import logging_to_stdout -from acapy_controller.models import V20PresExRecord -from acapy_controller.protocols import ( - DIDResult, - anoncreds_publish_revocation, - didexchange, - indy_anoncred_credential_artifacts, - anoncreds_revoke, - indy_issue_credential_v2, - indy_present_proof_v2, - params, -) -from aiohttp import ClientSession - -ALICE = getenv("ALICE", "http://alice:3001") -BOB = getenv("BOB", "http://bob:3001") - - -def summary(presentation: V20PresExRecord) -> str: - """Summarize a presentation exchange record.""" - request = presentation.pres_request - return "Summary: " + json.dumps( - { - "state": presentation.state, - "verified": presentation.verified, - "presentation_request": request.dict(by_alias=True) if request else None, - }, - indent=2, - sort_keys=True, - ) - - -@dataclass -class IndyDidCreateResponse: - """Response from creating a DID.""" - - did: str - verkey: str - - -async def main(): - """Test Controller protocols.""" - async with Controller(base_url=ALICE) as alice, Controller(base_url=BOB) as bob: - # Connecting - alice_conn, bob_conn = await didexchange(alice, bob) - - # Issuance prep - config = (await alice.get("/status/config"))["config"] - genesis_url = config.get("ledger.genesis_url") - public_did = (await alice.get("/wallet/did/public", response=DIDResult)).result - if not public_did: - public_did = await alice.post( - "/did/indy/create", - json={}, - response=IndyDidCreateResponse, - ) - assert public_did - - async with ClientSession() as session: - register_url = genesis_url.replace("/genesis", "/register") - async with session.post( - register_url, - json={ - "did": public_did.did, - "verkey": public_did.verkey, - "alias": None, - "role": "ENDORSER", - }, - ) as resp: - assert resp.ok - - await alice.post("/wallet/did/public", params=params(did=public_did.did)) - _, cred_def = await indy_anoncred_credential_artifacts( - alice, - ["firstname", "lastname"], - support_revocation=True, - ) - - # Issue a credential - alice_cred_ex, _ = await indy_issue_credential_v2( - alice, - bob, - alice_conn.connection_id, - bob_conn.connection_id, - cred_def.credential_definition_id, - {"firstname": "Bob", "lastname": "Builder"}, - ) - - # Present the the credential's attributes - await indy_present_proof_v2( - bob, - alice, - bob_conn.connection_id, - alice_conn.connection_id, - requested_attributes=[{"name": "firstname"}], - ) - - # Revoke credential - await anoncreds_revoke( - alice, - cred_ex=alice_cred_ex, - holder_connection_id=alice_conn.connection_id, - notify=True, - ) - await anoncreds_publish_revocation(alice, cred_ex=alice_cred_ex) - await bob.record(topic="revocation-notification") - - -if __name__ == "__main__": - logging_to_stdout() - asyncio.run(main()) diff --git a/scenarios/examples/json_ld/docker-compose.yml b/scenarios/examples/json_ld/docker-compose.yml deleted file mode 100644 index 0503b32450..0000000000 --- a/scenarios/examples/json_ld/docker-compose.yml +++ /dev/null @@ -1,65 +0,0 @@ - services: - alice: - image: acapy-test - ports: - - "3001:3001" - command: > - start -it http 0.0.0.0 3000 - --label Alice - -ot http - -e http://alice:3000 - --admin 0.0.0.0 3001 --admin-insecure-mode - --log-level debug - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name alice - --wallet-key insecure - --auto-provision - --debug-webhooks - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 3s - timeout: 5s - retries: 5 - - - bob: - image: acapy-test - ports: - - "3002:3001" - command: > - start -it http 0.0.0.0 3000 - --label Bob - -ot http - -e http://bob:3000 - --admin 0.0.0.0 3001 --admin-insecure-mode - --log-level debug - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name bob - --wallet-key insecure - --auto-provision - --debug-webhooks - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 3s - timeout: 5s - retries: 5 - - example: - container_name: controller - build: - context: ../.. - environment: - - ALICE=http://alice:3001 - - BOB=http://bob:3001 - volumes: - - ./example.py:/usr/src/app/example.py:ro,z - command: python -m example - depends_on: - alice: - condition: service_healthy - bob: - condition: service_healthy diff --git a/scenarios/examples/json_ld/example.py b/scenarios/examples/json_ld/example.py deleted file mode 100644 index 1629335fc0..0000000000 --- a/scenarios/examples/json_ld/example.py +++ /dev/null @@ -1,455 +0,0 @@ -"""Minimal reproducible example script. - -This script is for you to use to reproduce a bug or demonstrate a feature. -""" - -import asyncio -import json -from datetime import date -from os import getenv -from uuid import uuid4 - -from acapy_controller import Controller -from acapy_controller.logging import logging_to_stdout, pause_for_input, section -from acapy_controller.models import DIDResult, V20PresExRecord -from acapy_controller.protocols import ( - didexchange, - jsonld_issue_credential, - jsonld_present_proof, - params, -) -from aiohttp import ClientSession - -ALICE = getenv("ALICE", "http://alice:3001") -BOB = getenv("BOB", "http://bob:3001") - - -def presentation_summary(pres_ex: V20PresExRecord): - """Summarize a presentation.""" - pres_ex_dict = pres_ex.dict(exclude_none=True, exclude_unset=True) - return json.dumps( - { - key: pres_ex_dict.get(key) - for key in ( - "verified", - "state", - "role", - "connection_id", - "pres_request", - "pres", - ) - }, - indent=2, - ) - - -async def main(): - """Test Controller protocols.""" - async with Controller(base_url=ALICE) as alice, Controller(base_url=BOB) as bob: - with section("Establish connection"): - alice_conn, bob_conn = await didexchange(alice, bob) - - with section("Prepare for issuance"): - with section("Issuer prepares issuing DIDs", character="-"): - config = (await alice.get("/status/config"))["config"] - genesis_url = config.get("ledger.genesis_url") - public_did = ( - await alice.get("/wallet/did/public", response=DIDResult) - ).result - if not public_did: - public_did = ( - await alice.post( - "/wallet/did/create", - json={"method": "sov", "options": {"key_type": "ed25519"}}, - response=DIDResult, - ) - ).result - assert public_did - - async with ClientSession() as session: - register_url = genesis_url.replace("/genesis", "/register") - async with session.post( - register_url, - json={ - "did": public_did.did, - "verkey": public_did.verkey, - "alias": None, - "role": "ENDORSER", - }, - ) as resp: - assert resp.ok - - await alice.post( - "/wallet/did/public", params=params(did=public_did.did) - ) - - p256_alice_did_res = ( - await alice.post( - "/wallet/did/create", - json={"method": "key", "options": {"key_type": "p256"}}, - ) - )["result"] - assert p256_alice_did_res - p256_alice_did = p256_alice_did_res["did"] - - bls_alice_did_res = ( - await alice.post( - "/wallet/did/create", - json={"method": "key", "options": {"key_type": "bls12381g2"}}, - ) - )["result"] - assert bls_alice_did_res - bls_alice_did = bls_alice_did_res["did"] - - with section("Recipient prepares subject DIDs", character="-"): - ed25519_bob_did = ( - await bob.post( - "/wallet/did/create", - json={"method": "key", "options": {"key_type": "ed25519"}}, - response=DIDResult, - ) - ).result - assert ed25519_bob_did - p256_bob_did_res = ( - await bob.post( - "/wallet/did/create", - json={"method": "key", "options": {"key_type": "p256"}}, - ) - )["result"] - assert p256_bob_did_res - p256_bob_did = p256_bob_did_res["did"] - bls_bob_did_res = ( - await bob.post( - "/wallet/did/create", - json={"method": "key", "options": {"key_type": "bls12381g2"}}, - ) - )["result"] - assert bls_bob_did_res - bls_bob_did = bls_bob_did_res["did"] - - pause_for_input() - - with section("Issue example credential using Public Issuer ED25519 Signature"): - issuer_cred_ex, holder_cred_ex = await jsonld_issue_credential( - alice, - bob, - alice_conn.connection_id, - bob_conn.connection_id, - credential={ - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://w3id.org/citizenship/v1", - ], - "type": ["VerifiableCredential", "PermanentResident"], - "issuer": "did:sov:" + public_did.did, - "issuanceDate": str(date.today()), - "credentialSubject": { - "type": ["PermanentResident"], - "id": ed25519_bob_did.did, - "givenName": "Bob", - "familyName": "Builder", - "gender": "Male", - "birthCountry": "Bahamas", - "birthDate": "1958-07-17", - }, - }, - options={"proofType": "Ed25519Signature2018"}, - ) - - pause_for_input() - - with section("Present example ED25519 credential"): - alice_pres_ex, bob_pres_ex = await jsonld_present_proof( - alice, - bob, - alice_conn.connection_id, - bob_conn.connection_id, - presentation_definition={ - "input_descriptors": [ - { - "id": "citizenship_input_1", - "name": "EU Driver's License", - "schema": [ - { - "uri": "https://www.w3.org/2018/credentials#VerifiableCredential" # noqa: E501 - }, - { - "uri": "https://w3id.org/citizenship#PermanentResident" # noqa: E501 - }, - ], - "constraints": { - "is_holder": [ - { - "directive": "required", - "field_id": [ - "1f44d55f-f161-4938-a659-f8026467f126" - ], - } - ], - "fields": [ - { - "id": "1f44d55f-f161-4938-a659-f8026467f126", - "path": ["$.credentialSubject.familyName"], - "purpose": "The claim must be from one of the specified issuers", # noqa: E501 - "filter": {"const": "Builder"}, - }, - { - "path": ["$.credentialSubject.givenName"], - "purpose": "The claim must be from one of the specified issuers", # noqa: E501 - }, - ], - }, - } - ], - "id": str(uuid4()), - "format": {"ldp_vp": {"proof_type": ["Ed25519Signature2018"]}}, - }, - domain="test-degree", - ) - with section("Presentation summary", character="-"): - print(presentation_summary(alice_pres_ex.into(V20PresExRecord))) - - pause_for_input() - - with section("Issue example credential using P256 Signature"): - issuer_cred_ex, holder_cred_ex = await jsonld_issue_credential( - alice, - bob, - alice_conn.connection_id, - bob_conn.connection_id, - credential={ - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://w3id.org/citizenship/v1", - ], - "type": ["VerifiableCredential", "PermanentResident"], - "issuer": p256_alice_did, - "issuanceDate": str(date.today()), - "credentialSubject": { - "type": ["PermanentResident"], - "id": p256_bob_did, - "givenName": "Bob", - "familyName": "Builder", - "gender": "Male", - "birthCountry": "Bahamas", - "birthDate": "1958-07-17", - }, - }, - options={"proofType": "EcdsaSecp256r1Signature2019"}, - ) - - pause_for_input() - - with section("Present example P256 credential"): - alice_pres_ex, bob_pres_ex = await jsonld_present_proof( - alice, - bob, - alice_conn.connection_id, - bob_conn.connection_id, - presentation_definition={ - "input_descriptors": [ - { - "id": "citizenship_input_1", - "name": "EU Driver's License", - "schema": [ - { - "uri": "https://www.w3.org/2018/credentials#VerifiableCredential" # noqa: E501 - }, - { - "uri": "https://w3id.org/citizenship#PermanentResident" # noqa: E501 - }, - ], - "constraints": { - "is_holder": [ - { - "directive": "required", - "field_id": [ - "1f44d55f-f161-4938-a659-f8026467f126" - ], - } - ], - "fields": [ - { - "id": "1f44d55f-f161-4938-a659-f8026467f126", - "path": ["$.credentialSubject.familyName"], - "purpose": "The claim must be from one of the specified issuers", # noqa: E501 - "filter": {"const": "Builder"}, - }, - { - "path": ["$.issuer"], - "purpose": "The claim must be from one of the specified issuers", # noqa: E501 - "filter": {"const": p256_alice_did}, - }, - { - "path": ["$.credentialSubject.givenName"], - "purpose": "The claim must be from one of the specified issuers", # noqa: E501 - }, - ], - }, - } - ], - "id": str(uuid4()), - "format": {"ldp_vp": {"proof_type": ["EcdsaSecp256r1Signature2019"]}}, - }, - domain="test-degree", - ) - with section("Presentation summary", character="-"): - print(presentation_summary(alice_pres_ex.into(V20PresExRecord))) - - pause_for_input() - - with section("Issue ED25519 Credential with quick context"): - issuer_cred_ex, holder_cred_ex = await jsonld_issue_credential( - alice, - bob, - alice_conn.connection_id, - bob_conn.connection_id, - credential={ - "@context": [ - "https://www.w3.org/2018/credentials/v1", - { - "ex": "https://example.com/examples#", - "TableTennisTournamentWin": "ex:TableTennisTournamentWin", - "dateWon": "ex:dateWon", - }, - ], - "type": ["VerifiableCredential", "TableTennisTournamentWin"], - "issuer": "did:sov:" + public_did.did, - "issuanceDate": str(date.today()), - "credentialSubject": { - "id": ed25519_bob_did.did, - "dateWon": str(date.today()), - }, - }, - options={"proofType": "Ed25519Signature2018"}, - ) - - pause_for_input() - - with section("Present ED25519 quick context credential"): - alice_pres_ex, bob_pres_ex = await jsonld_present_proof( - alice, - bob, - alice_conn.connection_id, - bob_conn.connection_id, - presentation_definition={ - "input_descriptors": [ - { - "id": "ttt_win_input_1", - "name": "TableTennisTournamentWin", - "schema": [ - { - "uri": "https://www.w3.org/2018/credentials#VerifiableCredential" # noqa: E501 - }, - { - "uri": "https://example.com/examples#TableTennisTournamentWin" # noqa: E501 - }, - ], - "constraints": { - "is_holder": [ - { - "directive": "required", - "field_id": [ - "1f44d55f-f161-4938-a659-f8026467f126" - ], - } - ], - "fields": [ - { - "id": "1f44d55f-f161-4938-a659-f8026467f126", - "path": ["$.credentialSubject.dateWon"], - "purpose": "Get proof of win on date", # noqa: E501 - }, - ], - }, - } - ], - "id": str(uuid4()), - "format": {"ldp_vp": {"proof_type": ["Ed25519Signature2018"]}}, - }, - domain="test-degree", - ) - with section("Presentation summary", character="-"): - print(presentation_summary(alice_pres_ex.into(V20PresExRecord))) - - pause_for_input() - - with section("Issue BBS+ Credential"): - issuer_cred_ex, holder_cred_ex = await jsonld_issue_credential( - alice, - bob, - alice_conn.connection_id, - bob_conn.connection_id, - credential={ - "@context": [ - "https://www.w3.org/2018/credentials/v1", - { - "ex": "https://example.com/examples#", - "Employment": "ex:Employment", - "dateHired": "ex:dateHired", - "clearance": "ex:clearance", - }, - ], - "type": ["VerifiableCredential", "Employment"], - "issuer": bls_alice_did, - "issuanceDate": str(date.today()), - "credentialSubject": { - "id": bls_bob_did, - "dateHired": str(date.today()), - "clearance": 1, - }, - }, - options={"proofType": "BbsBlsSignature2020"}, - ) - - pause_for_input() - - with section("Present BBS+ Credential with SD"): - alice_pres_ex, bob_pres_ex = await jsonld_present_proof( - alice, - bob, - alice_conn.connection_id, - bob_conn.connection_id, - presentation_definition={ - "input_descriptors": [ - { - "id": "building_access_1", - "name": "BuildingAccess", - "schema": [ - { - "uri": "https://www.w3.org/2018/credentials#VerifiableCredential" # noqa: E501 - }, - {"uri": "https://example.com/examples#Employment"}, - ], - "constraints": { - "limit_disclosure": "required", - "is_holder": [ - { - "directive": "required", - "field_id": [ - "1f44d55f-f161-4938-a659-f8026467f126" - ], - } - ], - "fields": [ - { - "id": "1f44d55f-f161-4938-a659-f8026467f126", - "path": ["$.credentialSubject.clearance"], - "purpose": "Get clearance", # noqa: E501 - }, - ], - }, - } - ], - "id": str(uuid4()), - "format": {"ldp_vp": {"proof_type": ["BbsBlsSignature2020"]}}, - }, - domain="building-access", - ) - with section("Presentation summary", character="-"): - print(presentation_summary(alice_pres_ex.into(V20PresExRecord))) - - -if __name__ == "__main__": - logging_to_stdout() - asyncio.run(main()) diff --git a/scenarios/examples/mediation/docker-compose.yml b/scenarios/examples/mediation/docker-compose.yml deleted file mode 100644 index b6e9dbebbb..0000000000 --- a/scenarios/examples/mediation/docker-compose.yml +++ /dev/null @@ -1,105 +0,0 @@ - services: - alice: - image: acapy-test - ports: - - "3001:3001" - environment: - RUST_LOG: warn - command: > - start - --label Alice - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://alice:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --no-ledger - --wallet-type askar - --wallet-name alice - --wallet-key insecure - --auto-provision - --log-level debug - --debug-webhooks - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - - bob: - image: acapy-test - ports: - - "3002:3001" - environment: - RUST_LOG: warn - command: > - start - --label Bob - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://bob:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --no-ledger - --wallet-type askar - --wallet-name bob - --wallet-key insecure - --auto-provision - --log-level debug - --debug-webhooks - --monitor-revocation-notification - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - - mediator: - image: acapy-test - ports: - - "3003:3001" - environment: - RUST_LOG: warn - command: > - start - --label Mediator - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://mediator:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --no-ledger - --wallet-type askar - --wallet-name mediator - --wallet-key insecure - --auto-provision - --log-level debug - --debug-webhooks - --enable-undelivered-queue - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - - example: - container_name: controller - build: - context: ../.. - environment: - - ALICE=http://alice:3001 - - BOB=http://bob:3001 - - MEDIATOR=http://mediator:3001 - volumes: - - ./example.py:/usr/src/app/example.py:ro,z - command: python -m example - depends_on: - alice: - condition: service_healthy - bob: - condition: service_healthy - mediator: - condition: service_healthy diff --git a/scenarios/examples/mediation/example.py b/scenarios/examples/mediation/example.py deleted file mode 100644 index 3de69ad703..0000000000 --- a/scenarios/examples/mediation/example.py +++ /dev/null @@ -1,39 +0,0 @@ -"""Minimal reproducible example script. - -This script is for you to use to reproduce a bug or demonstrate a feature. -""" - -import asyncio -from os import getenv - -from acapy_controller import Controller -from acapy_controller.logging import logging_to_stdout -from acapy_controller.protocols import didexchange, request_mediation_v1, trustping - -ALICE = getenv("ALICE", "http://alice:3001") -BOB = getenv("BOB", "http://bob:3001") -MEDIATOR = getenv("MEDIATOR", "http://mediator:3001") - - -async def main(): - """Test Controller protocols.""" - alice = Controller(base_url=ALICE) - bob = Controller(base_url=BOB) - mediator = Controller(base_url=MEDIATOR) - - async with alice, bob, mediator: - ma, am = await didexchange(mediator, alice) - mam, amm = await request_mediation_v1( - mediator, alice, ma.connection_id, am.connection_id - ) - await alice.put(f"/mediation/{amm.mediation_id}/default-mediator") - ab, ba = await didexchange(alice, bob) - await trustping(alice, ab) - - ab, ba = await didexchange(alice, bob) - await trustping(alice, ab) - - -if __name__ == "__main__": - logging_to_stdout() - asyncio.run(main()) diff --git a/scenarios/examples/multitenancy/docker-compose.yml b/scenarios/examples/multitenancy/docker-compose.yml deleted file mode 100644 index 0a49d39a08..0000000000 --- a/scenarios/examples/multitenancy/docker-compose.yml +++ /dev/null @@ -1,61 +0,0 @@ - services: - agency: - image: acapy-test - ports: - - "3001:3001" - command: > - start - --label Agency - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://agency:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name agency - --wallet-key insecure - --auto-provision - --multitenant - --multitenant-admin - --jwt-secret insecure - --multitenancy-config wallet_type=single-wallet-askar key_derivation_method=RAW - --log-level debug - --debug-webhooks - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - depends_on: - tails: - condition: service_started - - example: - container_name: controller - build: - context: ../.. - environment: - - AGENCY=http://agency:3001 - volumes: - - ./example.py:/usr/src/app/example.py:ro,z - command: python -m example - depends_on: - agency: - condition: service_healthy - - tails: - image: ghcr.io/bcgov/tails-server:latest - ports: - - 6543:6543 - environment: - - GENESIS_URL=https://test.bcovrin.vonx.io/genesis - command: > - tails-server - --host 0.0.0.0 - --port 6543 - --storage-path /tmp/tails-files - --log-level INFO - diff --git a/scenarios/examples/multitenancy/example.py b/scenarios/examples/multitenancy/example.py deleted file mode 100644 index 2d8b2529c9..0000000000 --- a/scenarios/examples/multitenancy/example.py +++ /dev/null @@ -1,112 +0,0 @@ -"""Minimal reproducible example script. - -This script is for you to use to reproduce a bug or demonstrate a feature. -""" - -import asyncio -from os import getenv - -from acapy_controller import Controller -from acapy_controller.logging import logging_to_stdout -from acapy_controller.models import CreateWalletResponse -from acapy_controller.protocols import ( - DIDResult, - didexchange, - indy_anoncred_credential_artifacts, - indy_issue_credential_v2, - indy_present_proof_v2, - params, -) -from aiohttp import ClientSession - -AGENCY = getenv("AGENCY", "http://agency:3001") - - -async def main(): - """Test Controller protocols.""" - async with Controller(base_url=AGENCY) as agency: - alice = await agency.post( - "/multitenancy/wallet", - json={ - "label": "Alice", - "wallet_type": "askar", - }, - response=CreateWalletResponse, - ) - bob = await agency.post( - "/multitenancy/wallet", - json={ - "label": "Bob", - "wallet_type": "askar", - }, - response=CreateWalletResponse, - ) - - async with ( - Controller( - base_url=AGENCY, wallet_id=alice.wallet_id, subwallet_token=alice.token - ) as alice, - Controller( - base_url=AGENCY, wallet_id=bob.wallet_id, subwallet_token=bob.token - ) as bob, - ): - # Issuance prep - config = (await alice.get("/status/config"))["config"] - genesis_url = config.get("ledger.genesis_url") - public_did = (await alice.get("/wallet/did/public", response=DIDResult)).result - if not public_did: - public_did = ( - await alice.post( - "/wallet/did/create", - json={"method": "sov", "options": {"key_type": "ed25519"}}, - response=DIDResult, - ) - ).result - assert public_did - - async with ClientSession() as session: - register_url = genesis_url.replace("/genesis", "/register") - async with session.post( - register_url, - json={ - "did": public_did.did, - "verkey": public_did.verkey, - "alias": None, - "role": "ENDORSER", - }, - ) as resp: - assert resp.ok - - await alice.post("/wallet/did/public", params=params(did=public_did.did)) - _, cred_def = await indy_anoncred_credential_artifacts( - alice, - ["firstname", "lastname"], - support_revocation=True, - ) - - # Connecting - alice_conn, bob_conn = await didexchange(alice, bob) - - # Issue a credential - await indy_issue_credential_v2( - alice, - bob, - alice_conn.connection_id, - bob_conn.connection_id, - cred_def.credential_definition_id, - {"firstname": "Bob", "lastname": "Builder"}, - ) - - # Present the the credential's attributes - await indy_present_proof_v2( - bob, - alice, - bob_conn.connection_id, - alice_conn.connection_id, - requested_attributes=[{"name": "firstname"}], - ) - - -if __name__ == "__main__": - logging_to_stdout() - asyncio.run(main()) diff --git a/scenarios/examples/multiuse_invitations/docker-compose.yml b/scenarios/examples/multiuse_invitations/docker-compose.yml deleted file mode 100644 index 5011de3139..0000000000 --- a/scenarios/examples/multiuse_invitations/docker-compose.yml +++ /dev/null @@ -1,91 +0,0 @@ - services: - alice: - image: acapy-test - ports: - - "3001:3001" - environment: - RUST_LOG: 'aries-askar::log::target=error' - command: > - start - --label Alice - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://alice:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name alice - --wallet-key insecure - --auto-provision - --log-level debug - --debug-webhooks - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - depends_on: - tails: - condition: service_started - - bob: - image: acapy-test - ports: - - "3002:3001" - environment: - RUST_LOG: 'aries-askar::log::target=error' - command: > - start - --label Bob - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://bob:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name bob - --wallet-key insecure - --auto-provision - --log-level debug - --debug-webhooks - --monitor-revocation-notification - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - - tails: - image: ghcr.io/bcgov/tails-server:latest - ports: - - 6543:6543 - environment: - - GENESIS_URL=https://test.bcovrin.vonx.io/genesis - command: > - tails-server - --host 0.0.0.0 - --port 6543 - --storage-path /tmp/tails-files - --log-level INFO - - example: - container_name: controller - build: - context: ../.. - environment: - - ALICE=http://alice:3001 - - BOB=http://bob:3001 - volumes: - - ./example.py:/usr/src/app/example.py:ro,z - command: python -m example - depends_on: - alice: - condition: service_healthy - bob: - condition: service_healthy diff --git a/scenarios/examples/multiuse_invitations/example.py b/scenarios/examples/multiuse_invitations/example.py deleted file mode 100644 index 40a25536ae..0000000000 --- a/scenarios/examples/multiuse_invitations/example.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Minimal reproducible example script. - -This script is for you to use to reproduce a bug or demonstrate a feature. -""" - -import asyncio -from os import getenv - -from acapy_controller import Controller -from acapy_controller.logging import logging_to_stdout, section -from acapy_controller.protocols import didexchange, oob_invitation - -ALICE = getenv("ALICE", "http://alice:3001") -BOB = getenv("BOB", "http://bob:3001") - - -async def main(): - """Test Controller protocols.""" - async with Controller(base_url=ALICE) as alice, Controller(base_url=BOB) as bob: - invite = await oob_invitation(alice, multi_use=True) - with section("first"): - a1, _ = await didexchange(alice, bob, invite=invite) - a1 = a1.serialize() - assert a1["invitation_msg_id"] - with section("second"): - a2, _ = await didexchange(alice, bob, invite=invite) - a2 = a2.serialize() - assert a2["invitation_msg_id"] - assert a1["invitation_msg_id"] == a2["invitation_msg_id"] - - -if __name__ == "__main__": - logging_to_stdout() - asyncio.run(main()) diff --git a/scenarios/examples/presenting_revoked_credential/docker-compose.yml b/scenarios/examples/presenting_revoked_credential/docker-compose.yml deleted file mode 100644 index 83d481665f..0000000000 --- a/scenarios/examples/presenting_revoked_credential/docker-compose.yml +++ /dev/null @@ -1,89 +0,0 @@ - services: - alice: - image: acapy-test - ports: - - "3001:3001" - command: > - start - --label Alice - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://alice:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name alice - --wallet-key insecure - --auto-provision - --log-level debug - --debug-webhooks - --notify-revocation - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - depends_on: - tails: - condition: service_started - - bob: - image: acapy-test - ports: - - "3002:3001" - command: > - start - --label Bob - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://bob:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name bob - --wallet-key insecure - --auto-provision - --log-level debug - --debug-webhooks - --monitor-revocation-notification - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - - example: - container_name: controller - build: - context: ../.. - environment: - - ALICE=http://alice:3001 - - BOB=http://bob:3001 - volumes: - - ./example.py:/usr/src/app/example.py:ro,z - command: python -m example - depends_on: - alice: - condition: service_healthy - bob: - condition: service_healthy - - tails: - image: ghcr.io/bcgov/tails-server:latest - ports: - - 6543:6543 - environment: - - GENESIS_URL=https://test.bcovrin.vonx.io/genesis - command: > - tails-server - --host 0.0.0.0 - --port 6543 - --storage-path /tmp/tails-files - --log-level INFO - diff --git a/scenarios/examples/presenting_revoked_credential/example.py b/scenarios/examples/presenting_revoked_credential/example.py deleted file mode 100644 index 48aabed97b..0000000000 --- a/scenarios/examples/presenting_revoked_credential/example.py +++ /dev/null @@ -1,198 +0,0 @@ -"""Minimal reproducible example script. - -This script is for you to use to reproduce a bug or demonstrate a feature. -""" - -import asyncio -import json -import time -from os import getenv - -from acapy_controller import Controller -from acapy_controller.logging import logging_to_stdout -from acapy_controller.models import V20PresExRecord, V20PresExRecordList -from acapy_controller.protocols import ( - DIDResult, - anoncreds_publish_revocation, - anoncreds_revoke, - didexchange, - indy_anoncred_credential_artifacts, - indy_issue_credential_v2, - indy_present_proof_v2, - params, -) -from aiohttp import ClientSession - -ALICE = getenv("ALICE", "http://alice:3001") -BOB = getenv("BOB", "http://bob:3001") - - -def summary(presentation: V20PresExRecord) -> str: - """Summarize a presentation exchange record.""" - request = presentation.pres_request - return "Summary: " + json.dumps( - { - "state": presentation.state, - "verified": presentation.verified, - "presentation_request": request.dict(by_alias=True) if request else None, - }, - indent=2, - sort_keys=True, - ) - - -async def main(): - """Test Controller protocols.""" - async with Controller(base_url=ALICE) as alice, Controller(base_url=BOB) as bob: - # Connecting - alice_conn, bob_conn = await didexchange(alice, bob) - - # Issuance prep - config = (await alice.get("/status/config"))["config"] - genesis_url = config.get("ledger.genesis_url") - public_did = (await alice.get("/wallet/did/public", response=DIDResult)).result - if not public_did: - public_did = ( - await alice.post( - "/wallet/did/create", - json={"method": "sov", "options": {"key_type": "ed25519"}}, - response=DIDResult, - ) - ).result - assert public_did - - async with ClientSession() as session: - register_url = genesis_url.replace("/genesis", "/register") - async with session.post( - register_url, - json={ - "did": public_did.did, - "verkey": public_did.verkey, - "alias": None, - "role": "ENDORSER", - }, - ) as resp: - assert resp.ok - - await alice.post("/wallet/did/public", params=params(did=public_did.did)) - schema, cred_def = await indy_anoncred_credential_artifacts( - alice, - ["firstname", "lastname"], - support_revocation=True, - ) - - # Issue a credential - alice_cred_ex, _ = await indy_issue_credential_v2( - alice, - bob, - alice_conn.connection_id, - bob_conn.connection_id, - cred_def.credential_definition_id, - {"firstname": "Bob", "lastname": "Builder"}, - ) - issued_time = int(time.time()) - - # Present the the credential's attributes - await indy_present_proof_v2( - bob, - alice, - bob_conn.connection_id, - alice_conn.connection_id, - requested_attributes=[{"name": "firstname"}], - ) - - # Revoke credential - await anoncreds_revoke( - alice, - cred_ex=alice_cred_ex, - holder_connection_id=alice_conn.connection_id, - notify=True, - ) - await anoncreds_publish_revocation(alice, cred_ex=alice_cred_ex) - # TODO: Make this into a helper in protocols.py? - await bob.record(topic="revocation-notification") - revoked_time = int(time.time()) - - # Request proof from holder again after revoking, - # using the interval before cred revoked - await indy_present_proof_v2( - bob, - alice, - bob_conn.connection_id, - alice_conn.connection_id, - requested_attributes=[ - { - "name": "firstname", - "restrictions": [{"cred_def_id": cred_def.credential_definition_id}], - } - ], - non_revoked={"from": issued_time, "to": issued_time}, - ) - - # Request proof, no interval - await indy_present_proof_v2( - bob, - alice, - bob_conn.connection_id, - alice_conn.connection_id, - requested_attributes=[ - { - "name": "firstname", - "restrictions": [{"cred_def_id": cred_def.credential_definition_id}], - } - ], - ) - - # Request proof, using invalid/revoked interval but using - # local non_revoked override (in requsted attrs) - # ("LOCAL"-->requested attrs) - await indy_present_proof_v2( - bob, - alice, - bob_conn.connection_id, - alice_conn.connection_id, - requested_attributes=[ - { - "name": "firstname", - "restrictions": [{"cred_def_id": cred_def.credential_definition_id}], - "non_revoked": { - "from": issued_time, - "to": issued_time, - }, - } - ], - non_revoked={"from": revoked_time - 1, "to": revoked_time}, - ) - - # Request proof, just local invalid interval - await indy_present_proof_v2( - bob, - alice, - bob_conn.connection_id, - alice_conn.connection_id, - requested_attributes=[ - { - "name": "firstname", - "restrictions": [{"cred_def_id": cred_def.credential_definition_id}], - "non_revoked": { - "from": revoked_time, - "to": revoked_time, - }, - } - ], - ) - - # Query presentations - presentations = await alice.get( - "/present-proof-2.0/records", - response=V20PresExRecordList, - ) - - # Presentation summary - for i, pres in enumerate(presentations.results): - print(summary(pres)) - - -if __name__ == "__main__": - logging_to_stdout() - asyncio.run(main()) diff --git a/scenarios/examples/restart_anoncreds_upgrade/docker-compose.yml b/scenarios/examples/restart_anoncreds_upgrade/docker-compose.yml deleted file mode 100644 index 110cb64ecf..0000000000 --- a/scenarios/examples/restart_anoncreds_upgrade/docker-compose.yml +++ /dev/null @@ -1,208 +0,0 @@ -services: - wallet-db: - image: postgres:12 - environment: - - POSTGRES_USER=DB_USER - - POSTGRES_PASSWORD=DB_PASSWORD - ports: - - 5433:5432 - healthcheck: - test: ["CMD-SHELL", "pg_isready -U DB_USER"] - interval: 10s - retries: 5 - start_period: 30s - timeout: 10s - - alice: - image: acapy-test - ports: - - "3001:3001" - environment: - RUST_LOG: 'aries-askar::log::target=error' - command: > - start - --label Alice - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://alice:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name alice - --wallet-key insecure - --wallet-storage-type "postgres_storage" - --wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5}" - --wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}" - --auto-provision - --log-level debug - --debug-webhooks - --notify-revocation - --preserve-exchange-records - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - depends_on: - tails: - condition: service_started - wallet-db: - condition: service_healthy - - bob-askar: - image: acapy-test - ports: - - "3002:3001" - environment: - RUST_LOG: 'aries-askar::log::target=error' - command: > - start - --label bob-askar - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://bob-askar:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name bob-askar - --wallet-key insecure - --wallet-storage-type "postgres_storage" - --wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5}" - --wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}" - --auto-provision - --log-level debug - --debug-webhooks - --monitor-revocation-notification - --preserve-exchange-records - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - depends_on: - tails: - condition: service_started - wallet-db: - condition: service_healthy - - bob-anoncreds: - image: acapy-test - ports: - - "3003:3001" - environment: - RUST_LOG: 'aries-askar::log::target=error' - command: > - start - --label bob-anoncreds - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://bob-anoncreds:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar-anoncreds - --wallet-name bob-anoncreds - --wallet-key insecure - --wallet-storage-type "postgres_storage" - --wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5}" - --wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}" - --auto-provision - --log-level debug - --debug-webhooks - --monitor-revocation-notification - --preserve-exchange-records - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - depends_on: - tails: - condition: service_started - wallet-db: - condition: service_healthy - - bob-askar-anon: - image: acapy-test - ports: - - "3004:3001" - environment: - RUST_LOG: 'aries-askar::log::target=error' - command: > - start - --label bob-askar-anon - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://bob-askar-anon:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name bob-askar-anon - --wallet-key insecure - --wallet-storage-type "postgres_storage" - --wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5}" - --wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}" - --auto-provision - --log-level debug - --debug-webhooks - --monitor-revocation-notification - --preserve-exchange-records - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - depends_on: - tails: - condition: service_started - wallet-db: - condition: service_healthy - - tails: - image: ghcr.io/bcgov/tails-server:latest - ports: - - 6543:6543 - environment: - - GENESIS_URL=https://test.bcovrin.vonx.io/genesis - command: > - tails-server - --host 0.0.0.0 - --port 6543 - --storage-path /tmp/tails-files - --log-level INFO - - example: - container_name: controller - privileged: true - build: - context: ../.. - environment: - - DOCKER_HOST=unix:///var/run/docker.sock - - ALICE=http://alice:3001 - - BOB_ASKAR=http://bob-askar:3001 - - BOB_ANONCREDS=http://bob-anoncreds:3001 - - BOB_ASKAR_ANON=http://bob-askar-anon:3001 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - - ./example.py:/usr/src/app/example.py:ro,z - command: python -m example - depends_on: - alice: - condition: service_healthy - bob-askar: - condition: service_healthy - bob-anoncreds: - condition: service_healthy - bob-askar-anon: - condition: service_healthy diff --git a/scenarios/examples/restart_anoncreds_upgrade/example.py b/scenarios/examples/restart_anoncreds_upgrade/example.py deleted file mode 100644 index cc272c1d11..0000000000 --- a/scenarios/examples/restart_anoncreds_upgrade/example.py +++ /dev/null @@ -1,500 +0,0 @@ -"""Minimal reproducible example script. - -This script is for you to use to reproduce a bug or demonstrate a feature. -""" - -import asyncio -import json -from os import getenv - -from acapy_controller import Controller -from acapy_controller.logging import logging_to_stdout -from acapy_controller.protocols import ( - didexchange, - indy_anoncred_credential_artifacts, - indy_anoncred_onboard, -) -from examples.util import ( - Settings, - anoncreds_issue_credential_v2, - anoncreds_present_proof_v2, - get_wallet_name, - update_wallet_type, - wait_until_healthy, -) - -import docker - -ALICE = getenv("ALICE", "http://alice:3001") -BOB_ASKAR = getenv("BOB_ASKAR", "http://bob-askar:3001") -BOB_ANONCREDS = getenv("BOB_ANONCREDS", "http://bob-anoncreds:3001") -BOB_ASKAR_ANON = getenv("BOB_ASKAR_ANON", "http://bob-askar-anon:3001") - - -async def connect_agents_and_issue_credentials( - inviter: Controller, - invitee: Controller, - inviter_cred_def, - fname: str, - lname: str, - inviter_conn=None, - invitee_conn=None, -): - is_inviter_anoncreds = (await inviter.get("/settings", response=Settings)).get( - "wallet.type" - ) == "askar-anoncreds" - - # connect the 2 agents - if (not inviter_conn) or (not invitee_conn): - print(">>> connecting agents ...") - (inviter_conn, invitee_conn) = await didexchange(inviter, invitee) - - # Issue a credential - print(">>> issue credential ...") - inviter_cred_ex, _ = await anoncreds_issue_credential_v2( - inviter, - invitee, - inviter_conn.connection_id, - invitee_conn.connection_id, - {"firstname": fname, "lastname": lname}, - inviter_cred_def.credential_definition_id, - ) - - # Present the the credential's attributes - print(">>> present proof ...") - await anoncreds_present_proof_v2( - invitee, - inviter, - invitee_conn.connection_id, - inviter_conn.connection_id, - requested_attributes=[{"name": "firstname"}], - ) - - # Revoke credential - if is_inviter_anoncreds: - await inviter.post( - url="/anoncreds/revocation/revoke", # TODO need to check agent type (askar vs anoncreds) - json={ - "connection_id": inviter_conn.connection_id, - "rev_reg_id": inviter_cred_ex.details.rev_reg_id, - "cred_rev_id": inviter_cred_ex.details.cred_rev_id, - "publish": True, - "notify": True, - "notify_version": "v1_0", - }, - ) - await invitee.record(topic="revocation-notification") - else: - await inviter.post( - url="/revocation/revoke", # TODO need to check agent type (askar vs anoncreds) - json={ - "connection_id": inviter_conn.connection_id, - "rev_reg_id": inviter_cred_ex.details.rev_reg_id, - "cred_rev_id": inviter_cred_ex.details.cred_rev_id, - "publish": True, - "notify": True, - "notify_version": "v1_0", - }, - ) - await invitee.record(topic="revocation-notification") - - # Issue a second credential - print(">>> issue credential ...") - inviter_cred_ex, _ = await anoncreds_issue_credential_v2( - inviter, - invitee, - inviter_conn.connection_id, - invitee_conn.connection_id, - {"firstname": f"{fname}2", "lastname": f"{lname}2"}, - inviter_cred_def.credential_definition_id, - ) - print(">>> Done!") - - return (inviter_conn, invitee_conn) - - -async def verify_schema_cred_def(issuer, schema_count, cred_def_count): - is_issuer_anoncreds = (await issuer.get("/settings", response=Settings)).get( - "wallet.type" - ) == "askar-anoncreds" - - if is_issuer_anoncreds: - schemas = await issuer.get("/anoncreds/schemas") - assert schema_count == len(schemas["schema_ids"]) - - cred_defs = await issuer.get("/anoncreds/credential-definitions") - assert cred_def_count == len(cred_defs["credential_definition_ids"]) - else: - schemas = await issuer.get("/schemas/created") - assert schema_count == len(schemas["schema_ids"]) - - cred_defs = await issuer.get("/credential-definitions/created") - assert cred_def_count == len(cred_defs["credential_definition_ids"]) - - -async def verify_issued_credentials(issuer, issued_cred_count, revoked_cred_count): - is_issuer_anoncreds = (await issuer.get("/settings", response=Settings)).get( - "wallet.type" - ) == "askar-anoncreds" - - cred_exch_recs = await issuer.get("/issue-credential-2.0/records") - cred_exch_recs = cred_exch_recs["results"] - assert len(cred_exch_recs) == issued_cred_count - registries = {} - active_creds = 0 - revoked_creds = 0 - for cred_exch in cred_exch_recs: - cred_type = ( - "indy" - if "indy" in cred_exch - and cred_exch["indy"] - and "rev_reg_id" in cred_exch["indy"] - else "anoncreds" - ) - rev_reg_id = cred_exch[cred_type]["rev_reg_id"] - cred_rev_id = cred_exch[cred_type]["cred_rev_id"] - cred_rev_id = int(cred_rev_id) - if rev_reg_id not in registries: - if is_issuer_anoncreds: - registries[rev_reg_id] = await issuer.get( - f"/anoncreds/revocation/registry/{rev_reg_id}/issued/indy_recs", - ) - else: - registries[rev_reg_id] = await issuer.get( - f"/revocation/registry/{rev_reg_id}/issued/indy_recs", - ) - registry = registries[rev_reg_id] - if cred_rev_id in registry["rev_reg_delta"]["value"]["revoked"]: - revoked_creds = revoked_creds + 1 - else: - active_creds = active_creds + 1 - assert revoked_creds == revoked_cred_count - assert (revoked_creds + active_creds) == issued_cred_count - - -async def verify_recd_credentials(holder, active_cred_count, revoked_cred_count): - is_holder_anoncreds = (await holder.get("/settings", response=Settings)).get( - "wallet.type" - ) == "askar-anoncreds" - - credentials = await holder.get("/credentials") - credentials = credentials["results"] - assert len(credentials) == (active_cred_count + revoked_cred_count) - registries = {} - active_creds = 0 - revoked_creds = 0 - for credential in credentials: - rev_reg_id = credential["rev_reg_id"] - cred_rev_id = int(credential["cred_rev_id"]) - if rev_reg_id not in registries: - if is_holder_anoncreds: - registries[rev_reg_id] = await holder.get( - f"/anoncreds/revocation/registry/{rev_reg_id}/issued/indy_recs", - ) - else: - registries[rev_reg_id] = await holder.get( - f"/revocation/registry/{rev_reg_id}/issued/indy_recs", - ) - registry = registries[rev_reg_id] - if cred_rev_id in registry["rev_reg_delta"]["value"]["revoked"]: - revoked_creds = revoked_creds + 1 - else: - active_creds = active_creds + 1 - assert revoked_creds == revoked_cred_count - assert active_creds == active_cred_count - - -async def verify_recd_presentations(verifier, recd_pres_count): - presentations = await verifier.get("/present-proof-2.0/records") - presentations = presentations["results"] - - assert recd_pres_count == len(presentations) - - -async def upgrade_wallet_and_shutdown_container( - client, - agent_controller, - agent_container, -): - agent_command = agent_container.attrs["Config"]["Cmd"] - - # command is a List, find the wallet type and replace "askar" with "askar-anoncreds" - correct_wallet_type = update_wallet_type(agent_command, "askar-anoncreds") - wallet_name = get_wallet_name(agent_command) - - # call the wallet upgrade endpoint to upgrade to askar-anoncreds - await agent_controller.post( - "/anoncreds/wallet/upgrade", - params={ - "wallet_name": wallet_name, - }, - ) - - # Wait for the upgrade ... - await asyncio.sleep(2) - - print(">>> waiting for container to exit ...") - agent_id = agent_container.attrs["Id"] - wait_until_healthy(client, agent_id, is_healthy=False) - agent_container.remove() - - return agent_command - - -def start_new_container( - client, - agent_command, - agent_container, - agent_label, -): - print(">>> start new container ...") - new_agent_container = client.containers.run( - "acapy-test", - command=agent_command, - detach=True, - environment={"RUST_LOG": "aries-askar::log::target=error"}, - healthcheck=agent_container.attrs["Config"]["Healthcheck"], - name=agent_label, - network=agent_container.attrs["HostConfig"]["NetworkMode"], - ports=agent_container.attrs["NetworkSettings"]["Ports"], - ) - print(">>> new container:", agent_label, json.dumps(new_agent_container.attrs)) - new_agent_id = new_agent_container.attrs["Id"] - - wait_until_healthy(client, new_agent_id) - print(">>> new container is healthy") - - return (new_agent_container, new_agent_id) - - -def stop_and_remove_container(client, agent_id): - # cleanup - shut down agent (not part of docker compose) - print(">>> shut down agent ...") - agent_container = client.containers.get(agent_id) - agent_container.stop() - wait_until_healthy(client, agent_id, is_healthy=False) - agent_container.remove() - - -async def main(): - """Test Controller protocols.""" - async with Controller(base_url=ALICE) as alice: - # setup alice as an issuer - print(">>> setting up alice as issuer ...") - await indy_anoncred_onboard(alice) - schema, cred_def = await indy_anoncred_credential_artifacts( - alice, - ["firstname", "lastname"], - support_revocation=True, - revocation_registry_size=5, - ) - - # confirm alice has 1 schema and 1 cred def - await verify_schema_cred_def(alice, 1, 1) - - alice_conns = {} - bob_conns = {} - async with ( - Controller(base_url=ALICE) as alice, - Controller(base_url=BOB_ASKAR) as bob, - ): - # connect to Bob (Askar wallet) and issue (and revoke) some credentials - (alice_conn, bob_conn) = await connect_agents_and_issue_credentials( - alice, - bob, - cred_def, - "Bob", - "Askar", - ) - alice_conns["askar"] = alice_conn - bob_conns["askar"] = bob_conn - await verify_recd_credentials(bob, 1, 1) - - async with ( - Controller(base_url=ALICE) as alice, - Controller(base_url=BOB_ANONCREDS) as bob, - ): - # connect to Bob (AnonCreds wallet) and issue (and revoke) some credentials - (alice_conn, bob_conn) = await connect_agents_and_issue_credentials( - alice, - bob, - cred_def, - "Bob", - "AnonCreds", - ) - alice_conns["anoncreds"] = alice_conn - bob_conns["anoncreds"] = bob_conn - await verify_recd_credentials(bob, 1, 1) - - async with ( - Controller(base_url=ALICE) as alice, - Controller(base_url=BOB_ASKAR_ANON) as bob, - ): - # connect to Bob (Askar wallet which will be upgraded) and issue (and revoke) some credentials - (alice_conn, bob_conn) = await connect_agents_and_issue_credentials( - alice, - bob, - cred_def, - "Bob", - "Askar_Anon", - ) - alice_conns["askar-anon"] = alice_conn - bob_conns["askar-anon"] = bob_conn - await verify_recd_credentials(bob, 1, 1) - await verify_issued_credentials(alice, 6, 3) - await verify_recd_presentations(alice, 3) - - # at this point alice has issued 6 credentials (revocation registry size is 5) and revoked 3 - # TODO verify counts of credentials, revocations etc for each agent - - # play with docker - get a list of all our running containers - client = docker.from_env() - containers = client.containers.list(all=True) - docker_containers = {} - for container in containers: - if "com.docker.compose.service" in container.attrs["Config"]["Labels"]: - container_name = container.attrs["Config"]["Labels"][ - "com.docker.compose.service" - ] - container_id = container.attrs["Id"] - container_is_running = container.attrs["State"]["Running"] - docker_containers[container_name] = { - "Id": container_id, - "Running": container_is_running, - } - print(">>> container:", container_name, docker_containers[container_name]) - - alice_docker_container = docker_containers["alice"] - alice_container = client.containers.get(alice_docker_container["Id"]) - async with Controller(base_url=ALICE) as alice: - alice_command = await upgrade_wallet_and_shutdown_container( - client, - alice, - alice_container, - ) - - bob_docker_container = docker_containers["bob-askar-anon"] - bob_container = client.containers.get(bob_docker_container["Id"]) - async with Controller(base_url=BOB_ASKAR_ANON) as bob: - bob_command = await upgrade_wallet_and_shutdown_container( - client, - bob, - bob_container, - ) - - new_alice_container = None - alice_id = None - new_bob_container = None - bob_id = None - try: - (new_alice_container, alice_id) = start_new_container( - client, - alice_command, - alice_container, - "alice", - ) - - (new_bob_container, bob_id) = start_new_container( - client, - bob_command, - bob_container, - "bob-askar-anon", - ) - - # TODO verify counts of credentials, revocations etc for each upgraded agent - async with ( - Controller(base_url=ALICE) as alice, - Controller(base_url=BOB_ASKAR_ANON) as bob, - ): - await verify_schema_cred_def(alice, 1, 1) - - # run some more tests ... alice should still be connected to bob for example ... - async with ( - Controller(base_url=ALICE) as alice, - Controller(base_url=BOB_ANONCREDS) as bob, - ): - # Present the the credential's attributes - print(">>> present proof ... again ...") - await anoncreds_present_proof_v2( - bob, - alice, - bob_conns["anoncreds"].connection_id, - alice_conns["anoncreds"].connection_id, - requested_attributes=[{"name": "firstname"}], - ) - await connect_agents_and_issue_credentials( - alice, - bob, - cred_def, - "Bob", - "AnonCreds", - inviter_conn=alice_conns["anoncreds"], - invitee_conn=bob_conns["anoncreds"], - ) - await verify_recd_credentials(bob, 2, 2) - print(">>> Done! (again)") - - async with ( - Controller(base_url=ALICE) as alice, - Controller(base_url=BOB_ASKAR_ANON) as bob, - ): - # Present the the credential's attributes - print(">>> present proof ... again ...") - await anoncreds_present_proof_v2( - bob, - alice, - bob_conns["askar-anon"].connection_id, - alice_conns["askar-anon"].connection_id, - requested_attributes=[{"name": "firstname"}], - ) - await connect_agents_and_issue_credentials( - alice, - bob, - cred_def, - "Bob", - "Askar_Anon", - inviter_conn=alice_conns["askar-anon"], - invitee_conn=bob_conns["askar-anon"], - ) - await verify_recd_credentials(bob, 2, 2) - print(">>> Done! (again)") - - async with ( - Controller(base_url=ALICE) as alice, - Controller(base_url=BOB_ASKAR) as bob, - ): - # Present the the credential's attributes - print(">>> present proof ... again ...") - await anoncreds_present_proof_v2( - bob, - alice, - bob_conns["askar"].connection_id, - alice_conns["askar"].connection_id, - requested_attributes=[{"name": "firstname"}], - ) - await connect_agents_and_issue_credentials( - alice, - bob, - cred_def, - "Bob", - "Askar", - inviter_conn=alice_conns["askar"], - invitee_conn=bob_conns["askar"], - ) - await verify_recd_credentials(bob, 2, 2) - await verify_issued_credentials(alice, 12, 6) - await verify_recd_presentations(alice, 9) - print(">>> Done! (again)") - - finally: - if alice_id and new_alice_container: - # cleanup - shut down alice agent (not part of docker compose) - stop_and_remove_container(client, alice_id) - if bob_id and new_bob_container: - # cleanup - shut down bob agent (not part of docker compose) - stop_and_remove_container(client, bob_id) - - -if __name__ == "__main__": - logging_to_stdout() - asyncio.run(main()) diff --git a/scenarios/examples/self_attested/docker-compose.yml b/scenarios/examples/self_attested/docker-compose.yml deleted file mode 100644 index bda79e1f60..0000000000 --- a/scenarios/examples/self_attested/docker-compose.yml +++ /dev/null @@ -1,88 +0,0 @@ - services: - alice: - image: acapy-test - ports: - - "3001:3001" - command: > - start - --label Alice - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://alice:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name alice - --wallet-key insecure - --auto-provision - --log-level debug - --debug-webhooks - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - depends_on: - tails: - condition: service_started - - bob: - image: acapy-test - ports: - - "3002:3001" - command: > - start - --label Bob - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://bob:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name bob - --wallet-key insecure - --auto-provision - --log-level debug - --debug-webhooks - --monitor-revocation-notification - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - - example: - container_name: controller - build: - context: ../.. - environment: - - ALICE=http://alice:3001 - - BOB=http://bob:3001 - volumes: - - ./example.py:/usr/src/app/example.py:ro,z - command: python -m example - depends_on: - alice: - condition: service_healthy - bob: - condition: service_healthy - - tails: - image: ghcr.io/bcgov/tails-server:latest - ports: - - 6543:6543 - environment: - - GENESIS_URL=https://test.bcovrin.vonx.io/genesis - command: > - tails-server - --host 0.0.0.0 - --port 6543 - --storage-path /tmp/tails-files - --log-level INFO - diff --git a/scenarios/examples/self_attested/example.py b/scenarios/examples/self_attested/example.py deleted file mode 100644 index f1be99aa47..0000000000 --- a/scenarios/examples/self_attested/example.py +++ /dev/null @@ -1,180 +0,0 @@ -"""Minimal reproducible example script. - -This script is for you to use to reproduce a bug or demonstrate a feature. -""" - -import asyncio -from os import getenv -from secrets import randbelow -from typing import List -from uuid import uuid4 - -from acapy_controller import Controller -from acapy_controller.logging import logging_to_stdout -from acapy_controller.models import V10PresentationExchange -from acapy_controller.protocols import ( - DIDResult, - IndyCredPrecis, - anoncreds_auto_select_credentials_for_presentation_request, - didexchange, - indy_anoncred_credential_artifacts, - indy_issue_credential_v2, - params, -) -from aiohttp import ClientSession - -ALICE = getenv("ALICE", "http://alice:3001") -BOB = getenv("BOB", "http://bob:3001") - - -async def main(): - """Test Controller protocols.""" - async with Controller(base_url=ALICE) as alice, Controller(base_url=BOB) as bob: - # Connecting - alice_conn, bob_conn = await didexchange(alice, bob) - - # Issuance prep - config = (await alice.get("/status/config"))["config"] - genesis_url = config.get("ledger.genesis_url") - public_did = (await alice.get("/wallet/did/public", response=DIDResult)).result - if not public_did: - public_did = ( - await alice.post( - "/wallet/did/create", - json={"method": "sov", "options": {"key_type": "ed25519"}}, - response=DIDResult, - ) - ).result - assert public_did - - async with ClientSession() as session: - register_url = genesis_url.replace("/genesis", "/register") - async with session.post( - register_url, - json={ - "did": public_did.did, - "verkey": public_did.verkey, - "alias": None, - "role": "ENDORSER", - }, - ) as resp: - assert resp.ok - - await alice.post("/wallet/did/public", params=params(did=public_did.did)) - schema, cred_def = await indy_anoncred_credential_artifacts( - alice, - ["firstname", "lastname"], - support_revocation=True, - ) - schema, cred_def_age = await indy_anoncred_credential_artifacts( - alice, - ["age"], - support_revocation=True, - ) - - # Issue a credential - await indy_issue_credential_v2( - alice, - bob, - alice_conn.connection_id, - bob_conn.connection_id, - cred_def.credential_definition_id, - {"firstname": "Bob", "lastname": "Builder"}, - ) - await indy_issue_credential_v2( - alice, - bob, - alice_conn.connection_id, - bob_conn.connection_id, - cred_def_age.credential_definition_id, - {"age": "42"}, - ) - - # Present the thing - self_uuid = str(uuid4()) - alice_pres_ex = await alice.post( - "/present-proof/send-request", - json={ - "auto_verify": False, - "comment": "Presentation request from minimal", - "connection_id": alice_conn.connection_id, - "proof_request": { - "name": "proof", - "version": "0.1.0", - "nonce": str(randbelow(10**10)), - "requested_attributes": { - str(uuid4()): { - "name": "firstname", - "restrictions": [ - {"cred_def_id": cred_def.credential_definition_id} - ], - }, - str(uuid4()): { - "name": "age", - "restrictions": [ - {"cred_def_id": cred_def_age.credential_definition_id} - ], - }, - self_uuid: {"name": "self-attested"}, - }, - "requested_predicates": {}, - "non_revoked": None, - }, - "trace": False, - }, - response=V10PresentationExchange, - ) - alice_pres_ex_id = alice_pres_ex.presentation_exchange_id - - bob_pres_ex = await bob.record_with_values( - topic="present_proof", - record_type=V10PresentationExchange, - connection_id=bob_conn.connection_id, - state="request_received", - ) - assert bob_pres_ex.presentation_request - bob_pres_ex_id = bob_pres_ex.presentation_exchange_id - - relevant_creds = await bob.get( - f"/present-proof/records/{bob_pres_ex_id}/credentials", - response=List[IndyCredPrecis], - ) - pres_spec = anoncreds_auto_select_credentials_for_presentation_request( - bob_pres_ex.presentation_request.serialize(), relevant_creds - ) - pres_spec.self_attested_attributes = {self_uuid: "self-attested data goes here"} - bob_pres_ex = await bob.post( - f"/present-proof/records/{bob_pres_ex_id}/send-presentation", - json=pres_spec, - response=V10PresentationExchange, - ) - - await alice.record_with_values( - topic="present_proof", - record_type=V10PresentationExchange, - presentation_exchange_id=alice_pres_ex_id, - state="presentation_received", - ) - alice_pres_ex = await alice.post( - f"/present-proof/records/{alice_pres_ex_id}/verify-presentation", - json={}, - response=V10PresentationExchange, - ) - alice_pres_ex = await alice.record_with_values( - topic="present_proof", - record_type=V10PresentationExchange, - presentation_exchange_id=alice_pres_ex_id, - state="verified", - ) - - bob_pres_ex = await bob.record_with_values( - topic="present_proof", - record_type=V10PresentationExchange, - presentation_exchange_id=bob_pres_ex_id, - state="presentation_acked", - ) - - -if __name__ == "__main__": - logging_to_stdout() - asyncio.run(main()) diff --git a/scenarios/examples/simple/docker-compose.yml b/scenarios/examples/simple/docker-compose.yml deleted file mode 100644 index ea27497181..0000000000 --- a/scenarios/examples/simple/docker-compose.yml +++ /dev/null @@ -1,92 +0,0 @@ - services: - alice: - image: acapy-test - ports: - - "3001:3001" - environment: - RUST_LOG: 'aries-askar::log::target=error' - command: > - start - --label Alice - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://alice:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name alice - --wallet-key insecure - --auto-provision - --log-level debug - --debug-webhooks - --universal-resolver - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 50s - interval: 7s - timeout: 5s - retries: 10 - depends_on: - tails: - condition: service_started - - bob: - image: acapy-test - ports: - - "3002:3001" - environment: - RUST_LOG: 'aries-askar::log::target=error' - command: > - start - --label Bob - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://bob:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name bob - --wallet-key insecure - --auto-provision - --log-level debug - --debug-webhooks - --monitor-revocation-notification - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - - tails: - image: ghcr.io/bcgov/tails-server:latest - ports: - - 6543:6543 - environment: - - GENESIS_URL=https://test.bcovrin.vonx.io/genesis - command: > - tails-server - --host 0.0.0.0 - --port 6543 - --storage-path /tmp/tails-files - --log-level INFO - - example: - container_name: controller - build: - context: ../.. - environment: - - ALICE=http://alice:3001 - - BOB=http://bob:3001 - volumes: - - ./example.py:/usr/src/app/example.py:ro,z - command: python -m example - depends_on: - alice: - condition: service_healthy - bob: - condition: service_healthy diff --git a/scenarios/examples/simple/example.py b/scenarios/examples/simple/example.py deleted file mode 100644 index a41994e569..0000000000 --- a/scenarios/examples/simple/example.py +++ /dev/null @@ -1,25 +0,0 @@ -"""Minimal reproducible example script. - -This script is for you to use to reproduce a bug or demonstrate a feature. -""" - -import asyncio -from os import getenv - -from acapy_controller import Controller -from acapy_controller.logging import logging_to_stdout -from acapy_controller.protocols import didexchange - -ALICE = getenv("ALICE", "http://alice:3001") -BOB = getenv("BOB", "http://bob:3001") - - -async def main(): - """Test Controller protocols.""" - async with Controller(base_url=ALICE) as alice, Controller(base_url=BOB) as bob: - await didexchange(alice, bob) - - -if __name__ == "__main__": - logging_to_stdout() - asyncio.run(main()) diff --git a/scenarios/examples/simple_restart/docker-compose.yml b/scenarios/examples/simple_restart/docker-compose.yml deleted file mode 100644 index 78e0d8d511..0000000000 --- a/scenarios/examples/simple_restart/docker-compose.yml +++ /dev/null @@ -1,163 +0,0 @@ -services: - wallet-db: - image: postgres:12 - environment: - - POSTGRES_USER=DB_USER - - POSTGRES_PASSWORD=DB_PASSWORD - ports: - - 5433:5432 - healthcheck: - test: ["CMD-SHELL", "pg_isready -U DB_USER"] - interval: 10s - retries: 5 - start_period: 30s - timeout: 10s - - alice: - image: bcgovimages/aries-cloudagent:py3.12_1.0.1 - ports: - - "3001:3001" - environment: - RUST_LOG: 'aries-askar::log::target=error' - command: > - start - --label Alice - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://alice:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name alice - --wallet-key insecure - --wallet-storage-type "postgres_storage" - --wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5}" - --wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}" - --auto-provision - --log-level debug - --debug-webhooks - --preserve-exchange-records - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - depends_on: - tails: - condition: service_started - wallet-db: - condition: service_healthy - - bob: - image: acapy-test - ports: - - "3002:3001" - environment: - RUST_LOG: 'aries-askar::log::target=error' - command: > - start - --label Bob - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://bob:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name bob - --wallet-key insecure - --wallet-storage-type "postgres_storage" - --wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5}" - --wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}" - --auto-provision - --log-level debug - --debug-webhooks - --monitor-revocation-notification - --preserve-exchange-records - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - depends_on: - tails: - condition: service_started - wallet-db: - condition: service_healthy - - agency: - image: bcgovimages/aries-cloudagent:py3.12_1.0.1 - ports: - - "3003:3001" - command: > - start - --label Agency - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://agency:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --tails-server-base-url http://tails:6543 - --genesis-url https://test.bcovrin.vonx.io/genesis - --wallet-type askar - --wallet-name agency - --wallet-key insecure - --auto-provision - --multitenant - --multitenant-admin - --jwt-secret insecure - --multitenancy-config wallet_type=single-wallet-askar key_derivation_method=RAW - --wallet-storage-type "postgres_storage" - --wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5}" - --wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}" - --log-level info - --debug-webhooks - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - depends_on: - tails: - condition: service_started - - tails: - image: ghcr.io/bcgov/tails-server:latest - ports: - - 6543:6543 - environment: - - GENESIS_URL=https://test.bcovrin.vonx.io/genesis - command: > - tails-server - --host 0.0.0.0 - --port 6543 - --storage-path /tmp/tails-files - --log-level INFO - - example: - container_name: controller - privileged: true - build: - context: ../.. - environment: - - DOCKER_HOST=unix:///var/run/docker.sock - - ALICE=http://alice:3001 - - BOB=http://bob:3001 - - AGENCY=http://agency:3001 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - - ./example.py:/usr/src/app/example.py:ro,z - command: python -m example - depends_on: - alice: - condition: service_healthy - bob: - condition: service_healthy - agency: - condition: service_healthy diff --git a/scenarios/examples/simple_restart/example.py b/scenarios/examples/simple_restart/example.py deleted file mode 100644 index 3727568da9..0000000000 --- a/scenarios/examples/simple_restart/example.py +++ /dev/null @@ -1,255 +0,0 @@ -"""Minimal reproducible example script. - -This script is for you to use to reproduce a bug or demonstrate a feature. -""" - -import asyncio -from os import getenv - -from acapy_controller import Controller -from acapy_controller.logging import logging_to_stdout -from acapy_controller.models import CreateWalletResponse -from acapy_controller.protocols import ( - didexchange, - indy_anoncred_credential_artifacts, - indy_anoncred_onboard, - indy_issue_credential_v2, - indy_present_proof_v2, -) -from examples.util import wait_until_healthy - -import docker - -ALICE = getenv("ALICE", "http://alice:3001") -BOB = getenv("BOB", "http://bob:3001") -AGENCY = getenv("AGENCY", "http://agency:3001") - - -async def main(): - """Test Controller protocols.""" - # create multitenant issuer tenant - async with Controller(base_url=AGENCY) as agency: - multitenant_issuer_tenant = await agency.post( - "/multitenancy/wallet", - json={ - "label": "MultitenantIssuer", - "wallet_type": "askar", - }, - response=CreateWalletResponse, - ) - - async with ( - Controller(base_url=ALICE) as alice, - Controller(base_url=BOB) as bob, - Controller( - base_url=AGENCY, - wallet_id=multitenant_issuer_tenant.wallet_id, - subwallet_token=multitenant_issuer_tenant.token, - ) as multitenant_issuer, - ): - # connect the 2 agents - print(">>> connecting agents ...") - (alice_conn, bob_conn) = await didexchange(alice, bob) - - # setup alice as an issuer - print(">>> setting up alice as issuer ...") - await indy_anoncred_onboard(alice) - schema, cred_def = await indy_anoncred_credential_artifacts( - alice, - ["firstname", "lastname"], - support_revocation=True, - ) - - # Issue a credential - print(">>> issue credential ...") - alice_cred_ex, _ = await indy_issue_credential_v2( - alice, - bob, - alice_conn.connection_id, - bob_conn.connection_id, - cred_def.credential_definition_id, - {"firstname": "Bob", "lastname": "Builder"}, - ) - - # Present the the credential's attributes - print(">>> present proof ...") - await indy_present_proof_v2( - bob, - alice, - bob_conn.connection_id, - alice_conn.connection_id, - requested_attributes=[{"name": "firstname"}], - ) - print(">>> Done!") - - # connect multitenant issuer to bob - print(">>> connecting agents ...") - (multitenant_issuer_conn, bob_to_mt_conn) = await didexchange( - multitenant_issuer, bob - ) - - # setup multitenant issuer as an issuer - print(">>> setting up multitenant issuer as issuer ...") - await indy_anoncred_onboard(multitenant_issuer) - schema, cred_def = await indy_anoncred_credential_artifacts( - multitenant_issuer, - ["firstname", "lastname"], - support_revocation=True, - ) - - # Issue a credential - print(">>> issue credential ...") - multitenant_issuer_cred_ex, _ = await indy_issue_credential_v2( - multitenant_issuer, - bob, - multitenant_issuer_conn.connection_id, - bob_to_mt_conn.connection_id, - cred_def.credential_definition_id, - {"firstname": "Bob", "lastname": "Builder"}, - ) - - # Present the the credential's attributes - print(">>> present proof ...") - await indy_present_proof_v2( - bob, - multitenant_issuer, - bob_to_mt_conn.connection_id, - multitenant_issuer_conn.connection_id, - requested_attributes=[{"name": "firstname"}], - ) - print(">>> Done!") - - # play with docker - client = docker.from_env() - containers = client.containers.list(all=True) - docker_containers = {} - for container in containers: - if "com.docker.compose.service" in container.attrs["Config"]["Labels"]: - container_name = container.attrs["Config"]["Labels"][ - "com.docker.compose.service" - ] - container_id = container.attrs["Id"] - container_is_running = container.attrs["State"]["Running"] - docker_containers[container_name] = { - "Id": container_id, - "Running": container_is_running, - } - print(">>> container:", container_name, docker_containers[container_name]) - - # try to restart a container (stop alice and start alice-upgrade) - alice_docker_container = docker_containers["alice"] - alice_container = client.containers.get(alice_docker_container["Id"]) - - # try to restart agency container (stop agency and start agency-upgrade) - agency_docker_container = docker_containers["agency"] - agency_container = client.containers.get(agency_docker_container["Id"]) - - print(">>> shut down alice ...") - alice_container.stop() - - print(">>> shut down agency ...") - agency_container.stop() - - print(">>> waiting for alice container to exit ...") - alice_id = agency_container.attrs["Id"] - wait_until_healthy(client, alice_id, is_healthy=False) - alice_container.remove() - - print(">>> waiting for agency container to exit ...") - agency_id = agency_container.attrs["Id"] - wait_until_healthy(client, agency_id, is_healthy=False) - agency_container.remove() - - # Upgrade alice and perform some tests - new_alice_container = None - alice_id = None - try: - print(">>> start new alice container ...") - new_alice_container = client.containers.run( - "acapy-test", - command=alice_container.attrs["Config"]["Cmd"], - detach=True, - environment={"RUST_LOG": "aries-askar::log::target=error"}, - healthcheck=alice_container.attrs["Config"]["Healthcheck"], - name="alice", - network=alice_container.attrs["HostConfig"]["NetworkMode"], - ports=alice_container.attrs["NetworkSettings"]["Ports"], - ) - alice_id = new_alice_container.attrs["Id"] - - wait_until_healthy(client, alice_id) - print(">>> new alice container is healthy") - - # run some more tests ... alice should still be connected to bob for example ... - async with Controller(base_url=ALICE) as alice, Controller(base_url=BOB) as bob: - # Present the the credential's attributes - print(">>> present proof ... again ...") - await indy_present_proof_v2( - bob, - alice, - bob_conn.connection_id, - alice_conn.connection_id, - requested_attributes=[{"name": "firstname"}], - ) - print(">>> Done! (again)") - finally: - if alice_id and new_alice_container: - # cleanup - shut down alice agent (not part of docker compose) - print(">>> shut down alice ...") - alice_container = client.containers.get(alice_id) - alice_container.stop() - wait_until_healthy(client, alice_id, is_healthy=False) - alice_container.remove() - - # Upgrade agency and perform some tests - new_agency_container = None - agency_id = None - try: - print(">>> start new agency container ...") - new_agency_container = client.containers.run( - "acapy-test", - command=agency_container.attrs["Config"]["Cmd"], - detach=True, - environment={"RUST_LOG": "aries-askar::log::target=error"}, - healthcheck=agency_container.attrs["Config"]["Healthcheck"], - name="agency", - network=agency_container.attrs["HostConfig"]["NetworkMode"], - ports=agency_container.attrs["NetworkSettings"]["Ports"], - ) - agency_id = new_agency_container.attrs["Id"] - - wait_until_healthy(client, agency_id) - print(">>> new agency container is healthy") - - # run some more tests ... agency tenant should still be connected to bob ... - async with ( - Controller(base_url=BOB) as bob, - Controller( - base_url=AGENCY, - wallet_id=multitenant_issuer_tenant.wallet_id, - subwallet_token=multitenant_issuer_tenant.token, - ) as multitenant_issuer, - ): - # Present the the credential's attributes - print(">>> present proof ... again ...") - await indy_present_proof_v2( - bob, - multitenant_issuer, - bob_to_mt_conn.connection_id, - multitenant_issuer_conn.connection_id, - requested_attributes=[{"name": "firstname"}], - ) - print(">>> Done! (again)") - finally: - if agency_id and new_agency_container: - # cleanup - shut down agency agent (not part of docker compose) - print(">>> shut down agency ...") - agency_container = client.containers.get(agency_id) - agency_container.stop() - wait_until_healthy(client, agency_id, is_healthy=False) - agency_container.remove() - - -if __name__ == "__main__": - logging_to_stdout() - asyncio.run(main()) diff --git a/scenarios/examples/vc_holder/docker-compose.yml b/scenarios/examples/vc_holder/docker-compose.yml deleted file mode 100644 index ac9d0ef7a4..0000000000 --- a/scenarios/examples/vc_holder/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ - services: - agency: - image: acapy-test - ports: - - "3001:3001" - environment: - RUST_LOG: 'aries-askar::log::target=error' - command: > - start - --label Agency - --inbound-transport http 0.0.0.0 3000 - --outbound-transport http - --endpoint http://agency:3000 - --admin 0.0.0.0 3001 - --admin-insecure-mode - --no-ledger - --wallet-type askar - --wallet-name alice - --wallet-key insecure - --auto-provision - --log-level debug - --debug-webhooks - --multitenant - --multitenant-admin - --jwt-secret insecure - --multitenancy-config wallet_type=single-wallet-askar key_derivation_method=RAW - healthcheck: - test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null - start_period: 30s - interval: 7s - timeout: 5s - retries: 5 - - example: - container_name: controller - build: - context: ../.. - environment: - - AGENCY=http://agency:3001 - volumes: - - ./example.py:/usr/src/app/example.py:ro,z - command: python -m example - depends_on: - agency: - condition: service_healthy diff --git a/scenarios/examples/vc_holder/example.py b/scenarios/examples/vc_holder/example.py deleted file mode 100644 index 1e214419f0..0000000000 --- a/scenarios/examples/vc_holder/example.py +++ /dev/null @@ -1,95 +0,0 @@ -"""Test VC Holder multi-tenancy isolation.""" - -import asyncio -from os import getenv - -from acapy_controller import Controller -from acapy_controller.logging import logging_to_stdout -from acapy_controller.models import CreateWalletResponse -from acapy_controller.protocols import DIDResult - -AGENCY = getenv("AGENCY", "http://agency:3001") - - -async def main(): - """Test Controller protocols.""" - async with Controller(base_url=AGENCY) as agency: - issuer = await agency.post( - "/multitenancy/wallet", - json={ - "label": "Issuer", - "wallet_type": "askar", - }, - response=CreateWalletResponse, - ) - alice = await agency.post( - "/multitenancy/wallet", - json={ - "label": "Alice", - "wallet_type": "askar", - }, - response=CreateWalletResponse, - ) - bob = await agency.post( - "/multitenancy/wallet", - json={ - "label": "Bob", - "wallet_type": "askar", - }, - response=CreateWalletResponse, - ) - - async with ( - Controller( - base_url=AGENCY, wallet_id=alice.wallet_id, subwallet_token=alice.token - ) as alice, - Controller( - base_url=AGENCY, wallet_id=bob.wallet_id, subwallet_token=bob.token - ) as bob, - Controller( - base_url=AGENCY, wallet_id=issuer.wallet_id, subwallet_token=issuer.token - ) as issuer, - ): - public_did = ( - await issuer.post( - "/wallet/did/create", - json={"method": "key", "options": {"key_type": "ed25519"}}, - response=DIDResult, - ) - ).result - assert public_did - cred = await issuer.post( - "/vc/credentials/issue", - json={ - "credential": { - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://www.w3.org/2018/credentials/examples/v1", - ], - "id": "http://example.edu/credentials/1872", - "credentialSubject": { - "id": "did:example:ebfeb1f712ebc6f1c276e12ec21" - }, - "issuer": public_did.did, - "issuanceDate": "2024-12-10T10:00:00Z", - "type": ["VerifiableCredential", "AlumniCredential"], - }, - "options": { - "challenge": "3fa85f64-5717-4562-b3fc-2c963f66afa6", - "domain": "example.com", - "proofPurpose": "assertionMethod", - "proofType": "Ed25519Signature2018", - }, - }, - ) - await alice.post( - "/vc/credentials/store", - json={"verifiableCredential": cred["verifiableCredential"]}, - ) - result = await bob.get("/vc/credentials") - assert len(result["results"]) == 0 - - -if __name__ == "__main__": - logging_to_stdout() - asyncio.run(main()) From e0665930a484d7579ca36d9ccbda7821fa04eff0 Mon Sep 17 00:00:00 2001 From: jamshale Date: Fri, 21 Nov 2025 20:48:02 +0000 Subject: [PATCH 3/3] tiny change to trigger test Signed-off-by: jamshale --- scenarios/examples/kanon_issuance_and_presentation/example.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scenarios/examples/kanon_issuance_and_presentation/example.py b/scenarios/examples/kanon_issuance_and_presentation/example.py index 5ec12591d1..421a389574 100644 --- a/scenarios/examples/kanon_issuance_and_presentation/example.py +++ b/scenarios/examples/kanon_issuance_and_presentation/example.py @@ -69,6 +69,8 @@ async def main(): ).result assert public_did + + async with ClientSession() as session: register_url = genesis_url.replace("/genesis", "/register") async with session.post(