From 73862d9e915b4de1bd5cf7b770875275c32c4bda Mon Sep 17 00:00:00 2001 From: Ian Costanzo Date: Tue, 24 Jan 2023 09:27:57 -0800 Subject: [PATCH 1/4] Multitenancy demo Signed-off-by: Ian Costanzo --- demo/docker-agent/Dockerfile.acapy | 4 --- demo/multi-demo/Dockerfile.acapy | 10 +++++++ demo/multi-demo/README.md | 40 +++++++++++++++++++++++++ demo/multi-demo/docker-compose.yml | 47 ++++++++++++++++++++++++++++++ demo/multi-demo/ngrok-wait.sh | 47 ++++++++++++++++++++++++++++++ 5 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 demo/multi-demo/Dockerfile.acapy create mode 100644 demo/multi-demo/README.md create mode 100644 demo/multi-demo/docker-compose.yml create mode 100755 demo/multi-demo/ngrok-wait.sh diff --git a/demo/docker-agent/Dockerfile.acapy b/demo/docker-agent/Dockerfile.acapy index aa9e5593de..a8eee30ae0 100644 --- a/demo/docker-agent/Dockerfile.acapy +++ b/demo/docker-agent/Dockerfile.acapy @@ -8,7 +8,3 @@ COPY ngrok-wait.sh ngrok-wait.sh RUN chmod +x ./ngrok-wait.sh USER $user - -# temporary until this PR gets merged/released -RUN pip uninstall -y aries-cloudagent -RUN pip install aries-cloudagent[indy,bbs,askar]@git+https://github.com/ianco/aries-cloudagent-python@endorser-write-did diff --git a/demo/multi-demo/Dockerfile.acapy b/demo/multi-demo/Dockerfile.acapy new file mode 100644 index 0000000000..a8eee30ae0 --- /dev/null +++ b/demo/multi-demo/Dockerfile.acapy @@ -0,0 +1,10 @@ +FROM bcgovimages/aries-cloudagent:py36-1.16-1_1.0.0-rc0 + +USER root + +ADD https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 ./jq +RUN chmod +x ./jq +COPY ngrok-wait.sh ngrok-wait.sh +RUN chmod +x ./ngrok-wait.sh + +USER $user diff --git a/demo/multi-demo/README.md b/demo/multi-demo/README.md new file mode 100644 index 0000000000..208a8f7996 --- /dev/null +++ b/demo/multi-demo/README.md @@ -0,0 +1,40 @@ +# Running an Aca-Py Agent in Multitenant Mode + +This directory contains scripts to run an aca-py agent in multitenancy mode. + +## Running the Agent + +The docker-compose script runs ngrok to expose the agent's port publicly, and stores wallet data in a postgres database. + +To run the agent in this repo, open a command shell in this directory and run: + +- to build the containers: + +```bash +docker-compose build +``` + +- to run the agent: + +```bash +docker-compose up +``` + +You can connect to the [agent's api service here](http://localhost:8010). + +Note that all the configuration settings are hard-coded in the docker-compose file and ngrok-wait.sh script, so if you change any configs you need to rebuild the docker images. + +- to shut down the agent: + +```bash +docker-compose stop +docker-compose rm -f +``` + +This will leave the agent's wallet data, so if you restart the agent it will maintain any created data. + +- to remove the agent's wallet: + +```bash +docker volume rm docker-agent_wallet-db-data +``` diff --git a/demo/multi-demo/docker-compose.yml b/demo/multi-demo/docker-compose.yml new file mode 100644 index 0000000000..be9fb0683c --- /dev/null +++ b/demo/multi-demo/docker-compose.yml @@ -0,0 +1,47 @@ +# Sample docker-compose to start a local aca-py multitenancy agent +# To start aca-py and the postgres database, just run `docker-compose up` +# To shut down the services run `docker-compose rm` - this will retain the postgres database, so you can change aca-py startup parameters +# and restart the docker containers without losing your wallet data +# If you want to delete your wallet data just run `docker volume ls -q | xargs docker volume rm` +version: "3" +services: + ngrok-agent: + image: wernight/ngrok + ports: + - 4067:4040 + command: ngrok http multi-agent:8001 --log stdout + + multi-agent: + build: + context: . + dockerfile: Dockerfile.acapy + environment: + - NGROK_NAME=ngrok-agent + ports: + - 8010:8010 + - 8001:8001 + depends_on: + - wallet-db + entrypoint: /bin/bash + command: [ + "-c", + "sleep 5; \ + ./ngrok-wait.sh" + ] + volumes: + - ./ngrok-wait.sh:/home/indy/ngrok-wait.sh + + wallet-db: + image: vcr-postgresql + environment: + - POSTGRESQL_USER=DB_USER + - POSTGRESQL_PASSWORD=DB_PASSWORD + - POSTGRESQL_DATABASE=DB_USER + - POSTGRESQL_ADMIN_PASSWORD=mysecretpassword + ports: + - 5433:5432 + volumes: + - wallet-db-data:/var/lib/pgsql/data + +volumes: + wallet-db-data: diff --git a/demo/multi-demo/ngrok-wait.sh b/demo/multi-demo/ngrok-wait.sh new file mode 100755 index 0000000000..df0bc08d6e --- /dev/null +++ b/demo/multi-demo/ngrok-wait.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# based on code developed by Sovrin: https://github.com/hyperledger/aries-acapy-plugin-toolbox + +echo "using ngrok end point [$NGROK_NAME]" + +NGROK_ENDPOINT=null +while [ -z "$NGROK_ENDPOINT" ] || [ "$NGROK_ENDPOINT" = "null" ] +do + echo "Fetching end point from ngrok service" + NGROK_ENDPOINT=$(curl --silent $NGROK_NAME:4040/api/tunnels | ./jq -r '.tunnels[] | select(.proto=="https") | .public_url') + + if [ -z "$NGROK_ENDPOINT" ] || [ "$NGROK_ENDPOINT" = "null" ]; then + echo "ngrok not ready, sleeping 5 seconds...." + sleep 5 + fi +done + +export ACAPY_ENDPOINT=$NGROK_ENDPOINT + +echo "Starting aca-py agent with endpoint [$ACAPY_ENDPOINT]" + +# ... if you want to echo the aca-py startup command ... +set -x + +exec aca-py start \ + --auto-provision \ + --inbound-transport http '0.0.0.0' 8001 \ + --outbound-transport http \ + --genesis-url "http://test.bcovrin.vonx.io/genesis" \ + --endpoint "${ACAPY_ENDPOINT}" \ + --auto-ping-connection \ + --monitor-ping \ + --public-invites \ + --wallet-type "askar" \ + --wallet-name "test_multi" \ + --wallet-key "secret_key" \ + --wallet-storage-type "postgres_storage" \ + --wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5,\"scheme\":\"MultiWalletSingleTable\"}" \ + --wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"postgres\",\"admin_password\":\"mysecretpassword\"}" \ + --admin '0.0.0.0' 8010 \ + --label "test_multi" \ + --admin-insecure-mode \ + --multitenant \ + --multitenant-admin \ + --jwt-secret "very_secret_secret" \ + --log-level "error" From ea1ec8a52fcb5dcf61356fddec26b28bd7525e5e Mon Sep 17 00:00:00 2001 From: Shaanjot Gill Date: Thu, 2 Feb 2023 08:09:23 -0800 Subject: [PATCH 2/4] black 23.1.0 formatter changes Signed-off-by: Shaanjot Gill --- aries_cloudagent/admin/server.py | 2 +- aries_cloudagent/askar/didcomm/v2.py | 6 +- aries_cloudagent/config/tests/test_wallet.py | 1 - aries_cloudagent/connections/base_manager.py | 2 +- .../connections/models/diddoc/diddoc.py | 1 - .../models/diddoc/tests/test_diddoc.py | 1 - aries_cloudagent/core/conductor.py | 8 +-- .../core/in_memory/didcomm/tests/test_1pu.py | 3 - .../core/in_memory/didcomm/tests/test_ecdh.py | 6 +- aries_cloudagent/core/tests/test_conductor.py | 2 - .../core/tests/test_oob_processor.py | 9 --- .../did/tests/test_did_key_bls12381g1g2.py | 1 + aries_cloudagent/indy/models/pres_preview.py | 2 +- aries_cloudagent/indy/models/xform.py | 4 +- aries_cloudagent/indy/sdk/holder.py | 12 ++-- aries_cloudagent/indy/verifier.py | 16 ++--- aries_cloudagent/ledger/indy.py | 3 + .../ledger/merkel_validation/trie.py | 2 +- .../tests/test_indy_manager.py | 10 ++- .../tests/test_indy_vdr_manager.py | 10 ++- aries_cloudagent/ledger/tests/test_indy.py | 8 --- aries_cloudagent/ledger/tests/test_routes.py | 1 - .../tests/test_routes.py | 1 - .../decorators/tests/test_decorator_set.py | 5 -- .../tests/test_localization_decorator.py | 1 - .../decorators/tests/test_thread_decorator.py | 3 - .../decorators/tests/test_trace_decorator.py | 4 -- aries_cloudagent/messaging/jsonld/routes.py | 2 +- .../messaging/schemas/tests/test_routes.py | 1 - aries_cloudagent/multitenant/base.py | 2 +- aries_cloudagent/multitenant/route_manager.py | 2 +- .../multitenant/tests/test_base.py | 1 - .../actionmenu/v1_0/tests/test_routes.py | 10 --- .../actionmenu/v1_0/tests/test_service.py | 8 +-- .../basicmessage/v1_0/tests/test_routes.py | 3 - .../tests/test_connection_invitation.py | 1 - .../tests/test_connection_response.py | 1 - .../connections/v1_0/tests/test_routes.py | 2 - .../didexchange/v1_0/tests/test_manager.py | 1 - .../didexchange/v1_0/tests/test_routes.py | 1 - .../v1_0/messages/tests/test_disclose.py | 1 - .../v1_0/messages/tests/test_query.py | 1 - .../v2_0/messages/tests/test_queries.py | 1 - .../v1_0/tests/test_manager.py | 1 - .../v1_0/tests/test_routes.py | 2 - .../issue_credential/v1_0/manager.py | 72 +++++++++++-------- .../v1_0/tests/test_manager.py | 1 - .../v1_0/tests/test_routes.py | 16 ----- .../formats/ld_proof/tests/test_handler.py | 1 - .../issue_credential/v2_0/manager.py | 58 +++++++-------- .../v2_0/tests/test_manager.py | 9 --- .../v2_0/tests/test_routes.py | 14 ---- .../protocols/out_of_band/v1_0/manager.py | 1 - .../out_of_band/v1_0/tests/test_manager.py | 3 - .../present_proof/indy/pres_exch_handler.py | 2 +- .../test_presentation_request_handler.py | 9 --- .../protocols/present_proof/v1_0/manager.py | 12 ++-- .../present_proof/v1_0/tests/test_routes.py | 38 ---------- .../tests/test_pres_request_handler.py | 10 --- .../protocols/present_proof/v2_0/manager.py | 10 ++- .../protocols/present_proof/v2_0/routes.py | 3 +- .../v1_0/messages/tests/test_forward.py | 1 - .../revocation/tests/test_routes.py | 3 - aries_cloudagent/transport/pack_format.py | 1 - aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py | 1 - aries_cloudagent/wallet/bbs.py | 2 +- aries_cloudagent/wallet/indy.py | 4 +- aries_cloudagent/wallet/tests/test_routes.py | 1 - demo/runners/agent_container.py | 5 +- demo/runners/performance.py | 1 - docs/conf.py | 1 + 71 files changed, 139 insertions(+), 305 deletions(-) diff --git a/aries_cloudagent/admin/server.py b/aries_cloudagent/admin/server.py index 846405a024..def29588eb 100644 --- a/aries_cloudagent/admin/server.py +++ b/aries_cloudagent/admin/server.py @@ -491,7 +491,7 @@ async def start(self) -> None: def sort_dict(raw: dict) -> dict: """Order (JSON, string keys) dict asciibetically by key, recursively.""" - for (k, v) in raw.items(): + for k, v in raw.items(): if isinstance(v, dict): raw[k] = sort_dict(v) return dict(sorted([item for item in raw.items()], key=lambda x: x[0])) diff --git a/aries_cloudagent/askar/didcomm/v2.py b/aries_cloudagent/askar/didcomm/v2.py index c74b5cd9e7..7d89a3ec9c 100644 --- a/aries_cloudagent/askar/didcomm/v2.py +++ b/aries_cloudagent/askar/didcomm/v2.py @@ -33,7 +33,7 @@ def ecdh_es_encrypt(to_verkeys: Mapping[str, Key], message: bytes) -> bytes: except AskarError: raise DidcommEnvelopeError("Error creating content encryption key") - for (kid, recip_key) in to_verkeys.items(): + for kid, recip_key in to_verkeys.items(): try: epk = Key.generate(recip_key.algorithm, ephemeral=True) except AskarError: @@ -145,7 +145,7 @@ def ecdh_1pu_encrypt( apu = b64url(sender_kid) apv = [] - for (kid, recip_key) in to_verkeys.items(): + for kid, recip_key in to_verkeys.items(): if agree_alg: if agree_alg != recip_key.algorithm: raise DidcommEnvelopeError("Recipient key types must be consistent") @@ -173,7 +173,7 @@ def ecdh_1pu_encrypt( raise DidcommEnvelopeError("Error encrypting message payload") wrapper.set_payload(payload.ciphertext, payload.nonce, payload.tag) - for (kid, recip_key) in to_verkeys.items(): + for kid, recip_key in to_verkeys.items(): enc_key = ecdh.Ecdh1PU(alg_id, apu, apv).sender_wrap_key( wrap_alg, epk, sender_key, recip_key, cek, cc_tag=payload.tag ) diff --git a/aries_cloudagent/config/tests/test_wallet.py b/aries_cloudagent/config/tests/test_wallet.py index 9d514bc735..3ff2e5a8b8 100644 --- a/aries_cloudagent/config/tests/test_wallet.py +++ b/aries_cloudagent/config/tests/test_wallet.py @@ -187,7 +187,6 @@ async def test_wallet_config_bad_seed_x(self): ) as mock_seed_to_did, async_mock.patch.object( test_module, "add_or_update_version_to_storage", async_mock.CoroutineMock() ): - with self.assertRaises(test_module.ConfigError): await test_module.wallet_config(self.context, provision=True) diff --git a/aries_cloudagent/connections/base_manager.py b/aries_cloudagent/connections/base_manager.py index 53172b9966..815843b4c0 100644 --- a/aries_cloudagent/connections/base_manager.py +++ b/aries_cloudagent/connections/base_manager.py @@ -150,7 +150,7 @@ async def create_did_document( routing_keys = [*routing_keys, *mediator_routing_keys] svc_endpoints = [mediation_record.endpoint] - for (endpoint_index, svc_endpoint) in enumerate(svc_endpoints or []): + for endpoint_index, svc_endpoint in enumerate(svc_endpoints or []): endpoint_ident = "indy" if endpoint_index == 0 else f"indy{endpoint_index}" service = Service( did_info.did, diff --git a/aries_cloudagent/connections/models/diddoc/diddoc.py b/aries_cloudagent/connections/models/diddoc/diddoc.py index d1b8bcb0cc..ea47866487 100644 --- a/aries_cloudagent/connections/models/diddoc/diddoc.py +++ b/aries_cloudagent/connections/models/diddoc/diddoc.py @@ -176,7 +176,6 @@ def add_service_pubkeys( rv = [] for tag in [tags] if isinstance(tags, str) else list(tags): - for svc_key in service.get(tag, {}): canon_key = canon_ref(self.did, svc_key) pubkey = None diff --git a/aries_cloudagent/connections/models/diddoc/tests/test_diddoc.py b/aries_cloudagent/connections/models/diddoc/tests/test_diddoc.py index be002ddc27..141a0e6051 100644 --- a/aries_cloudagent/connections/models/diddoc/tests/test_diddoc.py +++ b/aries_cloudagent/connections/models/diddoc/tests/test_diddoc.py @@ -26,7 +26,6 @@ class TestDIDDoc(AsyncTestCase): async def test_basic(self): - # One authn key by reference dd_in = { "@context": "https://w3id.org/did/v1", diff --git a/aries_cloudagent/core/conductor.py b/aries_cloudagent/core/conductor.py index 9dfe8f8ab2..1f09dbc13a 100644 --- a/aries_cloudagent/core/conductor.py +++ b/aries_cloudagent/core/conductor.py @@ -455,11 +455,9 @@ async def start(self) -> None: auto_accept=True, ) async with self.root_profile.session() as session: - await ( - MediationInviteStore( - session.context.inject(BaseStorage) - ).mark_default_invite_as_used() - ) + await MediationInviteStore( + session.context.inject(BaseStorage) + ).mark_default_invite_as_used() await record.metadata_set( session, MediationManager.SEND_REQ_AFTER_CONNECTION, True diff --git a/aries_cloudagent/core/in_memory/didcomm/tests/test_1pu.py b/aries_cloudagent/core/in_memory/didcomm/tests/test_1pu.py index f12bdc25d0..e57b7bddda 100644 --- a/aries_cloudagent/core/in_memory/didcomm/tests/test_1pu.py +++ b/aries_cloudagent/core/in_memory/didcomm/tests/test_1pu.py @@ -6,7 +6,6 @@ def test_1pu_hex_example(): - # Previously randomly generated 3 sets of keys aliceSecretKey = "23832cbef38641b8754a35f1f79bbcbc248e09ac93b01c2eaf12474f2ac406b6" alicePublicKey = "04fd4ca9eb7954a03517ac8249e6070aa3112e582f596b10f0d45d757b56d5dc0395a7d207d06503a4d6ad6e2ad3a1fd8cc233c072c0dc0f32213deb712c32cbdf" @@ -41,7 +40,6 @@ def test_1pu_hex_example(): # Example key exchange in https://tools.ietf.org/id/draft-madden-jose-ecdh-1pu-03.html#rfc.appendix.A def test_1pu_appendix_example(): - # Convert the three JWK keys into hex encoded byte format # Alice Key @@ -106,7 +104,6 @@ def test_1pu_appendix_example(): def main(): - test_1pu_hex_example() test_1pu_appendix_example() diff --git a/aries_cloudagent/core/in_memory/didcomm/tests/test_ecdh.py b/aries_cloudagent/core/in_memory/didcomm/tests/test_ecdh.py index 16f15754d9..943456c7b8 100644 --- a/aries_cloudagent/core/in_memory/didcomm/tests/test_ecdh.py +++ b/aries_cloudagent/core/in_memory/didcomm/tests/test_ecdh.py @@ -2,9 +2,9 @@ from ..derive_ecdh import * + # Generate the same shared secret from imported generated keys def test_ecdh_derive_shared_secret(): - # Import keys for two participating users aliceSecretKey = "23832cbef38641b8754a35f1f79bbcbc248e09ac93b01c2eaf12474f2ac406b6" alicePublicKey = "04fd4ca9eb7954a03517ac8249e6070aa3112e582f596b10f0d45d757b56d5dc0395a7d207d06503a4d6ad6e2ad3a1fd8cc233c072c0dc0f32213deb712c32cbdf" @@ -23,7 +23,6 @@ def test_ecdh_derive_shared_secret(): # Generate the same shared secret from random keys def test_ecdh_derive_shared_secret_random(): - # Generate random keys for the two participating users aliceSecretKey = SigningKey.generate(curve=NIST256p) alice = ECDH(curve=NIST256p) @@ -46,7 +45,6 @@ def test_ecdh_derive_shared_secret_random(): # Test the entire key generation flow, DeriveECDHSecret() into ConcatKDF() def test_ecdh_generate_key(): - aliceSecretKey = "23832cbef38641b8754a35f1f79bbcbc248e09ac93b01c2eaf12474f2ac406b6" alicePublicKey = "04fd4ca9eb7954a03517ac8249e6070aa3112e582f596b10f0d45d757b56d5dc0395a7d207d06503a4d6ad6e2ad3a1fd8cc233c072c0dc0f32213deb712c32cbdf" @@ -78,7 +76,6 @@ def test_ecdh_generate_key(): # Test the entire key generation flow, derive_shared_secret() into concat_kdf() def test_ecdh_generate_key_random(): - aliceSecretKey = SigningKey.generate(curve=NIST256p) alice = ECDH(curve=NIST256p) alice.load_private_key(aliceSecretKey) @@ -113,7 +110,6 @@ def test_ecdh_generate_key_random(): def main(): - test_ecdh_derive_shared_secret() test_ecdh_derive_shared_secret_random() test_ecdh_generate_key() diff --git a/aries_cloudagent/core/tests/test_conductor.py b/aries_cloudagent/core/tests/test_conductor.py index d37f10161e..d4e73b4a8f 100644 --- a/aries_cloudagent/core/tests/test_conductor.py +++ b/aries_cloudagent/core/tests/test_conductor.py @@ -222,7 +222,6 @@ async def test_stats(self): ) as mock_outbound_mgr, async_mock.patch.object( test_module, "LoggingConfigurator", autospec=True ) as mock_logger: - mock_inbound_mgr.return_value.sessions = ["dummy"] mock_outbound_mgr.return_value.outbound_buffer = [ async_mock.MagicMock(state=QueuedOutboundMessage.STATE_ENCODE), @@ -263,7 +262,6 @@ async def test_inbound_message_handler(self): with async_mock.patch.object( conductor.dispatcher, "queue_message", autospec=True ) as mock_dispatch_q: - message_body = "{}" receipt = MessageReceipt(direct_response_mode="snail mail") message = InboundMessage(message_body, receipt) diff --git a/aries_cloudagent/core/tests/test_oob_processor.py b/aries_cloudagent/core/tests/test_oob_processor.py index 5197daedbd..7c73a946ad 100644 --- a/aries_cloudagent/core/tests/test_oob_processor.py +++ b/aries_cloudagent/core/tests/test_oob_processor.py @@ -59,7 +59,6 @@ async def test_clean_finished_oob_record_no_multi_use_no_request_attach(self): "retrieve_by_tag_filter", async_mock.CoroutineMock(return_value=mock_oob), ) as mock_retrieve_oob: - await self.oob_processor.clean_finished_oob_record( self.profile, test_message ) @@ -88,7 +87,6 @@ async def test_clean_finished_oob_record_multi_use(self): "retrieve_by_tag_filter", async_mock.CoroutineMock(return_value=mock_oob), ) as mock_retrieve_oob: - await self.oob_processor.clean_finished_oob_record( self.profile, test_message ) @@ -143,7 +141,6 @@ async def test_find_oob_target_for_outbound_message(self): "retrieve_by_tag_filter", async_mock.CoroutineMock(return_value=mock_oob), ) as mock_retrieve_oob: - target = await self.oob_processor.find_oob_target_for_outbound_message( self.profile, outbound ) @@ -182,7 +179,6 @@ async def test_find_oob_target_for_outbound_message_oob_not_found(self): "retrieve_by_tag_filter", async_mock.CoroutineMock(side_effect=(StorageNotFoundError(),)), ) as mock_retrieve_oob: - target = await self.oob_processor.find_oob_target_for_outbound_message( self.profile, outbound ) @@ -217,7 +213,6 @@ async def test_find_oob_target_for_outbound_message_update_service_thread(self): "retrieve_by_tag_filter", async_mock.CoroutineMock(return_value=mock_oob), ): - message = json.dumps({}) outbound = OutboundMessage(reply_thread_id="the-thid", payload=message) await self.oob_processor.find_oob_target_for_outbound_message( @@ -525,7 +520,6 @@ async def test_find_oob_record_for_inbound_message_attach_thread_id_not_in_list( async def test_find_oob_record_for_inbound_message_not_attach_thread_id_matching( self, ): - with async_mock.patch.object( OobRecord, "retrieve_by_tag_filter", @@ -639,7 +633,6 @@ async def test_find_oob_record_for_inbound_message_their_service_set_on_oob_reco async def test_find_oob_record_for_inbound_message_session_emit_delete( self, ): - with async_mock.patch.object( OobRecord, "retrieve_by_tag_filter", @@ -664,7 +657,6 @@ async def test_find_oob_record_for_inbound_message_session_emit_delete( async def test_find_oob_record_for_inbound_message_session_connectionless_save( self, ): - self.oob_record.connection_id = None with async_mock.patch.object( @@ -751,7 +743,6 @@ async def test_handle_message_connectionless(self): self.inbound_message_router.assert_called_once_with(self.profile, ANY, False) async def test_handle_message_unsupported_message_type(self): - with self.assertRaises(OobMessageProcessorError) as err: await self.oob_processor.handle_message( self.profile, [{"@type": "unsupported"}], async_mock.MagicMock() diff --git a/aries_cloudagent/did/tests/test_did_key_bls12381g1g2.py b/aries_cloudagent/did/tests/test_did_key_bls12381g1g2.py index f5ed77e64d..5877bed1c6 100644 --- a/aries_cloudagent/did/tests/test_did_key_bls12381g1g2.py +++ b/aries_cloudagent/did/tests/test_did_key_bls12381g1g2.py @@ -26,6 +26,7 @@ [b"\xee\x01", b58_to_bytes(TEST_BLS12381G1G2_BASE58_KEY)] ) + # The tests here are a bit quirky because g1g2 is a concatenation of g1 and g2 public key bytes # but it works with the already existing did key implementation. class TestDIDKey(TestCase): diff --git a/aries_cloudagent/indy/models/pres_preview.py b/aries_cloudagent/indy/models/pres_preview.py index 5f73978f33..0edb1cdb06 100644 --- a/aries_cloudagent/indy/models/pres_preview.py +++ b/aries_cloudagent/indy/models/pres_preview.py @@ -403,7 +403,7 @@ def non_revoc(cred_def_id: str) -> IndyNonRevocationInterval: }, } - for (reft, attr_spec) in attr_specs_names.items(): + for reft, attr_spec in attr_specs_names.items(): proof_req["requested_attributes"][ "{}_{}_uuid".format( len(proof_req["requested_attributes"]), canon(attr_spec["names"][0]) diff --git a/aries_cloudagent/indy/models/xform.py b/aries_cloudagent/indy/models/xform.py index 9e7d5e7601..afcb635fe2 100644 --- a/aries_cloudagent/indy/models/xform.py +++ b/aries_cloudagent/indy/models/xform.py @@ -30,7 +30,7 @@ async def indy_proof_req_preview2indy_requested_creds( "requested_predicates": {}, } - for (referent, req_item) in indy_proof_req["requested_attributes"].items(): + for referent, req_item in indy_proof_req["requested_attributes"].items(): credentials = await holder.get_credentials_for_presentation_request_by_referent( presentation_request=indy_proof_req, referents=(referent,), @@ -116,7 +116,7 @@ def indy_proof_req2non_revoc_intervals(indy_proof_req: dict): """Return non-revocation intervals by requested item referent in proof request.""" non_revoc_intervals = {} for req_item_type in ("requested_attributes", "requested_predicates"): - for (reft, req_item) in indy_proof_req[req_item_type].items(): + for reft, req_item in indy_proof_req[req_item_type].items(): interval = req_item.get( "non_revoked", indy_proof_req.get("non_revoked"), diff --git a/aries_cloudagent/indy/sdk/holder.py b/aries_cloudagent/indy/sdk/holder.py index 48cb2abac0..efb1a4f3ba 100644 --- a/aries_cloudagent/indy/sdk/holder.py +++ b/aries_cloudagent/indy/sdk/holder.py @@ -226,11 +226,13 @@ async def fetch(reft, limit): with IndyErrorHandler( "Error when constructing wallet credential query", IndyHolderError ): - search_handle = await ( - indy.anoncreds.prover_search_credentials_for_proof_req( - self.wallet.handle, - json.dumps(presentation_request), - json.dumps(extra_query), + search_handle = ( + await ( + indy.anoncreds.prover_search_credentials_for_proof_req( + self.wallet.handle, + json.dumps(presentation_request), + json.dumps(extra_query), + ) ) ) diff --git a/aries_cloudagent/indy/verifier.py b/aries_cloudagent/indy/verifier.py index f61ca829f2..9a83ce5b8f 100644 --- a/aries_cloudagent/indy/verifier.py +++ b/aries_cloudagent/indy/verifier.py @@ -59,12 +59,12 @@ def non_revoc_intervals(self, pres_req: dict, pres: dict, cred_defs: dict) -> li """ msgs = [] - for (req_proof_key, pres_key) in { + for req_proof_key, pres_key in { "revealed_attrs": "requested_attributes", "revealed_attr_groups": "requested_attributes", "predicates": "requested_predicates", }.items(): - for (uuid, spec) in pres["requested_proof"].get(req_proof_key, {}).items(): + for uuid, spec in pres["requested_proof"].get(req_proof_key, {}).items(): if ( "revocation" not in cred_defs[ @@ -132,7 +132,7 @@ async def check_timestamps( LOGGER.debug(f">>> got non-revoc intervals: {non_revoc_intervals}") # timestamp for irrevocable credential cred_defs = [] - for (index, ident) in enumerate(pres["identifiers"]): + for index, ident in enumerate(pres["identifiers"]): LOGGER.debug(f">>> got (index, ident): ({index},{ident})") cred_def_id = ident["cred_def_id"] multitenant_mgr = profile.inject_or(BaseMultitenantManager) @@ -184,7 +184,7 @@ async def check_timestamps( revealed_groups = pres["requested_proof"].get("revealed_attr_groups", {}) self_attested = pres["requested_proof"].get("self_attested_attrs", {}) preds = pres["requested_proof"].get("predicates", {}) - for (uuid, req_attr) in pres_req["requested_attributes"].items(): + for uuid, req_attr in pres_req["requested_attributes"].items(): if "name" in req_attr: if uuid in revealed_attrs: index = revealed_attrs[uuid]["sub_proof_index"] @@ -258,7 +258,7 @@ async def check_timestamps( f"{non_revoc_intervals[uuid]}" ) - for (uuid, req_pred) in pres_req["requested_predicates"].items(): + for uuid, req_pred in pres_req["requested_predicates"].items(): pred_spec = preds.get(uuid) if pred_spec is None or "sub_proof_index" not in pred_spec: raise ValueError( @@ -314,7 +314,7 @@ async def pre_verify(self, pres_req: dict, pres: dict) -> list: if "proof" not in pres: raise ValueError("Presentation missing 'proof'") - for (uuid, req_pred) in pres_req["requested_predicates"].items(): + for uuid, req_pred in pres_req["requested_predicates"].items(): try: canon_attr = canon(req_pred["name"]) matched = False @@ -340,7 +340,7 @@ async def pre_verify(self, pres_req: dict, pres: dict) -> list: unrevealed_attrs = pres["requested_proof"].get("unrevealed_attrs", {}) revealed_groups = pres["requested_proof"].get("revealed_attr_groups", {}) self_attested = pres["requested_proof"].get("self_attested_attrs", {}) - for (uuid, req_attr) in pres_req["requested_attributes"].items(): + for uuid, req_attr in pres_req["requested_attributes"].items(): if "name" in req_attr: if uuid in revealed_attrs: pres_req_attr_spec = {req_attr["name"]: revealed_attrs[uuid]} @@ -375,7 +375,7 @@ async def pre_verify(self, pres_req: dict, pres: dict) -> list: f"Request attribute missing 'name' and 'names': '{uuid}'" ) - for (attr, spec) in pres_req_attr_spec.items(): + for attr, spec in pres_req_attr_spec.items(): try: primary_enco = pres["proof"]["proofs"][spec["sub_proof_index"]][ "primary_proof" diff --git a/aries_cloudagent/ledger/indy.py b/aries_cloudagent/ledger/indy.py index de3e8d40fe..a127f8c028 100644 --- a/aries_cloudagent/ledger/indy.py +++ b/aries_cloudagent/ledger/indy.py @@ -389,6 +389,8 @@ async def _submit( if taa_accept: acceptance = await self.get_latest_txn_author_acceptance() if acceptance: + # flake8 and black 23.1.0 check collision fix + # fmt: off request_json = await ( indy.ledger.append_txn_author_agreement_acceptance_to_request( request_json, @@ -399,6 +401,7 @@ async def _submit( acceptance["time"], ) ) + # fmt: on if write_ledger: submit_op = indy.ledger.sign_and_submit_request( self.pool.handle, diff --git a/aries_cloudagent/ledger/merkel_validation/trie.py b/aries_cloudagent/ledger/merkel_validation/trie.py index 2c7acedf98..08eb958140 100644 --- a/aries_cloudagent/ledger/merkel_validation/trie.py +++ b/aries_cloudagent/ledger/merkel_validation/trie.py @@ -79,7 +79,7 @@ async def verify_spv_proof(expected_value, proof_nodes, serialized=True): json.loads(rlp_decode(decoded_node[1])[0].decode("utf-8")) ) == expected_value: return True - except (DecodingError): + except DecodingError: continue return False except Exception: diff --git a/aries_cloudagent/ledger/multiple_ledger/tests/test_indy_manager.py b/aries_cloudagent/ledger/multiple_ledger/tests/test_indy_manager.py index de629b2d78..572992a313 100644 --- a/aries_cloudagent/ledger/multiple_ledger/tests/test_indy_manager.py +++ b/aries_cloudagent/ledger/multiple_ledger/tests/test_indy_manager.py @@ -389,7 +389,10 @@ async def test_lookup_did_in_configured_ledgers_cached_prod_ledger(self): cache = InMemoryCache() await cache.set("did_ledger_id_resolver::Av63wJYM7xYR4AiygYq4c3", "test_prod_2") self.profile.context.injector.bind_instance(BaseCache, cache) - (ledger_id, ledger_inst,) = await self.manager.lookup_did_in_configured_ledgers( + ( + ledger_id, + ledger_inst, + ) = await self.manager.lookup_did_in_configured_ledgers( "Av63wJYM7xYR4AiygYq4c3", cache_did=True ) assert ledger_id == "test_prod_2" @@ -401,7 +404,10 @@ async def test_lookup_did_in_configured_ledgers_cached_non_prod_ledger(self): "did_ledger_id_resolver::Av63wJYM7xYR4AiygYq4c3", "test_non_prod_2", None ) self.profile.context.injector.bind_instance(BaseCache, cache) - (ledger_id, ledger_inst,) = await self.manager.lookup_did_in_configured_ledgers( + ( + ledger_id, + ledger_inst, + ) = await self.manager.lookup_did_in_configured_ledgers( "Av63wJYM7xYR4AiygYq4c3", cache_did=True ) assert ledger_id == "test_non_prod_2" diff --git a/aries_cloudagent/ledger/multiple_ledger/tests/test_indy_vdr_manager.py b/aries_cloudagent/ledger/multiple_ledger/tests/test_indy_vdr_manager.py index a09fb13983..86aa27a3d5 100644 --- a/aries_cloudagent/ledger/multiple_ledger/tests/test_indy_vdr_manager.py +++ b/aries_cloudagent/ledger/multiple_ledger/tests/test_indy_vdr_manager.py @@ -443,7 +443,10 @@ async def test_lookup_did_in_configured_ledgers_cached_prod_ledger(self): cache = InMemoryCache() await cache.set("did_ledger_id_resolver::Av63wJYM7xYR4AiygYq4c3", "test_prod_1") self.profile.context.injector.bind_instance(BaseCache, cache) - (ledger_id, ledger_inst,) = await self.manager.lookup_did_in_configured_ledgers( + ( + ledger_id, + ledger_inst, + ) = await self.manager.lookup_did_in_configured_ledgers( "Av63wJYM7xYR4AiygYq4c3", cache_did=True ) assert ledger_id == "test_prod_1" @@ -455,7 +458,10 @@ async def test_lookup_did_in_configured_ledgers_cached_non_prod_ledger(self): "did_ledger_id_resolver::Av63wJYM7xYR4AiygYq4c3", "test_non_prod_2", None ) self.profile.context.injector.bind_instance(BaseCache, cache) - (ledger_id, ledger_inst,) = await self.manager.lookup_did_in_configured_ledgers( + ( + ledger_id, + ledger_inst, + ) = await self.manager.lookup_did_in_configured_ledgers( "Av63wJYM7xYR4AiygYq4c3", cache_did=True ) assert ledger_id == "test_non_prod_2" diff --git a/aries_cloudagent/ledger/tests/test_indy.py b/aries_cloudagent/ledger/tests/test_indy.py index 0b36b67452..fe9c8216ee 100644 --- a/aries_cloudagent/ledger/tests/test_indy.py +++ b/aries_cloudagent/ledger/tests/test_indy.py @@ -337,7 +337,6 @@ async def test_submit_signed_taa_accept( mock_create_config, mock_set_proto, ): - mock_append_taa.return_value = "{}" mock_sign_submit.return_value = '{"op": "REPLY"}' @@ -387,7 +386,6 @@ async def test_submit_unsigned( mock_create_config, mock_set_proto, ): - mock_did = async_mock.MagicMock() future = asyncio.Future() @@ -419,7 +417,6 @@ async def test_submit_unsigned_ledger_transaction_error( mock_create_config, mock_set_proto, ): - mock_did = async_mock.MagicMock() future = asyncio.Future() @@ -454,7 +451,6 @@ async def test_submit_rejected( mock_create_config, mock_set_proto, ): - mock_did = async_mock.MagicMock() future = asyncio.Future() @@ -690,7 +686,6 @@ async def test_send_schema_ledger_transaction_error_already_exists( mock_create_config, mock_set_proto, ): - mock_wallet = async_mock.MagicMock() self.session.context.injector.bind_provider(BaseWallet, mock_wallet) mock_is_ledger_read_only.return_value = False @@ -736,7 +731,6 @@ async def test_send_schema_ledger_read_only( mock_create_config, mock_set_proto, ): - mock_wallet = async_mock.MagicMock() self.session.context.injector.bind_provider(BaseWallet, mock_wallet) @@ -778,7 +772,6 @@ async def test_send_schema_issuer_error( mock_create_config, mock_set_proto, ): - mock_wallet = async_mock.MagicMock() self.session.context.injector.bind_provider(BaseWallet, mock_wallet) mock_is_ledger_read_only.return_value = False @@ -823,7 +816,6 @@ async def test_send_schema_ledger_transaction_error( mock_create_config, mock_set_proto, ): - mock_wallet = async_mock.MagicMock() self.session.context.injector.bind_provider(BaseWallet, mock_wallet) diff --git a/aries_cloudagent/ledger/tests/test_routes.py b/aries_cloudagent/ledger/tests/test_routes.py index 95bce0d497..14853fc6bb 100644 --- a/aries_cloudagent/ledger/tests/test_routes.py +++ b/aries_cloudagent/ledger/tests/test_routes.py @@ -418,7 +418,6 @@ async def test_register_nym_create_transaction_for_endorser_storage_x(self): ) as mock_conn_rec_retrieve, async_mock.patch.object( test_module, "TransactionManager", async_mock.MagicMock() ) as mock_txn_mgr: - mock_txn_mgr.return_value = async_mock.MagicMock( create_record=async_mock.AsyncMock( side_effect=test_module.StorageError() diff --git a/aries_cloudagent/messaging/credential_definitions/tests/test_routes.py b/aries_cloudagent/messaging/credential_definitions/tests/test_routes.py index 24b5a41bda..3a0cccb1b2 100644 --- a/aries_cloudagent/messaging/credential_definitions/tests/test_routes.py +++ b/aries_cloudagent/messaging/credential_definitions/tests/test_routes.py @@ -158,7 +158,6 @@ async def test_send_credential_definition_create_transaction_for_endorser_storag ) as mock_conn_rec_retrieve, async_mock.patch.object( test_module, "TransactionManager", async_mock.MagicMock() ) as mock_txn_mgr: - mock_conn_rec_retrieve.return_value = async_mock.MagicMock( metadata_get=async_mock.CoroutineMock( return_value={ diff --git a/aries_cloudagent/messaging/decorators/tests/test_decorator_set.py b/aries_cloudagent/messaging/decorators/tests/test_decorator_set.py index bed13f62c7..96e2c034af 100644 --- a/aries_cloudagent/messaging/decorators/tests/test_decorator_set.py +++ b/aries_cloudagent/messaging/decorators/tests/test_decorator_set.py @@ -33,7 +33,6 @@ def test_deco_set(self): assert all(k in deco_set.models for k in DEFAULT_MODELS) def test_extract(self): - decor_value = {} message = {"~decorator": decor_value, "one": "TWO"} @@ -47,7 +46,6 @@ def test_extract(self): assert remain == {"one": "TWO"} def test_dict(self): - decors = BaseDecoratorSet() decors["test"] = "TEST" assert decors["test"] == "TEST" @@ -55,7 +53,6 @@ def test_dict(self): assert result == {"~test": "TEST"} def test_decorator_model(self): - decor_value = {} message = {"~test": {"value": "TEST"}} @@ -70,7 +67,6 @@ def test_decorator_model(self): assert result == message def test_field_decorator(self): - decor_value = {} message = {"test~decorator": decor_value, "one": "TWO"} @@ -86,7 +82,6 @@ def test_field_decorator(self): assert "test~decorator" in decors.to_dict() def test_skip_decorator(self): - decor_value = {} message = {"handled~decorator": decor_value, "one": "TWO"} diff --git a/aries_cloudagent/messaging/decorators/tests/test_localization_decorator.py b/aries_cloudagent/messaging/decorators/tests/test_localization_decorator.py index 93e7e32d4b..6140f4e1f4 100644 --- a/aries_cloudagent/messaging/decorators/tests/test_localization_decorator.py +++ b/aries_cloudagent/messaging/decorators/tests/test_localization_decorator.py @@ -4,7 +4,6 @@ class TestThreadDecorator(TestCase): - LOCALE = "en-ca" LOCALIZABLE = ["a", "b"] CATALOGS = ["http://192.168.56.111/my-project/catalog.json"] diff --git a/aries_cloudagent/messaging/decorators/tests/test_thread_decorator.py b/aries_cloudagent/messaging/decorators/tests/test_thread_decorator.py index 898930233f..8ad7be4878 100644 --- a/aries_cloudagent/messaging/decorators/tests/test_thread_decorator.py +++ b/aries_cloudagent/messaging/decorators/tests/test_thread_decorator.py @@ -4,14 +4,12 @@ class TestThreadDecorator(TestCase): - thread_id = "tid-001" parent_id = "tid-000" sender_order = 1 received_orders = {"did": 2} def test_init(self): - decorator = ThreadDecorator( thid=self.thread_id, pthid=self.parent_id, @@ -24,7 +22,6 @@ def test_init(self): assert decorator.received_orders == self.received_orders def test_serialize_load(self): - decorator = ThreadDecorator( thid=self.thread_id, pthid=self.parent_id, diff --git a/aries_cloudagent/messaging/decorators/tests/test_trace_decorator.py b/aries_cloudagent/messaging/decorators/tests/test_trace_decorator.py index 2d2613fe96..b67da74477 100644 --- a/aries_cloudagent/messaging/decorators/tests/test_trace_decorator.py +++ b/aries_cloudagent/messaging/decorators/tests/test_trace_decorator.py @@ -4,7 +4,6 @@ class TestTraceDecorator(TestCase): - target_api = "http://example.com/api/trace/" full_thread_api = False target_msg = TRACE_MESSAGE_TARGET @@ -20,7 +19,6 @@ class TestTraceDecorator(TestCase): outcome = "OK ..." def test_init_api(self): - decorator = TraceDecorator( target=self.target_api, full_thread=self.full_thread_api, @@ -29,7 +27,6 @@ def test_init_api(self): assert decorator.full_thread == self.full_thread_api def test_init_message(self): - x_msg_id = self.msg_id x_thread_id = self.thread_id x_trace_report = TraceReport( @@ -64,7 +61,6 @@ def test_init_message(self): assert trace_report.outcome == self.outcome def test_serialize_load(self): - x_msg_id = self.msg_id x_thread_id = self.thread_id x_trace_report = TraceReport( diff --git a/aries_cloudagent/messaging/jsonld/routes.py b/aries_cloudagent/messaging/jsonld/routes.py index eb3b7b48c2..f89db9752a 100644 --- a/aries_cloudagent/messaging/jsonld/routes.py +++ b/aries_cloudagent/messaging/jsonld/routes.py @@ -84,7 +84,7 @@ async def sign(request: web.BaseRequest): session, doc.get("credential"), doc.get("options"), body.get("verkey") ) response["signed_doc"] = doc_with_proof - except (BaseJSONLDMessagingError) as err: + except BaseJSONLDMessagingError as err: response["error"] = str(err) except (WalletError, InjectionError): raise web.HTTPForbidden(reason="No wallet available") diff --git a/aries_cloudagent/messaging/schemas/tests/test_routes.py b/aries_cloudagent/messaging/schemas/tests/test_routes.py index 91a826d628..f5347a6b2b 100644 --- a/aries_cloudagent/messaging/schemas/tests/test_routes.py +++ b/aries_cloudagent/messaging/schemas/tests/test_routes.py @@ -157,7 +157,6 @@ async def test_send_schema_create_transaction_for_endorser_storage_x(self): ) as mock_conn_rec_retrieve, async_mock.patch.object( test_module, "TransactionManager", async_mock.MagicMock() ) as mock_txn_mgr: - mock_txn_mgr.return_value = async_mock.MagicMock( create_record=async_mock.CoroutineMock( side_effect=test_module.StorageError() diff --git a/aries_cloudagent/multitenant/base.py b/aries_cloudagent/multitenant/base.py index ae5f5c60bd..9e242d3351 100644 --- a/aries_cloudagent/multitenant/base.py +++ b/aries_cloudagent/multitenant/base.py @@ -378,7 +378,7 @@ async def _get_wallet_by_key(self, recipient_key: str) -> Optional[WalletRecord] ) return wallet - except (RouteNotFoundError): + except RouteNotFoundError: pass async def get_profile_for_key( diff --git a/aries_cloudagent/multitenant/route_manager.py b/aries_cloudagent/multitenant/route_manager.py index ff8f1d37e7..d430aa0c51 100644 --- a/aries_cloudagent/multitenant/route_manager.py +++ b/aries_cloudagent/multitenant/route_manager.py @@ -66,7 +66,7 @@ async def _route_for_key( # If no error is thrown, it means there is already a record return None - except (StorageNotFoundError): + except StorageNotFoundError: pass await routing_mgr.create_route_record( diff --git a/aries_cloudagent/multitenant/tests/test_base.py b/aries_cloudagent/multitenant/tests/test_base.py index a58cbc9375..c302b44813 100644 --- a/aries_cloudagent/multitenant/tests/test_base.py +++ b/aries_cloudagent/multitenant/tests/test_base.py @@ -209,7 +209,6 @@ async def test_create_wallet_fails_if_wallet_name_exists(self): ) async def test_create_wallet_saves_wallet_record_creates_profile(self): - mock_route_manager = async_mock.MagicMock() mock_route_manager.route_public_did = async_mock.CoroutineMock() self.context.injector.bind_instance(RouteManager, mock_route_manager) diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/tests/test_routes.py b/aries_cloudagent/protocols/actionmenu/v1_0/tests/test_routes.py index 48148e5ff9..f766d9a77f 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/tests/test_routes.py @@ -78,7 +78,6 @@ async def test_actionmenu_perform(self): ) as mock_perform, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_conn_record.retrieve_by_id = async_mock.CoroutineMock() res = await test_module.actionmenu_perform(self.request) @@ -97,7 +96,6 @@ async def test_actionmenu_perform_no_conn_record(self): ) as mock_conn_record, async_mock.patch.object( test_module, "Perform", autospec=True ) as mock_perform: - # Emulate storage not found (bad connection id) mock_conn_record.retrieve_by_id = async_mock.CoroutineMock( side_effect=StorageNotFoundError @@ -115,7 +113,6 @@ async def test_actionmenu_perform_conn_not_ready(self): ) as mock_conn_record, async_mock.patch.object( test_module, "Perform", autospec=True ) as mock_perform: - # Emulate connection not ready mock_conn_record.retrieve_by_id = async_mock.CoroutineMock() mock_conn_record.retrieve_by_id.return_value.is_ready = False @@ -134,7 +131,6 @@ async def test_actionmenu_request(self): ) as menu_request, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_conn_record.retrieve_by_id = async_mock.CoroutineMock() res = await test_module.actionmenu_request(self.request) @@ -153,7 +149,6 @@ async def test_actionmenu_request_no_conn_record(self): ) as mock_conn_record, async_mock.patch.object( test_module, "Perform", autospec=True ) as mock_perform: - # Emulate storage not found (bad connection id) mock_conn_record.retrieve_by_id = async_mock.CoroutineMock( side_effect=StorageNotFoundError @@ -171,7 +166,6 @@ async def test_actionmenu_request_conn_not_ready(self): ) as mock_conn_record, async_mock.patch.object( test_module, "Perform", autospec=True ) as mock_perform: - # Emulate connection not ready mock_conn_record.retrieve_by_id = async_mock.CoroutineMock() mock_conn_record.retrieve_by_id.return_value.is_ready = False @@ -190,7 +184,6 @@ async def test_actionmenu_send(self): ) as mock_menu, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_conn_record.retrieve_by_id = async_mock.CoroutineMock() mock_menu.deserialize = async_mock.MagicMock() @@ -210,7 +203,6 @@ async def test_actionmenu_send_deserialize_x(self): ) as mock_conn_record, async_mock.patch.object( test_module, "Menu", autospec=True ) as mock_menu: - mock_conn_record.retrieve_by_id = async_mock.CoroutineMock() mock_menu.deserialize = async_mock.MagicMock( side_effect=test_module.BaseModelError("cannot deserialize") @@ -228,7 +220,6 @@ async def test_actionmenu_send_no_conn_record(self): ) as mock_conn_record, async_mock.patch.object( test_module, "Menu", autospec=True ) as mock_menu: - mock_menu.deserialize = async_mock.MagicMock() # Emulate storage not found (bad connection id) @@ -248,7 +239,6 @@ async def test_actionmenu_send_conn_not_ready(self): ) as mock_conn_record, async_mock.patch.object( test_module, "Menu", autospec=True ) as mock_menu: - mock_menu.deserialize = async_mock.MagicMock() # Emulate connection not ready diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/tests/test_service.py b/aries_cloudagent/protocols/actionmenu/v1_0/tests/test_service.py index 8a94c08361..4573997115 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/tests/test_service.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/tests/test_service.py @@ -17,8 +17,8 @@ async def test_get_active_menu(self): mock_event_bus = MockEventBus() self.context.profile.context.injector.bind_instance(EventBus, mock_event_bus) - self.menu_service = await ( - test_module.DriverMenuService.service_handler()(self.context) + self.menu_service = await test_module.DriverMenuService.service_handler()( + self.context ) connection = async_mock.MagicMock() @@ -41,8 +41,8 @@ async def test_perform_menu_action(self): mock_event_bus = MockEventBus() self.context.profile.context.injector.bind_instance(EventBus, mock_event_bus) - self.menu_service = await ( - test_module.DriverMenuService.service_handler()(self.context) + self.menu_service = await test_module.DriverMenuService.service_handler()( + self.context ) action_name = "action" diff --git a/aries_cloudagent/protocols/basicmessage/v1_0/tests/test_routes.py b/aries_cloudagent/protocols/basicmessage/v1_0/tests/test_routes.py index 6265cbd762..ca730021b0 100644 --- a/aries_cloudagent/protocols/basicmessage/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/basicmessage/v1_0/tests/test_routes.py @@ -34,7 +34,6 @@ async def test_connections_send_message(self): ) as mock_basic_message, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_connection_record.retrieve_by_id = async_mock.CoroutineMock() res = await test_module.connections_send_message(self.request) @@ -50,7 +49,6 @@ async def test_connections_send_message_no_conn_record(self): ) as mock_connection_record, async_mock.patch.object( test_module, "BasicMessage", autospec=True ) as mock_basic_message: - # Emulate storage not found (bad connection id) mock_connection_record.retrieve_by_id = async_mock.CoroutineMock( side_effect=StorageNotFoundError @@ -68,7 +66,6 @@ async def test_connections_send_message_not_ready(self): ) as mock_connection_record, async_mock.patch.object( test_module, "BasicMessage", autospec=True ) as mock_basic_message: - # Emulate connection not ready mock_connection_record.retrieve_by_id = async_mock.CoroutineMock() mock_connection_record.retrieve_by_id.return_value.is_ready = False diff --git a/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_invitation.py b/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_invitation.py index 58d38b5917..b35bf95e1a 100644 --- a/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_invitation.py +++ b/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_invitation.py @@ -84,7 +84,6 @@ def test_from_no_url(self): class TestConnectionInvitationSchema(TestCase): - connection_invitation = ConnectionInvitation( label="label", did="did:sov:QmWbsNYhMrjHiqZDTUTEJs" ) diff --git a/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_response.py b/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_response.py index fd47e9c896..0fadf94ff4 100644 --- a/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_response.py +++ b/aries_cloudagent/protocols/connections/v1_0/messages/tests/test_connection_response.py @@ -19,7 +19,6 @@ class TestConfig: - test_seed = "testseed000000000000000000000001" test_did = "55GkHamhTU1ZbTbV2ab9DE" test_verkey = "3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx" diff --git a/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py b/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py index 5886e5aed9..274ef8b6e6 100644 --- a/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py @@ -360,7 +360,6 @@ async def test_connections_create_invitation(self): ) as mock_conn_mgr, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_conn_mgr.return_value.create_invitation = async_mock.CoroutineMock( return_value=( async_mock.MagicMock( # connection record @@ -543,7 +542,6 @@ async def test_connections_accept_invitation(self): ) as mock_conn_mgr, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_conn_rec_retrieve_by_id.return_value = mock_conn_rec mock_conn_mgr.return_value.create_request = async_mock.CoroutineMock() diff --git a/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py index 30ae59db04..f5ddf31b4d 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/tests/test_manager.py @@ -41,7 +41,6 @@ class TestConfig: - test_seed = "testseed000000000000000000000001" test_did = "55GkHamhTU1ZbTbV2ab9DE" test_verkey = "3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx" diff --git a/aries_cloudagent/protocols/didexchange/v1_0/tests/test_routes.py b/aries_cloudagent/protocols/didexchange/v1_0/tests/test_routes.py index 44584c5d1e..8de2345b31 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/tests/test_routes.py @@ -43,7 +43,6 @@ async def test_didx_accept_invitation(self): ) as mock_didx_mgr, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_conn_rec_class.retrieve_by_id.return_value = mock_conn_rec mock_didx_mgr.return_value.create_request = async_mock.CoroutineMock() diff --git a/aries_cloudagent/protocols/discovery/v1_0/messages/tests/test_disclose.py b/aries_cloudagent/protocols/discovery/v1_0/messages/tests/test_disclose.py index 658f25bc67..84e02cf12e 100644 --- a/aries_cloudagent/protocols/discovery/v1_0/messages/tests/test_disclose.py +++ b/aries_cloudagent/protocols/discovery/v1_0/messages/tests/test_disclose.py @@ -42,7 +42,6 @@ def test_serialize(self, mock_disclose_schema_dump): class TestDiscloseSchema(TestCase): - disclose = Disclose(protocols=[]) def test_make_model(self): diff --git a/aries_cloudagent/protocols/discovery/v1_0/messages/tests/test_query.py b/aries_cloudagent/protocols/discovery/v1_0/messages/tests/test_query.py index 114c02f80c..18af3b6ba7 100644 --- a/aries_cloudagent/protocols/discovery/v1_0/messages/tests/test_query.py +++ b/aries_cloudagent/protocols/discovery/v1_0/messages/tests/test_query.py @@ -39,7 +39,6 @@ def test_serialize(self, mock_query_schema_dump): class TestQuerySchema(TestCase): - query = Query(query="*", comment="comment") def test_make_model(self): diff --git a/aries_cloudagent/protocols/discovery/v2_0/messages/tests/test_queries.py b/aries_cloudagent/protocols/discovery/v2_0/messages/tests/test_queries.py index e8957dc912..01dfa793f3 100644 --- a/aries_cloudagent/protocols/discovery/v2_0/messages/tests/test_queries.py +++ b/aries_cloudagent/protocols/discovery/v2_0/messages/tests/test_queries.py @@ -60,7 +60,6 @@ def test_serialize(self, mock_queries_schema_dump): class TestQuerySchema(TestCase): - test_queries = [ QueryItem(feature_type="protocol", match=TEST_QUERY_PROTOCOL), QueryItem(feature_type="goal-code", match=TEST_QUERY_GOAL_CODE), diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py index f4b2719237..df10ffe4ee 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_manager.py @@ -496,7 +496,6 @@ async def test_complete_transaction(self): ) as save_record, async_mock.patch.object( ConnRecord, "retrieve_by_id" ) as mock_conn_rec_retrieve: - mock_conn_rec_retrieve.return_value = async_mock.MagicMock( metadata_get=async_mock.CoroutineMock( return_value={ diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py index 611d1245ce..4d6e3b0897 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/tests/test_routes.py @@ -1553,7 +1553,6 @@ async def test_transaction_write_schema_txn(self): ) as mock_txn_mgr, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_txn_mgr.return_value.complete_transaction = async_mock.CoroutineMock() mock_txn_mgr.return_value.complete_transaction.return_value = ( @@ -1600,7 +1599,6 @@ async def test_transaction_write_wrong_state_x(self): with async_mock.patch.object( TransactionRecord, "retrieve_by_id", async_mock.CoroutineMock() ) as mock_txn_rec_retrieve: - mock_txn_rec_retrieve.return_value = async_mock.MagicMock( serialize=async_mock.MagicMock(return_value={"...": "..."}), state=TransactionRecord.STATE_TRANSACTION_CREATED, diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/manager.py b/aries_cloudagent/protocols/issue_credential/v1_0/manager.py index 90d1a15217..1bca37dea8 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/manager.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/manager.py @@ -356,13 +356,15 @@ async def receive_offer( # Get credential exchange record (holder sent proposal first) # or create it (issuer sent offer first) try: - cred_ex_record = await ( - V10CredentialExchange.retrieve_by_connection_and_thread( - txn, - connection_id, - message._thread_id, - role=V10CredentialExchange.ROLE_HOLDER, - for_update=True, + cred_ex_record = ( + await ( + V10CredentialExchange.retrieve_by_connection_and_thread( + txn, + connection_id, + message._thread_id, + role=V10CredentialExchange.ROLE_HOLDER, + for_update=True, + ) ) ) except StorageNotFoundError: # issuer sent this offer free of any proposal @@ -532,13 +534,15 @@ async def receive_request( async with self._profile.transaction() as txn: try: - cred_ex_record = await ( - V10CredentialExchange.retrieve_by_connection_and_thread( - txn, - connection_id, - message._thread_id, - role=V10CredentialExchange.ROLE_ISSUER, - for_update=True, + cred_ex_record = ( + await ( + V10CredentialExchange.retrieve_by_connection_and_thread( + txn, + connection_id, + message._thread_id, + role=V10CredentialExchange.ROLE_ISSUER, + for_update=True, + ) ) ) except StorageNotFoundError: @@ -741,13 +745,15 @@ async def receive_credential( async with self._profile.transaction() as txn: try: - cred_ex_record = await ( - V10CredentialExchange.retrieve_by_connection_and_thread( - txn, - connection_id, - message._thread_id, - role=V10CredentialExchange.ROLE_HOLDER, - for_update=True, + cred_ex_record = ( + await ( + V10CredentialExchange.retrieve_by_connection_and_thread( + txn, + connection_id, + message._thread_id, + role=V10CredentialExchange.ROLE_HOLDER, + for_update=True, + ) ) ) except StorageNotFoundError: @@ -947,13 +953,15 @@ async def receive_credential_ack( """ async with self._profile.transaction() as txn: try: - cred_ex_record = await ( - V10CredentialExchange.retrieve_by_connection_and_thread( - txn, - connection_id, - message._thread_id, - role=V10CredentialExchange.ROLE_ISSUER, - for_update=True, + cred_ex_record = ( + await ( + V10CredentialExchange.retrieve_by_connection_and_thread( + txn, + connection_id, + message._thread_id, + role=V10CredentialExchange.ROLE_ISSUER, + for_update=True, + ) ) ) except StorageNotFoundError: @@ -987,9 +995,11 @@ async def receive_problem_report( """ async with self._profile.transaction() as txn: try: - cred_ex_record = await ( - V10CredentialExchange.retrieve_by_connection_and_thread( - txn, connection_id, message._thread_id, for_update=True + cred_ex_record = ( + await ( + V10CredentialExchange.retrieve_by_connection_and_thread( + txn, connection_id, message._thread_id, for_update=True + ) ) ) except StorageNotFoundError: diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/issue_credential/v1_0/tests/test_manager.py index 94ec08f0f6..838f5abdf4 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/tests/test_manager.py @@ -1357,7 +1357,6 @@ async def test_store_credential(self): ) as save_ex, async_mock.patch.object( V10CredentialExchange, "delete_record", autospec=True ) as delete_ex: - mock_rev_reg.from_definition = async_mock.MagicMock( return_value=async_mock.MagicMock( get_or_fetch_local_tails_path=async_mock.CoroutineMock() diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/tests/test_routes.py b/aries_cloudagent/protocols/issue_credential/v1_0/tests/test_routes.py index 1afc367d20..129f7eceb1 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/tests/test_routes.py @@ -253,7 +253,6 @@ async def test_credential_exchange_send_no_conn_record(self): ) as mock_conn_rec, async_mock.patch.object( test_module, "CredentialManager", autospec=True ) as mock_credential_manager: - # Emulate storage not found (bad connection id) mock_conn_rec.retrieve_by_id = async_mock.CoroutineMock( side_effect=test_module.StorageNotFoundError() @@ -280,7 +279,6 @@ async def test_credential_exchange_send_not_ready(self): ) as mock_conn_rec, async_mock.patch.object( test_module, "CredentialManager", autospec=True ) as mock_credential_manager: - # Emulate connection not ready mock_conn_rec.retrieve_by_id.return_value.is_ready = False @@ -343,7 +341,6 @@ async def test_credential_exchange_send_proposal(self): ) as mock_credential_manager, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_cred_ex_record = async_mock.MagicMock() mock_credential_manager.return_value.create_proposal.return_value = ( mock_cred_ex_record @@ -367,7 +364,6 @@ async def test_credential_exchange_send_proposal_no_conn_record(self): ) as mock_credential_manager, async_mock.patch.object( test_module.CredentialPreview, "deserialize", autospec=True ) as mock_preview_deserialize: - # Emulate storage not found (bad connection id) mock_conn_rec.retrieve_by_id = async_mock.CoroutineMock( side_effect=test_module.StorageNotFoundError() @@ -405,7 +401,6 @@ async def test_credential_exchange_send_proposal_not_ready(self): ) as mock_credential_manager, async_mock.patch.object( test_module.CredentialPreview, "deserialize", autospec=True ) as mock_preview_deserialize: - # Emulate connection not ready mock_conn_rec.retrieve_by_id = async_mock.CoroutineMock() mock_conn_rec.retrieve_by_id.return_value.is_ready = False @@ -595,7 +590,6 @@ async def test_credential_exchange_send_free_offer(self): ) as mock_credential_manager, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_credential_manager.return_value.create_offer = ( async_mock.CoroutineMock() ) @@ -647,7 +641,6 @@ async def test_credential_exchange_send_free_offer_no_conn_record(self): ) as mock_conn_rec, async_mock.patch.object( test_module, "CredentialManager", autospec=True ) as mock_credential_manager: - # Emulate storage not found (bad connection id) mock_conn_rec.retrieve_by_id = async_mock.CoroutineMock( side_effect=test_module.StorageNotFoundError() @@ -673,7 +666,6 @@ async def test_credential_exchange_send_free_offer_not_ready(self): ) as mock_conn_rec, async_mock.patch.object( test_module, "CredentialManager", autospec=True ) as mock_credential_manager: - # Emulate connection not ready mock_conn_rec.retrieve_by_id = async_mock.CoroutineMock() mock_conn_rec.retrieve_by_id.return_value.is_ready = False @@ -739,7 +731,6 @@ async def test_credential_exchange_send_bound_offer(self): ) as mock_cred_ex, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_cred_ex.retrieve_by_id = async_mock.CoroutineMock() mock_cred_ex.retrieve_by_id.return_value.state = ( mock_cred_ex.STATE_PROPOSAL_RECEIVED @@ -878,7 +869,6 @@ async def test_credential_exchange_send_request(self): ) as mock_cred_ex, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_cred_ex.retrieve_by_id = async_mock.CoroutineMock() mock_cred_ex.retrieve_by_id.return_value.state = ( mock_cred_ex.STATE_OFFER_RECEIVED @@ -912,7 +902,6 @@ async def test_credential_exchange_send_request_no_conn(self): ) as mock_cred_ex, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_oob_rec.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=async_mock.MagicMock(our_recipient_key="our-recipient_key") ) @@ -1037,7 +1026,6 @@ async def test_credential_exchange_issue(self): ) as mock_cred_ex, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_cred_ex.retrieve_by_id = async_mock.CoroutineMock() mock_cred_ex.retrieve_by_id.return_value.state = ( mock_cred_ex.STATE_REQUEST_RECEIVED @@ -1087,7 +1075,6 @@ async def test_credential_exchange_issue_no_conn_record(self): ) as mock_credential_manager, async_mock.patch.object( test_module, "V10CredentialExchange", autospec=True ) as mock_cred_ex_cls: - mock_cred_ex_rec.state = mock_cred_ex_cls.STATE_REQUEST_RECEIVED mock_cred_ex_cls.retrieve_by_id = async_mock.CoroutineMock( return_value=mock_cred_ex_rec @@ -1120,7 +1107,6 @@ async def test_credential_exchange_issue_not_ready(self): ) as mock_credential_manager, async_mock.patch.object( test_module, "V10CredentialExchange", autospec=True ) as mock_cred_ex: - mock_cred_ex.retrieve_by_id = async_mock.CoroutineMock() mock_cred_ex.retrieve_by_id.return_value.state = ( mock_cred_ex.STATE_REQUEST_RECEIVED @@ -1216,7 +1202,6 @@ async def test_credential_exchange_store(self): ) as mock_cred_ex, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_cred_ex.retrieve_by_id = async_mock.CoroutineMock() mock_cred_ex.retrieve_by_id.return_value.state = ( mock_cred_ex.STATE_CREDENTIAL_RECEIVED @@ -1253,7 +1238,6 @@ async def test_credential_exchange_store_bad_cred_id_json(self): ) as mock_cred_ex, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_cred_ex.retrieve_by_id = async_mock.CoroutineMock() mock_cred_ex.retrieve_by_id.return_value.state = ( mock_cred_ex.STATE_CREDENTIAL_RECEIVED diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py index ea4565a6b6..f0e11070e6 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py @@ -274,7 +274,6 @@ async def test_get_suite_for_detail(self): "_did_info_for_did", async_mock.CoroutineMock(), ) as mock_did_info: - suite = await self.handler._get_suite_for_detail(detail) assert suite.signature_type == detail.options.proof_type diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/manager.py b/aries_cloudagent/protocols/issue_credential/v2_0/manager.py index f1d3f541c3..ad6f3f9313 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/manager.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/manager.py @@ -284,13 +284,11 @@ async def receive_offer( # or create it (issuer sent offer first) try: async with self._profile.session() as session: - cred_ex_record = await ( - V20CredExRecord.retrieve_by_conn_and_thread( - session, - connection_id, - cred_offer_message._thread_id, - role=V20CredExRecord.ROLE_HOLDER, - ) + cred_ex_record = await V20CredExRecord.retrieve_by_conn_and_thread( + session, + connection_id, + cred_offer_message._thread_id, + role=V20CredExRecord.ROLE_HOLDER, ) except StorageNotFoundError: # issuer sent this offer free of any proposal cred_ex_record = V20CredExRecord( @@ -420,13 +418,11 @@ async def receive_request( async with self._profile.session() as session: try: - cred_ex_record = await ( - V20CredExRecord.retrieve_by_conn_and_thread( - session, - connection_id, - cred_request_message._thread_id, - role=V20CredExRecord.ROLE_ISSUER, - ) + cred_ex_record = await V20CredExRecord.retrieve_by_conn_and_thread( + session, + connection_id, + cred_request_message._thread_id, + role=V20CredExRecord.ROLE_ISSUER, ) except StorageNotFoundError: # holder sent this request free of any offer @@ -553,13 +549,11 @@ async def receive_credential( # FIXME use transaction, fetch for_update async with self._profile.session() as session: - cred_ex_record = await ( - V20CredExRecord.retrieve_by_conn_and_thread( - session, - connection_id, - cred_issue_message._thread_id, - role=V20CredExRecord.ROLE_HOLDER, - ) + cred_ex_record = await V20CredExRecord.retrieve_by_conn_and_thread( + session, + connection_id, + cred_issue_message._thread_id, + role=V20CredExRecord.ROLE_HOLDER, ) cred_request_message = cred_ex_record.cred_request @@ -697,13 +691,11 @@ async def receive_credential_ack( """ # FIXME use transaction, fetch for_update async with self._profile.session() as session: - cred_ex_record = await ( - V20CredExRecord.retrieve_by_conn_and_thread( - session, - connection_id, - cred_ack_message._thread_id, - role=V20CredExRecord.ROLE_ISSUER, - ) + cred_ex_record = await V20CredExRecord.retrieve_by_conn_and_thread( + session, + connection_id, + cred_ack_message._thread_id, + role=V20CredExRecord.ROLE_ISSUER, ) cred_ex_record.state = V20CredExRecord.STATE_DONE @@ -740,12 +732,10 @@ async def receive_problem_report( """ # FIXME use transaction, fetch for_update async with self._profile.session() as session: - cred_ex_record = await ( - V20CredExRecord.retrieve_by_conn_and_thread( - session, - connection_id, - message._thread_id, - ) + cred_ex_record = await V20CredExRecord.retrieve_by_conn_and_thread( + session, + connection_id, + message._thread_id, ) cred_ex_record.state = V20CredExRecord.STATE_ABANDONED diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_manager.py b/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_manager.py index 583f52e9c5..55d654c5f1 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_manager.py @@ -165,7 +165,6 @@ async def test_create_proposal(self): ) as mock_save, async_mock.patch.object( V20CredFormat.Format, "handler" ) as mock_handler: - mock_handler.return_value.create_proposal = async_mock.CoroutineMock( return_value=( V20CredFormat( @@ -209,7 +208,6 @@ async def test_create_proposal_no_preview(self): ) as mock_save, async_mock.patch.object( V20CredFormat.Format, "handler" ) as mock_handler: - mock_handler.return_value.create_proposal = async_mock.CoroutineMock( return_value=( V20CredFormat( @@ -261,7 +259,6 @@ async def test_receive_proposal(self): ) as mock_save, async_mock.patch.object( V20CredFormat.Format, "handler" ) as mock_handler: - mock_handler.return_value.receive_proposal = async_mock.CoroutineMock() cred_proposal = V20CredProposal( @@ -335,7 +332,6 @@ async def test_create_free_offer(self): ) as mock_save, async_mock.patch.object( V20CredFormat.Format, "handler" ) as mock_handler: - mock_handler.return_value.create_offer = async_mock.CoroutineMock( return_value=( V20CredFormat( @@ -627,7 +623,6 @@ async def test_create_bound_request(self): ) as mock_save, async_mock.patch.object( V20CredFormat.Format, "handler" ) as mock_handler: - mock_handler.return_value.create_request = async_mock.CoroutineMock( return_value=( V20CredFormat( @@ -715,7 +710,6 @@ async def test_create_free_request(self): ) as mock_save, async_mock.patch.object( V20CredFormat.Format, "handler" ) as mock_handler: - mock_handler.return_value.create_request = async_mock.CoroutineMock( return_value=( V20CredFormat( @@ -986,7 +980,6 @@ async def test_issue_credential(self): ) as mock_save, async_mock.patch.object( V20CredFormat.Format, "handler" ) as mock_handler: - mock_handler.return_value.issue_credential = async_mock.CoroutineMock( return_value=( V20CredFormat( @@ -1099,7 +1092,6 @@ async def test_receive_cred(self): ) as mock_retrieve, async_mock.patch.object( V20CredFormat.Format, "handler" ) as mock_handler: - mock_handler.return_value.receive_credential = async_mock.CoroutineMock() mock_retrieve.return_value = stored_cx_rec ret_cx_rec = await self.manager.receive_credential( @@ -1247,7 +1239,6 @@ async def test_store_credential(self): ) as mock_delete, async_mock.patch.object( V20CredFormat.Format, "handler" ) as mock_handler: - mock_handler.return_value.store_credential = async_mock.CoroutineMock() ret_cx_rec = await self.manager.store_credential( diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_routes.py b/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_routes.py index 7a689b66b4..845f21555c 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/tests/test_routes.py @@ -362,7 +362,6 @@ async def test_credential_exchange_send_request_no_conn_no_holder_did(self): ) as mock_cred_ex, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_oob_rec.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=async_mock.MagicMock(our_recipient_key="our-recipient_key") ) @@ -407,7 +406,6 @@ async def test_credential_exchange_send_no_conn_record(self): ) as mock_conn_rec, async_mock.patch.object( test_module, "V20CredManager", autospec=True ) as mock_cred_mgr: - # Emulate storage not found (bad connection id) mock_conn_rec.retrieve_by_id = async_mock.CoroutineMock( side_effect=test_module.StorageNotFoundError() @@ -584,7 +582,6 @@ async def test_credential_exchange_send_proposal_not_ready(self): ) as mock_cred_mgr, async_mock.patch.object( test_module.V20CredPreview, "deserialize", autospec=True ) as mock_preview_deser: - # Emulate connection not ready mock_conn_rec.retrieve_by_id = async_mock.CoroutineMock() mock_conn_rec.retrieve_by_id.return_value.is_ready = False @@ -731,7 +728,6 @@ async def test_credential_exchange_send_free_offer_no_conn_record(self): ) as mock_conn_rec, async_mock.patch.object( test_module, "V20CredManager", autospec=True ) as mock_cred_mgr: - # Emulate storage not found (bad connection id) mock_conn_rec.retrieve_by_id = async_mock.CoroutineMock( side_effect=test_module.StorageNotFoundError() @@ -762,7 +758,6 @@ async def test_credential_exchange_send_free_offer_not_ready(self): ) as mock_conn_rec, async_mock.patch.object( test_module, "V20CredManager", autospec=True ) as mock_cred_mgr: - # Emulate connection not ready mock_conn_rec.retrieve_by_id = async_mock.CoroutineMock() mock_conn_rec.retrieve_by_id.return_value.is_ready = False @@ -986,7 +981,6 @@ async def test_credential_exchange_send_request(self): ) as mock_cx_rec_cls, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_cx_rec_cls.retrieve_by_id = async_mock.CoroutineMock() mock_cx_rec_cls.retrieve_by_id.return_value.state = ( test_module.V20CredExRecord.STATE_OFFER_RECEIVED @@ -1096,7 +1090,6 @@ async def test_credential_exchange_send_free_request(self): ) as mock_cred_mgr, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_cred_mgr.return_value.create_request = async_mock.CoroutineMock() mock_cx_rec = async_mock.MagicMock() @@ -1131,7 +1124,6 @@ async def test_credential_exchange_send_free_request_no_conn_record(self): ) as mock_conn_rec, async_mock.patch.object( test_module, "V20CredManager", autospec=True ) as mock_cred_mgr: - # Emulate storage not found (bad connection id) mock_conn_rec.retrieve_by_id = async_mock.CoroutineMock( side_effect=test_module.StorageNotFoundError() @@ -1158,7 +1150,6 @@ async def test_credential_exchange_send_free_request_not_ready(self): ) as mock_conn_rec, async_mock.patch.object( test_module, "V20CredManager", autospec=True ) as mock_cred_mgr: - # Emulate connection not ready mock_conn_rec.retrieve_by_id = async_mock.CoroutineMock() mock_conn_rec.retrieve_by_id.return_value.is_ready = False @@ -1186,7 +1177,6 @@ async def test_credential_exchange_send_free_request_x(self): ) as mock_cred_mgr, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_cred_mgr.return_value.create_request = async_mock.CoroutineMock( side_effect=[ test_module.LedgerError(), @@ -1277,7 +1267,6 @@ async def test_credential_exchange_issue_no_conn_record(self): ) as mock_cred_mgr, async_mock.patch.object( test_module, "V20CredExRecord", autospec=True ) as mock_cx_rec_cls: - mock_cx_rec.state = mock_cx_rec_cls.STATE_REQUEST_RECEIVED mock_cx_rec_cls.retrieve_by_id = async_mock.CoroutineMock( return_value=mock_cx_rec @@ -1308,7 +1297,6 @@ async def test_credential_exchange_issue_not_ready(self): ) as mock_cred_mgr, async_mock.patch.object( test_module, "V20CredExRecord", autospec=True ) as mock_cx_rec: - mock_cx_rec.retrieve_by_id = async_mock.CoroutineMock() mock_cx_rec.retrieve_by_id.return_value.state = ( test_module.V20CredExRecord.STATE_REQUEST_RECEIVED @@ -1343,7 +1331,6 @@ async def test_credential_exchange_issue_rev_reg_full(self): ) as mock_cred_mgr, async_mock.patch.object( test_module, "V20CredExRecord", autospec=True ) as mock_cx_rec_cls: - mock_cx_rec.state = mock_cx_rec_cls.STATE_REQUEST_RECEIVED mock_cx_rec_cls.retrieve_by_id = async_mock.CoroutineMock( return_value=mock_cx_rec @@ -1464,7 +1451,6 @@ async def test_credential_exchange_store_bad_cred_id_json(self): ) as mock_ld_proof_get_detail_record, async_mock.patch.object( IndyCredFormatHandler, "get_detail_record", autospec=True ) as mock_indy_get_detail_record: - mock_cx_rec_cls.retrieve_by_id = async_mock.CoroutineMock() mock_cx_rec_cls.retrieve_by_id.return_value.state = ( test_module.V20CredExRecord.STATE_CREDENTIAL_RECEIVED diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/manager.py b/aries_cloudagent/protocols/out_of_band/v1_0/manager.py index b3c3f97311..58d46431f6 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/manager.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/manager.py @@ -273,7 +273,6 @@ async def create_invitation( ).serialize() else: - if not my_endpoint: my_endpoint = self.profile.settings.get("default_endpoint") diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py index 07010c744c..4cbb29ab65 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/tests/test_manager.py @@ -91,7 +91,6 @@ class TestConfig: - test_did = "55GkHamhTU1ZbTbV2ab9DE" test_verkey = "3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx" test_endpoint = "http://localhost" @@ -712,7 +711,6 @@ async def test_create_invitation_public_x_multi_use(self): assert "Cannot create public invitation with" in str(context.exception) async def test_create_invitation_requests_attach_x_multi_use(self): - with self.assertRaises(OutOfBandManagerError) as context: await self.manager.create_invitation( public=False, @@ -1094,7 +1092,6 @@ async def test_receive_reuse_accepted_x(self): mock_retrieve_oob.side_effect = (StorageNotFoundError,) with self.assertRaises(test_module.OutOfBandManagerError) as err: - await self.manager.receive_reuse_accepted_message( reuse_msg_accepted, receipt, self.test_conn_rec ) diff --git a/aries_cloudagent/protocols/present_proof/indy/pres_exch_handler.py b/aries_cloudagent/protocols/present_proof/indy/pres_exch_handler.py index 51c6c264a9..4bff88cc89 100644 --- a/aries_cloudagent/protocols/present_proof/indy/pres_exch_handler.py +++ b/aries_cloudagent/protocols/present_proof/indy/pres_exch_handler.py @@ -194,7 +194,7 @@ async def return_presentation( f"Failed to create revocation state: {e.error_code}, {e.message}" ) raise e - for (referent, precis) in requested_referents.items(): + for referent, precis in requested_referents.items(): if "timestamp" not in precis: continue if referent in requested_credentials["requested_attributes"]: diff --git a/aries_cloudagent/protocols/present_proof/v1_0/handlers/tests/test_presentation_request_handler.py b/aries_cloudagent/protocols/present_proof/v1_0/handlers/tests/test_presentation_request_handler.py index add1efa8e9..83329461a4 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/handlers/tests/test_presentation_request_handler.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/handlers/tests/test_presentation_request_handler.py @@ -102,7 +102,6 @@ async def test_called(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V10PresentationExchange", autospec=True ) as mock_pres_ex_cls: - mock_pres_ex_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=px_rec_instance ) @@ -163,7 +162,6 @@ async def test_called_not_found(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V10PresentationExchange", autospec=True ) as mock_pres_ex_cls: - mock_pres_ex_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( side_effect=StorageNotFoundError ) @@ -335,7 +333,6 @@ async def test_called_auto_present_x(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V10PresentationExchange", autospec=True ) as mock_pres_ex_cls: - mock_pres_ex_cls.return_value = mock_px_rec mock_pres_ex_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=mock_px_rec @@ -415,7 +412,6 @@ async def test_called_auto_present_no_preview(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V10PresentationExchange", autospec=True ) as mock_pres_ex_cls: - mock_pres_ex_cls.return_value = px_rec_instance mock_pres_ex_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=px_rec_instance @@ -491,7 +487,6 @@ async def test_called_auto_present_pred_no_match(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V10PresentationExchange", autospec=True ) as mock_pres_ex_cls: - mock_pres_ex_cls.return_value = px_rec_instance mock_pres_ex_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=px_rec_instance @@ -565,7 +560,6 @@ async def test_called_auto_present_pred_single_match(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V10PresentationExchange", autospec=True ) as mock_pres_ex_cls: - mock_pres_ex_cls.return_value = px_rec_instance mock_pres_ex_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=px_rec_instance @@ -646,7 +640,6 @@ async def test_called_auto_present_pred_multi_match(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V10PresentationExchange", autospec=True ) as mock_pres_ex_cls: - mock_pres_ex_cls.return_value = px_rec_instance mock_pres_ex_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=px_rec_instance @@ -778,7 +771,6 @@ async def test_called_auto_present_multi_cred_match_reft(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V10PresentationExchange", autospec=True ) as mock_pres_ex_cls: - mock_pres_ex_cls.return_value = px_rec_instance mock_pres_ex_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=px_rec_instance @@ -892,7 +884,6 @@ async def test_called_auto_present_bait_and_switch(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V10PresentationExchange", autospec=True ) as mock_pres_ex_cls: - mock_pres_ex_cls.return_value = px_rec_instance mock_pres_ex_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=px_rec_instance diff --git a/aries_cloudagent/protocols/present_proof/v1_0/manager.py b/aries_cloudagent/protocols/present_proof/v1_0/manager.py index 2f3af46da5..7453506a45 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/manager.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/manager.py @@ -354,7 +354,7 @@ async def receive_presentation( presentation_preview = exchange_pres_proposal.presentation_proposal proof_req = presentation_exchange_record._presentation_request.ser - for (reft, attr_spec) in presentation["requested_proof"][ + for reft, attr_spec in presentation["requested_proof"][ "revealed_attrs" ].items(): name = proof_req["requested_attributes"][reft]["name"] @@ -540,12 +540,10 @@ async def receive_problem_report( """ # FIXME use transaction, fetch for_update async with self._profile.session() as session: - pres_ex_record = await ( - V10PresentationExchange.retrieve_by_tag_filter( - session, - {"thread_id": message._thread_id}, - {"connection_id": connection_id}, - ) + pres_ex_record = await V10PresentationExchange.retrieve_by_tag_filter( + session, + {"thread_id": message._thread_id}, + {"connection_id": connection_id}, ) pres_ex_record.state = V10PresentationExchange.STATE_ABANDONED diff --git a/aries_cloudagent/protocols/present_proof/v1_0/tests/test_routes.py b/aries_cloudagent/protocols/present_proof/v1_0/tests/test_routes.py index 555c079b58..77e3ea1ca7 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/tests/test_routes.py @@ -67,7 +67,6 @@ async def test_presentation_exchange_list(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -101,7 +100,6 @@ async def test_presentation_exchange_list_x(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -122,7 +120,6 @@ async def test_presentation_exchange_credentials_list_not_found(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -158,7 +155,6 @@ async def test_presentation_exchange_credentials_x(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -191,7 +187,6 @@ async def test_presentation_exchange_credentials_list_single_referent(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -229,7 +224,6 @@ async def test_presentation_exchange_credentials_list_multiple_referents(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -253,7 +247,6 @@ async def test_presentation_exchange_retrieve(self): ), autospec=True, ) as mock_pres_ex: - # Since we are mocking import importlib.reload(test_module) @@ -280,7 +273,6 @@ async def test_presentation_exchange_retrieve_not_found(self): ), autospec=True, ) as mock_pres_ex: - # Since we are mocking import importlib.reload(test_module) @@ -307,7 +299,6 @@ async def test_presentation_exchange_retrieve_x(self): ), autospec=True, ) as mock_pres_ex: - # Since we are mocking import importlib.reload(test_module) @@ -334,7 +325,6 @@ async def test_presentation_exchange_send_proposal(self): "aries_cloudagent.indy.models.pres_preview.IndyPresPreview", autospec=True, ) as mock_preview: - # Since we are mocking import importlib.reload(test_module) @@ -360,7 +350,6 @@ async def test_presentation_exchange_send_proposal_no_conn_record(self): "aries_cloudagent.connections.models.conn_record.ConnRecord", autospec=True, ) as mock_connection_record: - # Since we are mocking import importlib.reload(test_module) @@ -388,7 +377,6 @@ async def test_presentation_exchange_send_proposal_not_ready(self): ), autospec=True, ) as mock_proposal: - # Since we are mocking import importlib.reload(test_module) @@ -411,7 +399,6 @@ async def test_presentation_exchange_send_proposal_x(self): "aries_cloudagent.indy.models.pres_preview.IndyPresPreview", autospec=True, ) as mock_preview: - # Since we are mocking import importlib.reload(test_module) @@ -456,7 +443,6 @@ async def test_presentation_exchange_create_request(self): "aries_cloudagent.indy.util.generate_pr_nonce", autospec=True, ) as mock_generate_nonce: - # Since we are mocking import importlib.reload(test_module) @@ -510,7 +496,6 @@ async def test_presentation_exchange_create_request_x(self): "aries_cloudagent.indy.util.generate_pr_nonce", autospec=True, ) as mock_generate_nonce: - # Since we are mocking import importlib.reload(test_module) @@ -562,7 +547,6 @@ async def test_presentation_exchange_send_free_request(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -601,7 +585,6 @@ async def test_presentation_exchange_send_free_request_not_found(self): "aries_cloudagent.connections.models.conn_record.ConnRecord", autospec=True, ) as mock_connection_record: - # Since we are mocking import importlib.reload(test_module) @@ -620,7 +603,6 @@ async def test_presentation_exchange_send_free_request_not_ready(self): "aries_cloudagent.connections.models.conn_record.ConnRecord", autospec=True, ) as mock_connection_record: - # Since we are mocking import importlib.reload(test_module) @@ -664,7 +646,6 @@ async def test_presentation_exchange_send_free_request_x(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -731,7 +712,6 @@ async def test_presentation_exchange_send_bound_request(self): "models.presentation_exchange.V10PresentationExchange", autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -793,7 +773,6 @@ async def test_presentation_exchange_send_bound_request_not_found(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -838,7 +817,6 @@ async def test_presentation_exchange_send_bound_request_not_ready(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -883,7 +861,6 @@ async def test_presentation_exchange_send_bound_request_bad_state(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -923,7 +900,6 @@ async def test_presentation_exchange_send_bound_request_x(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -998,7 +974,6 @@ async def test_presentation_exchange_send_presentation(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -1075,7 +1050,6 @@ async def test_presentation_exchange_send_presentation_not_found(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -1120,7 +1094,6 @@ async def test_presentation_exchange_send_presentation_not_ready(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -1150,7 +1123,6 @@ async def test_presentation_exchange_send_presentation_bad_state(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -1196,7 +1168,6 @@ async def test_presentation_exchange_send_presentation_x(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -1251,7 +1222,6 @@ async def test_presentation_exchange_verify_presentation(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -1311,7 +1281,6 @@ async def test_presentation_exchange_verify_presentation_bad_state(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -1354,7 +1323,6 @@ async def test_presentation_exchange_verify_presentation_x(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -1412,7 +1380,6 @@ async def test_presentation_exchange_problem_report(self): ) as mock_problem_report, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - # Since we are mocking import importlib.reload(test_module) @@ -1444,7 +1411,6 @@ async def test_presentation_exchange_problem_report_bad_pres_ex_id(self): ), autospec=True, ) as mock_pres_ex: - # Since we are mocking import importlib.reload(test_module) @@ -1474,7 +1440,6 @@ async def test_presentation_exchange_problem_report_x(self): ) as mock_problem_report, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - # Since we are mocking import importlib.reload(test_module) mock_pres_ex.retrieve_by_id = async_mock.CoroutineMock( @@ -1494,7 +1459,6 @@ async def test_presentation_exchange_remove(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -1523,7 +1487,6 @@ async def test_presentation_exchange_remove_not_found(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) @@ -1545,7 +1508,6 @@ async def test_presentation_exchange_remove_x(self): ), autospec=True, ) as mock_presentation_exchange: - # Since we are mocking import importlib.reload(test_module) diff --git a/aries_cloudagent/protocols/present_proof/v2_0/handlers/tests/test_pres_request_handler.py b/aries_cloudagent/protocols/present_proof/v2_0/handlers/tests/test_pres_request_handler.py index bd1e3d2174..c0e28fa043 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/handlers/tests/test_pres_request_handler.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/handlers/tests/test_pres_request_handler.py @@ -219,7 +219,6 @@ async def test_called(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V20PresExRecord", autospec=True ) as mock_px_rec_cls: - mock_px_rec_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=px_rec_instance ) @@ -279,7 +278,6 @@ async def test_called_not_found(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V20PresExRecord", autospec=True ) as mock_px_rec_cls: - mock_px_rec_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( side_effect=StorageNotFoundError ) @@ -349,7 +347,6 @@ async def test_called_auto_present_x(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V20PresExRecord", autospec=True ) as mock_pres_ex_rec_cls: - mock_pres_ex_rec_cls.return_value = mock_px_rec mock_pres_ex_rec_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=mock_px_rec @@ -419,7 +416,6 @@ async def test_called_auto_present_indy(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V20PresExRecord", autospec=True ) as mock_pres_ex_rec_cls: - mock_pres_ex_rec_cls.return_value = mock_px_rec mock_pres_ex_rec_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=mock_px_rec @@ -494,7 +490,6 @@ async def test_called_auto_present_dif(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V20PresExRecord", autospec=True ) as mock_pres_ex_rec_cls: - mock_pres_ex_rec_cls.return_value = px_rec_instance mock_pres_ex_rec_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=px_rec_instance @@ -565,7 +560,6 @@ async def test_called_auto_present_no_preview(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V20PresExRecord", autospec=True ) as mock_pres_ex_rec_cls: - mock_pres_ex_rec_cls.return_value = px_rec_instance mock_pres_ex_rec_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=px_rec_instance @@ -640,7 +634,6 @@ async def test_called_auto_present_pred_no_match(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V20PresExRecord", autospec=True ) as mock_pres_ex_rec_cls: - mock_pres_ex_rec_cls.return_value = mock_px_rec mock_pres_ex_rec_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=mock_px_rec @@ -705,7 +698,6 @@ async def test_called_auto_present_pred_single_match(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V20PresExRecord", autospec=True ) as mock_pres_ex_rec_cls: - mock_pres_ex_rec_cls.return_value = px_rec_instance mock_pres_ex_rec_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=px_rec_instance @@ -777,7 +769,6 @@ async def test_called_auto_present_pred_multi_match(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V20PresExRecord", autospec=True ) as mock_pres_ex_rec_cls: - mock_pres_ex_rec_cls.return_value = px_rec_instance mock_pres_ex_rec_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=px_rec_instance @@ -894,7 +885,6 @@ async def test_called_auto_present_multi_cred_match_reft(self): ) as mock_pres_mgr, async_mock.patch.object( test_module, "V20PresExRecord", autospec=True ) as mock_pres_ex_rec_cls: - mock_pres_ex_rec_cls.return_value = px_rec_instance mock_pres_ex_rec_cls.retrieve_by_tag_filter = async_mock.CoroutineMock( return_value=px_rec_instance diff --git a/aries_cloudagent/protocols/present_proof/v2_0/manager.py b/aries_cloudagent/protocols/present_proof/v2_0/manager.py index ef542f0c29..ea65e37c64 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/manager.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/manager.py @@ -472,12 +472,10 @@ async def receive_problem_report( """ # FIXME use transaction, fetch for_update async with self._profile.session() as session: - pres_ex_record = await ( - V20PresExRecord.retrieve_by_tag_filter( - session, - {"thread_id": message._thread_id}, - {"connection_id": connection_id}, - ) + pres_ex_record = await V20PresExRecord.retrieve_by_tag_filter( + session, + {"thread_id": message._thread_id}, + {"connection_id": connection_id}, ) pres_ex_record.state = V20PresExRecord.STATE_ABANDONED diff --git a/aries_cloudagent/protocols/present_proof/v2_0/routes.py b/aries_cloudagent/protocols/present_proof/v2_0/routes.py index 02d5b7fff3..68a55087ef 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/routes.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/routes.py @@ -331,7 +331,7 @@ async def _add_nonce(indy_proof_request: Mapping) -> Mapping: def _formats_attach(by_format: Mapping, msg_type: str, spec: str) -> Mapping: """Break out formats and proposals/requests/presentations for v2.0 messages.""" attach = [] - for (fmt_api, item_by_fmt) in by_format.items(): + for fmt_api, item_by_fmt in by_format.items(): if fmt_api == V20PresFormat.Format.INDY.api: attach.append( AttachDecorator.data_base64(mapping=item_by_fmt, ident=fmt_api) @@ -1090,7 +1090,6 @@ async def present_proof_send_presentation(request: web.BaseRequest): if pres_ex_record.connection_id: try: async with profile.session() as session: - conn_record = await ConnRecord.retrieve_by_id( session, pres_ex_record.connection_id ) diff --git a/aries_cloudagent/protocols/routing/v1_0/messages/tests/test_forward.py b/aries_cloudagent/protocols/routing/v1_0/messages/tests/test_forward.py index 4988e052b0..2dea1d988d 100644 --- a/aries_cloudagent/protocols/routing/v1_0/messages/tests/test_forward.py +++ b/aries_cloudagent/protocols/routing/v1_0/messages/tests/test_forward.py @@ -9,7 +9,6 @@ class TestForward(TestCase): - to = "to" msg = {"msg": "body"} diff --git a/aries_cloudagent/revocation/tests/test_routes.py b/aries_cloudagent/revocation/tests/test_routes.py index 34cb11d323..d651a442df 100644 --- a/aries_cloudagent/revocation/tests/test_routes.py +++ b/aries_cloudagent/revocation/tests/test_routes.py @@ -87,7 +87,6 @@ async def test_revoke(self): ) as mock_mgr, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_mgr.return_value.revoke_credential = async_mock.CoroutineMock() await test_module.revoke(self.request) @@ -107,7 +106,6 @@ async def test_revoke_by_cred_ex_id(self): ) as mock_mgr, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_mgr.return_value.revoke_credential = async_mock.CoroutineMock() await test_module.revoke(self.request) @@ -128,7 +126,6 @@ async def test_revoke_not_found(self): ) as mock_mgr, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_mgr.return_value.revoke_credential = async_mock.CoroutineMock( side_effect=test_module.StorageNotFoundError() ) diff --git a/aries_cloudagent/transport/pack_format.py b/aries_cloudagent/transport/pack_format.py index f982748098..76ac70b87f 100644 --- a/aries_cloudagent/transport/pack_format.py +++ b/aries_cloudagent/transport/pack_format.py @@ -69,7 +69,6 @@ async def parse_message( # packed messages are detected by the absence of @type if "@type" not in message_dict: - try: unpack = self.unpack(session, message_body, receipt) message_json = await ( diff --git a/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py b/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py index 3c3643ec1a..c09f9345dc 100644 --- a/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py +++ b/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py @@ -259,7 +259,6 @@ async def test_verify_presentation_x_no_purpose_challenge(self): ) async def test_sign_presentation_x_no_purpose_challenge(self): - with self.assertRaises(LinkedDataProofException) as context: await sign_presentation( presentation=PRESENTATION_UNSIGNED, diff --git a/aries_cloudagent/wallet/bbs.py b/aries_cloudagent/wallet/bbs.py index fd80e24fb7..a204682a73 100644 --- a/aries_cloudagent/wallet/bbs.py +++ b/aries_cloudagent/wallet/bbs.py @@ -102,5 +102,5 @@ def create_bls12381g2_keypair(seed: bytes = None) -> Tuple[bytes, bytes]: try: key_pair = BlsKeyPair.generate_g2(seed) return key_pair.public_key, key_pair.secret_key - except (Exception) as error: + except Exception as error: raise BbsException("Unable to create keypair") from error diff --git a/aries_cloudagent/wallet/indy.py b/aries_cloudagent/wallet/indy.py index ea27f3132b..78356946bb 100644 --- a/aries_cloudagent/wallet/indy.py +++ b/aries_cloudagent/wallet/indy.py @@ -199,9 +199,9 @@ async def __get_keypair_signing_key(self, verkey: str) -> KeyInfo: metadata=key_pair["metadata"], key_type=key_types.from_key_type(key_pair["key_type"]) or BLS12381G2, ) - except (StorageNotFoundError): + except StorageNotFoundError: raise WalletNotFoundError(f"Unknown key: {verkey}") - except (StorageDuplicateError): + except StorageDuplicateError: raise WalletDuplicateError(f"Multiple keys exist for verkey: {verkey}") async def get_signing_key(self, verkey: str) -> KeyInfo: diff --git a/aries_cloudagent/wallet/tests/test_routes.py b/aries_cloudagent/wallet/tests/test_routes.py index 03c1dc57cb..051380c7f8 100644 --- a/aries_cloudagent/wallet/tests/test_routes.py +++ b/aries_cloudagent/wallet/tests/test_routes.py @@ -464,7 +464,6 @@ async def test_set_public_did_no_query_did(self): await test_module.wallet_set_public_did(self.request) async def test_set_public_did_no_ledger(self): - mock_route_manager = async_mock.MagicMock() mock_route_manager.mediation_record_if_id = async_mock.AsyncMock() mock_route_manager.__aenter__ = async_mock.AsyncMock( diff --git a/demo/runners/agent_container.py b/demo/runners/agent_container.py index c18c472ebc..bbcd11be40 100644 --- a/demo/runners/agent_container.py +++ b/demo/runners/agent_container.py @@ -622,7 +622,10 @@ async def create_schema_and_cred_def( random.randint(1, 101), ) ) - (_, cred_def_id,) = await self.register_schema_and_creddef( # schema id + ( + _, + cred_def_id, + ) = await self.register_schema_and_creddef( # schema id schema_name, version, schema_attrs, diff --git a/demo/runners/performance.py b/demo/runners/performance.py index b92125f3b2..02b6d3283e 100644 --- a/demo/runners/performance.py +++ b/demo/runners/performance.py @@ -275,7 +275,6 @@ async def main( wallet_type: str = None, arg_file: str = None, ): - if multi_ledger: genesis = None multi_ledger_config_path = "./demo/multi_ledger_config.yml" diff --git a/docs/conf.py b/docs/conf.py index d3c2d570da..6ed81e5982 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -242,6 +242,7 @@ # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = {"https://docs.python.org/": None} + # To supress cross-reference warnings # https://github.com/sphinx-doc/sphinx/issues/3866#issuecomment-768167824 class PatchedPythonDomain(PythonDomain): From b81a8312d792eb8a89299776e97d71dedb1baa92 Mon Sep 17 00:00:00 2001 From: Ian Costanzo Date: Thu, 2 Feb 2023 10:12:15 -0800 Subject: [PATCH 3/4] Cleanup demo postgres dependencies Signed-off-by: Ian Costanzo --- demo/docker-agent/docker-compose.yml | 8 +++----- demo/docker-agent/ngrok-wait.sh | 2 +- demo/docker/docker-compose.yml | 13 +++++++------ demo/multi-demo/docker-compose.yml | 8 +++----- demo/multi-demo/ngrok-wait.sh | 2 +- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/demo/docker-agent/docker-compose.yml b/demo/docker-agent/docker-compose.yml index 8dd07c428f..35b7b2ac57 100644 --- a/demo/docker-agent/docker-compose.yml +++ b/demo/docker-agent/docker-compose.yml @@ -32,12 +32,10 @@ services: - ./ngrok-wait.sh:/home/indy/ngrok-wait.sh wallet-db: - image: vcr-postgresql + image: postgres:12 environment: - - POSTGRESQL_USER=DB_USER - - POSTGRESQL_PASSWORD=DB_PASSWORD - - POSTGRESQL_DATABASE=DB_USER - - POSTGRESQL_ADMIN_PASSWORD=mysecretpassword + - POSTGRES_USER=DB_USER + - POSTGRES_PASSWORD=DB_PASSWORD ports: - 5433:5432 volumes: diff --git a/demo/docker-agent/ngrok-wait.sh b/demo/docker-agent/ngrok-wait.sh index 70c50ce6f3..4c7ccde9db 100755 --- a/demo/docker-agent/ngrok-wait.sh +++ b/demo/docker-agent/ngrok-wait.sh @@ -37,7 +37,7 @@ exec aca-py start \ --wallet-key "secret_key" \ --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\":\"postgres\",\"admin_password\":\"mysecretpassword\"}" \ + --wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}" \ --admin '0.0.0.0' 8010 \ --label "test_author" \ --admin-insecure-mode \ diff --git a/demo/docker/docker-compose.yml b/demo/docker/docker-compose.yml index bcec777fd0..29facddf0f 100644 --- a/demo/docker/docker-compose.yml +++ b/demo/docker/docker-compose.yml @@ -3,6 +3,9 @@ # To shut down the services run `docker-compose rm` - this will retain the postgres database, so you can change aca-py startup parameters # and restart the docker containers without losing your wallet data # If you want to delete your wallet data just run `docker volume ls -q | xargs docker volume rm` + +# Note this requires von-network (https://github.com/bcgov/von-network) and indy-tails-server (https://github.com/bcgov/indy-tails-server) are already running + version: "3" services: vcr-agent: @@ -41,7 +44,7 @@ services: --wallet-key 'key' \ --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\":\"postgres\",\"admin_password\":\"mysecretpassword\"}' \ + --wallet-storage-creds '{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}' \ --admin '0.0.0.0' 8010 \ --admin-insecure-mode \ --label 'tester_agent' \ @@ -58,12 +61,10 @@ services: # --genesis-transactions-list 'ledgers.yaml' \ wallet-db: - image: vcr-postgresql + image: postgres:12 environment: - - POSTGRESQL_USER=DB_USER - - POSTGRESQL_PASSWORD=DB_PASSWORD - - POSTGRESQL_DATABASE=DB_USER - - POSTGRESQL_ADMIN_PASSWORD=mysecretpassword + - POSTGRES_USER=DB_USER + - POSTGRES_PASSWORD=DB_PASSWORD ports: - 5433:5432 volumes: diff --git a/demo/multi-demo/docker-compose.yml b/demo/multi-demo/docker-compose.yml index be9fb0683c..80021ab211 100644 --- a/demo/multi-demo/docker-compose.yml +++ b/demo/multi-demo/docker-compose.yml @@ -32,12 +32,10 @@ services: - ./ngrok-wait.sh:/home/indy/ngrok-wait.sh wallet-db: - image: vcr-postgresql + image: postgres:12 environment: - - POSTGRESQL_USER=DB_USER - - POSTGRESQL_PASSWORD=DB_PASSWORD - - POSTGRESQL_DATABASE=DB_USER - - POSTGRESQL_ADMIN_PASSWORD=mysecretpassword + - POSTGRES_USER=DB_USER + - POSTGRES_PASSWORD=DB_PASSWORD ports: - 5433:5432 volumes: diff --git a/demo/multi-demo/ngrok-wait.sh b/demo/multi-demo/ngrok-wait.sh index df0bc08d6e..6800ec5cd1 100755 --- a/demo/multi-demo/ngrok-wait.sh +++ b/demo/multi-demo/ngrok-wait.sh @@ -37,7 +37,7 @@ exec aca-py start \ --wallet-key "secret_key" \ --wallet-storage-type "postgres_storage" \ --wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5,\"scheme\":\"MultiWalletSingleTable\"}" \ - --wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"postgres\",\"admin_password\":\"mysecretpassword\"}" \ + --wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"DB_USER\",\"admin_password\":\"DB_PASSWORD\"}" \ --admin '0.0.0.0' 8010 \ --label "test_multi" \ --admin-insecure-mode \ From 7edd4170c9447b007e63e37a2e613a5c19cfba0d Mon Sep 17 00:00:00 2001 From: Ian Costanzo Date: Thu, 2 Feb 2023 10:30:57 -0800 Subject: [PATCH 4/4] Fix docker command Signed-off-by: Ian Costanzo --- demo/multi-demo/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/multi-demo/README.md b/demo/multi-demo/README.md index 208a8f7996..90274cb259 100644 --- a/demo/multi-demo/README.md +++ b/demo/multi-demo/README.md @@ -36,5 +36,5 @@ This will leave the agent's wallet data, so if you restart the agent it will mai - to remove the agent's wallet: ```bash -docker volume rm docker-agent_wallet-db-data +docker volume rm multi-demo_wallet-db-data ```