From 57377dd083452849cf261fee5f888291ae345b90 Mon Sep 17 00:00:00 2001 From: sklump Date: Wed, 26 Aug 2020 17:52:15 +0000 Subject: [PATCH 1/2] mark up verifier Signed-off-by: sklump --- aries_cloudagent/verifier/indy.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/aries_cloudagent/verifier/indy.py b/aries_cloudagent/verifier/indy.py index 57ee327022..2c805ab7d5 100644 --- a/aries_cloudagent/verifier/indy.py +++ b/aries_cloudagent/verifier/indy.py @@ -193,12 +193,20 @@ async def verify_presentation( rev_reg_entries: revocation registry entries """ + print("\n-- VERIFIER: VERIFY PRESENTATION") + print(f".. pres req: {json.dumps(presentation_request, indent=4)}") + print(f".. pres: {json.dumps(presentation, indent=4)}") + print(f".. schemas: {json.dumps(schemas, indent=4)}") + print(f".. cred-defs: {json.dumps(credential_definitions, indent=4)}") + print(f".. rev_reg_defs: {json.dumps(rev_reg_defs, indent=4)}") + print(f".. rev_reg_entries: {json.dumps(rev_reg_entries, indent=4)}") (pv_result, pv_msg) = await self.pre_verify(presentation_request, presentation) if pv_result != PreVerifyResult.OK: LOGGER.error( f"Presentation on nonce={presentation_request['nonce']} " f"cannot be validated: {pv_result.value} [{pv_msg}]" ) + print(f" !! Pre-verification fails") return False try: From 5c31ca079b14a48aaf78861a34ba6f19eb4822bd Mon Sep 17 00:00:00 2001 From: sklump Date: Thu, 27 Aug 2020 17:30:54 +0000 Subject: [PATCH 2/2] indy chokes on non-revocation intervals when their corresponding referents are non-revocable credentials: seek and destroy Signed-off-by: sklump --- aries_cloudagent/admin/server.py | 38 +- aries_cloudagent/config/argparse.py | 4 +- aries_cloudagent/config/default_context.py | 4 +- aries_cloudagent/core/dispatcher.py | 4 +- aries_cloudagent/holder/routes.py | 19 +- aries_cloudagent/holder/tests/test_indy.py | 5 +- aries_cloudagent/issuer/indy.py | 5 +- aries_cloudagent/issuer/tests/test_indy.py | 12 +- aries_cloudagent/ledger/indy.py | 11 +- aries_cloudagent/ledger/routes.py | 24 +- aries_cloudagent/ledger/tests/test_indy.py | 66 ++- .../ledger/tests/test_provider.py | 9 +- aries_cloudagent/ledger/tests/test_routes.py | 10 +- .../credential_definitions/routes.py | 4 +- .../tests/test_routes.py | 15 +- .../messaging/credential_definitions/util.py | 22 +- .../messaging/decorators/attach_decorator.py | 9 +- .../decorators/localization_decorator.py | 14 +- .../decorators/please_ack_decorator.py | 4 +- .../decorators/tests/test_attach_decorator.py | 13 +- .../decorators/tests/test_timing_decorator.py | 5 +- .../decorators/tests/test_trace_decorator.py | 15 +- .../messaging/decorators/thread_decorator.py | 3 +- .../messaging/models/base_record.py | 7 +- aries_cloudagent/messaging/schemas/routes.py | 22 +- .../messaging/schemas/tests/test_routes.py | 15 +- aries_cloudagent/messaging/schemas/util.py | 12 +- aries_cloudagent/messaging/tests/test_util.py | 5 +- aries_cloudagent/messaging/valid.py | 18 +- .../actionmenu/v1_0/messages/perform.py | 6 +- .../actionmenu/v1_0/models/menu_form.py | 4 +- .../actionmenu/v1_0/models/menu_form_param.py | 12 +- .../actionmenu/v1_0/models/menu_option.py | 9 +- .../protocols/actionmenu/v1_0/routes.py | 10 +- .../handlers/tests/test_request_handler.py | 14 +- .../handlers/tests/test_response_handler.py | 14 +- .../tests/test_connection_invitation.py | 3 +- .../protocols/connections/v1_0/routes.py | 33 +- .../connections/v1_0/tests/test_manager.py | 48 +- .../connections/v1_0/tests/test_routes.py | 10 +- .../protocols/discovery/v1_0/routes.py | 3 +- .../introduction/v0_1/demo_service.py | 3 +- .../tests/test_invitation_request_handler.py | 3 +- .../protocols/introduction/v0_1/routes.py | 3 +- .../introduction/v0_1/tests/test_service.py | 21 +- .../messages/tests/test_credential_issue.py | 9 +- .../messages/tests/test_credential_offer.py | 12 +- .../tests/test_credential_proposal.py | 4 +- .../messages/tests/test_credential_request.py | 3 +- .../protocols/issue_credential/v1_0/routes.py | 34 +- .../v1_0/tests/test_routes.py | 12 +- .../out_of_band/v1_0/models/invitation.py | 7 +- .../protocols/out_of_band/v1_0/routes.py | 6 +- .../test_presentation_request_handler.py | 174 +++--- .../protocols/present_proof/v1_0/manager.py | 7 +- .../messages/inner/presentation_preview.py | 3 +- .../v1_0/messages/tests/test_presentation.py | 9 +- .../tests/test_presentation_request.py | 3 +- .../protocols/present_proof/v1_0/routes.py | 24 +- .../present_proof/v1_0/tests/test_routes.py | 44 +- .../handlers/tests/test_forward_handler.py | 10 +- .../tests/test_query_update_handlers.py | 3 +- .../models/issuer_rev_reg_record.py | 10 +- .../tests/test_issuer_rev_reg_record.py | 4 +- aries_cloudagent/revocation/routes.py | 14 +- .../transport/inbound/tests/test_session.py | 31 +- .../transport/outbound/tests/test_manager.py | 9 +- aries_cloudagent/transport/pack_format.py | 10 +- aries_cloudagent/transport/wire_format.py | 8 +- aries_cloudagent/utils/tests/test_tracing.py | 5 +- aries_cloudagent/verifier/indy.py | 57 +- aries_cloudagent/verifier/tests/test_indy.py | 495 +++++++++++------- aries_cloudagent/wallet/routes.py | 3 +- .../wallet/tests/test_indy_wallet.py | 5 +- .../wallet/tests/test_provider.py | 6 +- demo/runners/faber.py | 7 +- demo/runners/support/agent.py | 8 +- 77 files changed, 1128 insertions(+), 498 deletions(-) diff --git a/aries_cloudagent/admin/server.py b/aries_cloudagent/admin/server.py index f4556186e8..73de252610 100644 --- a/aries_cloudagent/admin/server.py +++ b/aries_cloudagent/admin/server.py @@ -61,7 +61,11 @@ class AdminResponder(BaseResponder): """Handle outgoing messages from message handlers.""" def __init__( - self, context: InjectionContext, send: Coroutine, webhook: Coroutine, **kwargs, + self, + context: InjectionContext, + send: Coroutine, + webhook: Coroutine, + **kwargs, ): """ Initialize an instance of `AdminResponder`. @@ -128,10 +132,14 @@ def topic_filter(self, val: Sequence[str]): async def ready_middleware(request: web.BaseRequest, handler: Coroutine): """Only continue if application is ready to take work.""" - if str(request.rel_url).rstrip("/") in ( - "/status/live", - "/status/ready", - ) or request.app._state.get("ready"): + if ( + str(request.rel_url).rstrip("/") + in ( + "/status/live", + "/status/ready", + ) + or request.app._state.get("ready") + ): try: return await handler(request) except (LedgerConfigError, LedgerTransactionError) as e: @@ -205,7 +213,9 @@ def __init__( self.context = context.start_scope("admin") self.responder = AdminResponder( - self.context, outbound_message_router, self.send_webhook, + self.context, + outbound_message_router, + self.send_webhook, ) self.context.injector.bind_instance(BaseResponder, self.responder) @@ -220,12 +230,16 @@ async def make_application(self) -> web.Application: assert self.admin_insecure_mode ^ bool(self.admin_api_key) def is_unprotected_path(path: str): - return path in [ - "/api/doc", - "/api/docs/swagger.json", - "/favicon.ico", - "/ws", # ws handler checks authentication - ] or path.startswith("/static/swagger/") + return ( + path + in [ + "/api/doc", + "/api/docs/swagger.json", + "/favicon.ico", + "/ws", # ws handler checks authentication + ] + or path.startswith("/static/swagger/") + ) # If admin_api_key is None, then admin_insecure_mode must be set so # we can safely enable the admin server with no security diff --git a/aries_cloudagent/config/argparse.py b/aries_cloudagent/config/argparse.py index ad6ebc1a00..d21227ab6a 100644 --- a/aries_cloudagent/config/argparse.py +++ b/aries_cloudagent/config/argparse.py @@ -579,7 +579,9 @@ def add_arguments(self, parser: ArgumentParser): help="Write timing information to a given log file.", ) parser.add_argument( - "--trace", action="store_true", help="Generate tracing events.", + "--trace", + action="store_true", + help="Generate tracing events.", ) parser.add_argument( "--trace-target", diff --git a/aries_cloudagent/config/default_context.py b/aries_cloudagent/config/default_context.py index 7fe3caf73f..7352cfa7a0 100644 --- a/aries_cloudagent/config/default_context.py +++ b/aries_cloudagent/config/default_context.py @@ -122,7 +122,9 @@ async def bind_providers(self, context: InjectionContext): ) context.injector.bind_provider( BaseTailsServer, - ClassProvider("aries_cloudagent.tails.indy_tails_server.IndyTailsServer",), + ClassProvider( + "aries_cloudagent.tails.indy_tails_server.IndyTailsServer", + ), ) # Register default pack format diff --git a/aries_cloudagent/core/dispatcher.py b/aries_cloudagent/core/dispatcher.py index 497c9d5a4f..9809b16307 100644 --- a/aries_cloudagent/core/dispatcher.py +++ b/aries_cloudagent/core/dispatcher.py @@ -146,7 +146,9 @@ async def handle_message( message = None trace_event( - self.context.settings, message, outcome="Dispatcher.handle_message.START", + self.context.settings, + message, + outcome="Dispatcher.handle_message.START", ) context = RequestContext(base_context=self.context) diff --git a/aries_cloudagent/holder/routes.py b/aries_cloudagent/holder/routes.py index 06b342a102..e1c9ff06be 100644 --- a/aries_cloudagent/holder/routes.py +++ b/aries_cloudagent/holder/routes.py @@ -82,11 +82,21 @@ class CredentialsListSchema(OpenAPISchema): class CredentialsListQueryStringSchema(OpenAPISchema): """Parameters and validators for query string in credentials list query.""" - start = fields.Int(description="Start index", required=False, **WHOLE_NUM,) + start = fields.Int( + description="Start index", + required=False, + **WHOLE_NUM, + ) count = fields.Int( - description="Maximum number to retrieve", required=False, **NATURAL_NUM, + description="Maximum number to retrieve", + required=False, + **NATURAL_NUM, + ) + wql = fields.Str( + description="(JSON) WQL query", + required=False, + **INDY_WQL, ) - wql = fields.Str(description="(JSON) WQL query", required=False, **INDY_WQL,) class CredIdMatchInfoSchema(OpenAPISchema): @@ -173,7 +183,8 @@ async def credentials_remove(request: web.BaseRequest): @docs( - tags=["credentials"], summary="Fetch credentials from wallet", + tags=["credentials"], + summary="Fetch credentials from wallet", ) @querystring_schema(CredentialsListQueryStringSchema()) @response_schema(CredentialsListSchema(), 200) diff --git a/aries_cloudagent/holder/tests/test_indy.py b/aries_cloudagent/holder/tests/test_indy.py index ee0b526c4a..b55e92d942 100644 --- a/aries_cloudagent/holder/tests/test_indy.py +++ b/aries_cloudagent/holder/tests/test_indy.py @@ -304,7 +304,10 @@ async def test_get_credentials_for_presentation_request_by_referent_default_reft } credentials = await holder.get_credentials_for_presentation_request_by_referent( - PRES_REQ, None, 2, 3, + PRES_REQ, + None, + 2, + 3, ) mock_prover_search_credentials_for_proof_req.assert_called_once_with( diff --git a/aries_cloudagent/issuer/indy.py b/aries_cloudagent/issuer/indy.py index 3b94aa549b..513ca8c79d 100644 --- a/aries_cloudagent/issuer/indy.py +++ b/aries_cloudagent/issuer/indy.py @@ -64,7 +64,10 @@ async def create_and_store_schema( with IndyErrorHandler("Error when creating schema", IssuerError): schema_id, schema_json = await indy.anoncreds.issuer_create_schema( - origin_did, schema_name, schema_version, json.dumps(attribute_names), + origin_did, + schema_name, + schema_version, + json.dumps(attribute_names), ) return (schema_id, schema_json) diff --git a/aries_cloudagent/issuer/tests/test_indy.py b/aries_cloudagent/issuer/tests/test_indy.py index 669d2da3bf..cef92d4a41 100644 --- a/aries_cloudagent/issuer/tests/test_indy.py +++ b/aries_cloudagent/issuer/tests/test_indy.py @@ -157,7 +157,11 @@ async def test_create_revoke_credentials( test_cred_rev_ids = ["42", "54"] test_rr_delta = TEST_RR_DELTA mock_indy_create_credential.side_effect = [ - (json.dumps(test_cred), cr_id, test_rr_delta,) + ( + json.dumps(test_cred), + cr_id, + test_rr_delta, + ) for cr_id in test_cred_rev_ids ] @@ -232,7 +236,11 @@ async def test_create_revoke_credentials_x( test_cred_rev_ids = ["42", "54", "103"] test_rr_delta = TEST_RR_DELTA mock_indy_create_credential.side_effect = [ - (json.dumps(test_cred), cr_id, test_rr_delta,) + ( + json.dumps(test_cred), + cr_id, + test_rr_delta, + ) for cr_id in test_cred_rev_ids ] diff --git a/aries_cloudagent/ledger/indy.py b/aries_cloudagent/ledger/indy.py index f9327936a3..2fba86e0f7 100644 --- a/aries_cloudagent/ledger/indy.py +++ b/aries_cloudagent/ledger/indy.py @@ -368,7 +368,10 @@ async def create_and_send_schema( try: schema_id, schema_json = await issuer.create_and_store_schema( - public_info.did, schema_name, schema_version, attribute_names, + public_info.did, + schema_name, + schema_version, + attribute_names, ) except IssuerError as err: raise LedgerError(err.message) from err @@ -620,7 +623,11 @@ async def create_and_send_credential_definition( credential_definition_id, credential_definition_json, ) = await issuer.create_and_store_credential_definition( - public_info.did, schema, signature_type, tag, support_revocation, + public_info.did, + schema, + signature_type, + tag, + support_revocation, ) except IssuerError as err: raise LedgerError(err.message) from err diff --git a/aries_cloudagent/ledger/routes.py b/aries_cloudagent/ledger/routes.py index f171d249bc..1cb2de8eeb 100644 --- a/aries_cloudagent/ledger/routes.py +++ b/aries_cloudagent/ledger/routes.py @@ -65,11 +65,19 @@ class TAAAcceptSchema(OpenAPISchema): class RegisterLedgerNymQueryStringSchema(OpenAPISchema): """Query string parameters and validators for register ledger nym request.""" - did = fields.Str(description="DID to register", required=True, **INDY_DID,) + did = fields.Str( + description="DID to register", + required=True, + **INDY_DID, + ) verkey = fields.Str( description="Verification key", required=True, **INDY_RAW_PUBLIC_KEY ) - alias = fields.Str(description="Alias", required=False, example="Barry",) + alias = fields.Str( + description="Alias", + required=False, + example="Barry", + ) role = fields.Str( description="Role", required=False, @@ -99,7 +107,8 @@ class QueryStringEndpointSchema(OpenAPISchema): @docs( - tags=["ledger"], summary="Send a NYM registration to the ledger.", + tags=["ledger"], + summary="Send a NYM registration to the ledger.", ) @querystring_schema(RegisterLedgerNymQueryStringSchema()) async def register_ledger_nym(request: web.BaseRequest): @@ -143,7 +152,8 @@ async def register_ledger_nym(request: web.BaseRequest): @docs( - tags=["ledger"], summary="Get the role from the NYM registration of a public DID.", + tags=["ledger"], + summary="Get the role from the NYM registration of a public DID.", ) @querystring_schema(QueryStringDIDSchema) async def get_nym_role(request: web.BaseRequest): @@ -202,7 +212,8 @@ async def rotate_public_did_keypair(request: web.BaseRequest): @docs( - tags=["ledger"], summary="Get the verkey for a DID from the ledger.", + tags=["ledger"], + summary="Get the verkey for a DID from the ledger.", ) @querystring_schema(QueryStringDIDSchema()) async def get_did_verkey(request: web.BaseRequest): @@ -236,7 +247,8 @@ async def get_did_verkey(request: web.BaseRequest): @docs( - tags=["ledger"], summary="Get the endpoint for a DID from the ledger.", + tags=["ledger"], + summary="Get the endpoint for a DID from the ledger.", ) @querystring_schema(QueryStringEndpointSchema()) async def get_did_endpoint(request: web.BaseRequest): diff --git a/aries_cloudagent/ledger/tests/test_indy.py b/aries_cloudagent/ledger/tests/test_indy.py index a19373dac5..fe2d1476db 100644 --- a/aries_cloudagent/ledger/tests/test_indy.py +++ b/aries_cloudagent/ledger/tests/test_indy.py @@ -752,7 +752,10 @@ async def test_send_schema_no_seq_no( @async_mock.patch("aries_cloudagent.ledger.indy.IndyLedger._context_close") @async_mock.patch("aries_cloudagent.ledger.indy.IndyLedger.fetch_schema_by_id") async def test_check_existing_schema( - self, mock_fetch_schema_by_id, mock_close, mock_open, + self, + mock_fetch_schema_by_id, + mock_close, + mock_open, ): mock_wallet = async_mock.MagicMock() mock_wallet.type = "indy" @@ -825,7 +828,11 @@ async def test_get_schema( @async_mock.patch("aries_cloudagent.ledger.indy.IndyLedger._submit") @async_mock.patch("indy.ledger.build_get_schema_request") async def test_get_schema_not_found( - self, mock_build_get_schema_req, mock_submit, mock_close, mock_open, + self, + mock_build_get_schema_req, + mock_submit, + mock_close, + mock_open, ): mock_wallet = async_mock.MagicMock() mock_wallet.type = "indy" @@ -939,7 +946,17 @@ async def test_get_schema_by_wrong_seq_no( mock_parse_get_schema_resp.return_value = (None, '{"attrNames": ["a", "b"]}') submissions = [ - json.dumps({"result": {"data": {"txn": {"type": "102",}}}}), # not a schema + json.dumps( + { + "result": { + "data": { + "txn": { + "type": "102", + } + } + } + } + ), # not a schema json.dumps({"result": {"seqNo": 999}}), ] # need to subscript these in assertions later mock_submit.side_effect = [ @@ -1130,7 +1147,10 @@ async def test_send_credential_definition_exists_in_ledger_and_wallet( @async_mock.patch("aries_cloudagent.ledger.indy.IndyLedger._context_open") @async_mock.patch("aries_cloudagent.ledger.indy.IndyLedger._context_close") async def test_send_credential_definition_no_such_schema( - self, mock_close, mock_open, mock_get_schema, + self, + mock_close, + mock_open, + mock_get_schema, ): mock_wallet = async_mock.MagicMock() mock_wallet.type = "indy" @@ -1205,7 +1225,11 @@ async def test_send_credential_definition_offer_exception( "aries_cloudagent.ledger.indy.IndyLedger.fetch_credential_definition" ) async def test_send_credential_definition_cred_def_in_wallet_not_ledger( - self, mock_fetch_cred_def, mock_close, mock_open, mock_get_schema, + self, + mock_fetch_cred_def, + mock_close, + mock_open, + mock_get_schema, ): mock_wallet = async_mock.MagicMock() mock_wallet.type = "indy" @@ -1248,7 +1272,11 @@ async def test_send_credential_definition_cred_def_in_wallet_not_ledger( "aries_cloudagent.ledger.indy.IndyLedger.fetch_credential_definition" ) async def test_send_credential_definition_cred_def_not_on_ledger_wallet_check_x( - self, mock_fetch_cred_def, mock_close, mock_open, mock_get_schema, + self, + mock_fetch_cred_def, + mock_close, + mock_open, + mock_get_schema, ): mock_wallet = async_mock.MagicMock() mock_wallet.type = "indy" @@ -1295,7 +1323,11 @@ async def test_send_credential_definition_cred_def_not_on_ledger_wallet_check_x( "aries_cloudagent.ledger.indy.IndyLedger.fetch_credential_definition" ) async def test_send_credential_definition_cred_def_not_on_ledger_nor_wallet_send_x( - self, mock_fetch_cred_def, mock_close, mock_open, mock_get_schema, + self, + mock_fetch_cred_def, + mock_close, + mock_open, + mock_get_schema, ): mock_wallet = async_mock.MagicMock() mock_wallet.type = "indy" @@ -1345,7 +1377,11 @@ async def test_send_credential_definition_cred_def_not_on_ledger_nor_wallet_send "aries_cloudagent.ledger.indy.IndyLedger.fetch_credential_definition" ) async def test_send_credential_definition_read_only( - self, mock_fetch_cred_def, mock_close, mock_open, mock_get_schema, + self, + mock_fetch_cred_def, + mock_close, + mock_open, + mock_get_schema, ): mock_wallet = async_mock.MagicMock() mock_wallet.type = "indy" @@ -1395,7 +1431,11 @@ async def test_send_credential_definition_read_only( "aries_cloudagent.ledger.indy.IndyLedger.fetch_credential_definition" ) async def test_send_credential_definition_cred_def_on_ledger_not_in_wallet( - self, mock_fetch_cred_def, mock_close, mock_open, mock_get_schema, + self, + mock_fetch_cred_def, + mock_close, + mock_open, + mock_get_schema, ): mock_wallet = async_mock.MagicMock() mock_wallet.type = "indy" @@ -2006,7 +2046,9 @@ async def test_update_endpoint_for_did_no_prior_endpoints( None, ) mock_submit.assert_has_calls( - [async_mock.call(mock_build_attrib_req.return_value, True, True),] + [ + async_mock.call(mock_build_attrib_req.return_value, True, True), + ] ) assert response @@ -2682,7 +2724,9 @@ async def test_send_revoc_reg_entry_x_no_did( @async_mock.patch("indy.pool.open_pool_ledger") @async_mock.patch("indy.pool.close_pool_ledger") async def test_taa_digest_bad_value( - self, mock_close_pool, mock_open_ledger, + self, + mock_close_pool, + mock_open_ledger, ): mock_wallet = async_mock.MagicMock() mock_wallet.type = "indy" diff --git a/aries_cloudagent/ledger/tests/test_provider.py b/aries_cloudagent/ledger/tests/test_provider.py index 2e1e7fb836..0d5dc62f31 100644 --- a/aries_cloudagent/ledger/tests/test_provider.py +++ b/aries_cloudagent/ledger/tests/test_provider.py @@ -22,7 +22,9 @@ class TestProvider(AsyncTestCase): @async_mock.patch("indy.pool.create_pool_ledger_config") @async_mock.patch("builtins.open") async def test_provide( - self, mock_open, mock_create_ledger_config, + self, + mock_open, + mock_create_ledger_config, ): mock_open.return_value = async_mock.MagicMock() provider = LedgerProvider() @@ -57,6 +59,9 @@ async def test_provide_no_pool_config(self, mock_open, mock_list_pools): context.injector.bind_instance(BaseWallet, mock_wallet) result = await provider.provide( - settings={"ledger.pool_name": "name",}, injector=context.injector + settings={ + "ledger.pool_name": "name", + }, + injector=context.injector, ) assert result is None diff --git a/aries_cloudagent/ledger/tests/test_routes.py b/aries_cloudagent/ledger/tests/test_routes.py index a073216c54..7b8f85fe9a 100644 --- a/aries_cloudagent/ledger/tests/test_routes.py +++ b/aries_cloudagent/ledger/tests/test_routes.py @@ -27,7 +27,9 @@ def setUp(self): self.test_endpoint_type_profile = "http://company.com/profile" async def test_missing_ledger(self): - request = async_mock.MagicMock(app=self.app,) + request = async_mock.MagicMock( + app=self.app, + ) self.context.injector.clear_binding(BaseLedger) with self.assertRaises(test_module.web.HTTPForbidden): @@ -133,7 +135,11 @@ async def test_get_endpoint_x(self): async def test_register_nym(self): request = async_mock.MagicMock( app=self.app, - query={"did": self.test_did, "verkey": self.test_verkey, "role": "reset",}, + query={ + "did": self.test_did, + "verkey": self.test_verkey, + "role": "reset", + }, ) with async_mock.patch.object( test_module.web, "json_response", async_mock.Mock() diff --git a/aries_cloudagent/messaging/credential_definitions/routes.py b/aries_cloudagent/messaging/credential_definitions/routes.py index 76691cd710..b01548572f 100644 --- a/aries_cloudagent/messaging/credential_definitions/routes.py +++ b/aries_cloudagent/messaging/credential_definitions/routes.py @@ -163,7 +163,9 @@ async def credential_definitions_send_credential_definition(request: web.BaseReq issuer_did = cred_def_id.split(":")[0] revoc = IndyRevocation(context) registry_record = await revoc.init_issuer_registry( - cred_def_id, issuer_did, max_cred_num=revocation_registry_size, + cred_def_id, + issuer_did, + max_cred_num=revocation_registry_size, ) except RevocationNotSupportedError as e: diff --git a/aries_cloudagent/messaging/credential_definitions/tests/test_routes.py b/aries_cloudagent/messaging/credential_definitions/tests/test_routes.py index 6d2baba131..63e9034f8a 100644 --- a/aries_cloudagent/messaging/credential_definitions/tests/test_routes.py +++ b/aries_cloudagent/messaging/credential_definitions/tests/test_routes.py @@ -61,8 +61,10 @@ async def test_send_credential_definition(self): ) with async_mock.patch.object(test_module.web, "json_response") as mock_response: - result = await test_module.credential_definitions_send_credential_definition( - mock_request + result = ( + await test_module.credential_definitions_send_credential_definition( + mock_request + ) ) assert result == mock_response.return_value mock_response.assert_called_once_with( @@ -274,7 +276,8 @@ async def test_send_credential_definition_ledger_x(self): async def test_created(self): mock_request = async_mock.MagicMock( - app=self.app, match_info={"cred_def_id": CRED_DEF_ID}, + app=self.app, + match_info={"cred_def_id": CRED_DEF_ID}, ) with async_mock.patch.object(test_module.web, "json_response") as mock_response: @@ -286,7 +289,8 @@ async def test_created(self): async def test_get_credential_definition(self): mock_request = async_mock.MagicMock( - app=self.app, match_info={"cred_def_id": CRED_DEF_ID}, + app=self.app, + match_info={"cred_def_id": CRED_DEF_ID}, ) with async_mock.patch.object(test_module.web, "json_response") as mock_response: @@ -300,7 +304,8 @@ async def test_get_credential_definition(self): async def test_get_credential_definition_no_ledger(self): mock_request = async_mock.MagicMock( - app=self.app, match_info={"cred_def_id": CRED_DEF_ID}, + app=self.app, + match_info={"cred_def_id": CRED_DEF_ID}, ) self.context.injector.clear_binding(BaseLedger) diff --git a/aries_cloudagent/messaging/credential_definitions/util.py b/aries_cloudagent/messaging/credential_definitions/util.py index 8038f21fc2..0d0a374aa7 100644 --- a/aries_cloudagent/messaging/credential_definitions/util.py +++ b/aries_cloudagent/messaging/credential_definitions/util.py @@ -18,20 +18,32 @@ class CredDefQueryStringSchema(OpenAPISchema): """Query string parameters for credential definition searches.""" schema_id = fields.Str( - description="Schema identifier", required=False, **INDY_SCHEMA_ID, + description="Schema identifier", + required=False, + **INDY_SCHEMA_ID, ) schema_issuer_did = fields.Str( - description="Schema issuer DID", required=False, **INDY_DID, + description="Schema issuer DID", + required=False, + **INDY_DID, ) schema_name = fields.Str( - description="Schema name", required=False, example="membership", + description="Schema name", + required=False, + example="membership", ) schema_version = fields.Str( description="Schema version", required=False, **INDY_VERSION ) - issuer_did = fields.Str(description="Issuer DID", required=False, **INDY_DID,) + issuer_did = fields.Str( + description="Issuer DID", + required=False, + **INDY_DID, + ) cred_def_id = fields.Str( - description="Credential definition id", required=False, **INDY_CRED_DEF_ID, + description="Credential definition id", + required=False, + **INDY_CRED_DEF_ID, ) diff --git a/aries_cloudagent/messaging/decorators/attach_decorator.py b/aries_cloudagent/messaging/decorators/attach_decorator.py index b8737d2270..80fea1bb81 100644 --- a/aries_cloudagent/messaging/decorators/attach_decorator.py +++ b/aries_cloudagent/messaging/decorators/attach_decorator.py @@ -332,7 +332,9 @@ def sha256(self): return getattr(self, "sha256_", None) async def sign( - self, verkeys: Union[str, Sequence[str]], wallet: BaseWallet, + self, + verkeys: Union[str, Sequence[str]], + wallet: BaseWallet, ): """ Sign base64 data value of attachment. @@ -669,4 +671,7 @@ class Meta: example="view from doorway, facing east, with lights off", required=False, ) - data = fields.Nested(AttachDecoratorDataSchema, required=True,) + data = fields.Nested( + AttachDecoratorDataSchema, + required=True, + ) diff --git a/aries_cloudagent/messaging/decorators/localization_decorator.py b/aries_cloudagent/messaging/decorators/localization_decorator.py index bbb731cb19..d9459354ee 100644 --- a/aries_cloudagent/messaging/decorators/localization_decorator.py +++ b/aries_cloudagent/messaging/decorators/localization_decorator.py @@ -46,15 +46,23 @@ class Meta: model_class = LocalizationDecorator unknown = EXCLUDE - locale = fields.Str(required=True, description="Locale specifier", example="en-CA",) + locale = fields.Str( + required=True, + description="Locale specifier", + example="en-CA", + ) localizable = fields.List( - fields.Str(description="Localizable field", example="note",), + fields.Str( + description="Localizable field", + example="note", + ), required=False, description="List of localizable fields", ) catalogs = fields.List( fields.Str( - description="", example="https://192.168.56.111/my-project/catalog.json", + description="", + example="https://192.168.56.111/my-project/catalog.json", ), required=False, description="List of message catalog URIs", diff --git a/aries_cloudagent/messaging/decorators/please_ack_decorator.py b/aries_cloudagent/messaging/decorators/please_ack_decorator.py index 3c97a7f40d..fe5fd42d13 100644 --- a/aries_cloudagent/messaging/decorators/please_ack_decorator.py +++ b/aries_cloudagent/messaging/decorators/please_ack_decorator.py @@ -17,7 +17,9 @@ class Meta: schema_class = "PleaseAckDecoratorSchema" def __init__( - self, message_id: str = None, on: Sequence[str] = None, + self, + message_id: str = None, + on: Sequence[str] = None, ): """ Initialize a PleaseAckDecorator instance. diff --git a/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py b/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py index 3a78075933..a9117efc9d 100644 --- a/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py +++ b/aries_cloudagent/messaging/decorators/tests/test_attach_decorator.py @@ -195,7 +195,10 @@ def test_jws2(self): "signature": SIGNATURE, "signatures": [one_jws.serialize(), one_jws.serialize()], }, - {"protected": PROTECTED, "signature": SIGNATURE,}, + { + "protected": PROTECTED, + "signature": SIGNATURE, + }, ] for bad in badness: with pytest.raises(BaseModelError) as excinfo: @@ -305,7 +308,9 @@ def test_serialize_load_appended_links(self): def test_indy_dict(self): deco_indy = AttachDecorator.from_indy_dict( - indy_dict=INDY_CRED, ident=IDENT, description=DESCRIPTION, + indy_dict=INDY_CRED, + ident=IDENT, + description=DESCRIPTION, ) assert deco_indy.mime_type == "application/json" assert hasattr(deco_indy.data, "base64_") @@ -334,7 +339,9 @@ def test_indy_dict(self): def test_from_aries_msg(self): deco_aries = AttachDecorator.from_aries_msg( - message=INDY_CRED, ident=IDENT, description=DESCRIPTION, + message=INDY_CRED, + ident=IDENT, + description=DESCRIPTION, ) assert deco_aries.mime_type == "application/json" assert hasattr(deco_aries.data, "json_") diff --git a/aries_cloudagent/messaging/decorators/tests/test_timing_decorator.py b/aries_cloudagent/messaging/decorators/tests/test_timing_decorator.py index 8e3de33072..b979f90bec 100644 --- a/aries_cloudagent/messaging/decorators/tests/test_timing_decorator.py +++ b/aries_cloudagent/messaging/decorators/tests/test_timing_decorator.py @@ -10,7 +10,10 @@ class TestTimingDecorator(TestCase): def test_serialize_load(self): - deco = TimingDecorator(in_time=NOW, out_time=NOW,) + deco = TimingDecorator( + in_time=NOW, + out_time=NOW, + ) assert deco.in_time == datetime_to_str(NOW) assert deco.out_time == datetime_to_str(NOW) diff --git a/aries_cloudagent/messaging/decorators/tests/test_trace_decorator.py b/aries_cloudagent/messaging/decorators/tests/test_trace_decorator.py index c83ffa4e60..2d2613fe96 100644 --- a/aries_cloudagent/messaging/decorators/tests/test_trace_decorator.py +++ b/aries_cloudagent/messaging/decorators/tests/test_trace_decorator.py @@ -22,7 +22,8 @@ class TestTraceDecorator(TestCase): def test_init_api(self): decorator = TraceDecorator( - target=self.target_api, full_thread=self.full_thread_api, + target=self.target_api, + full_thread=self.full_thread_api, ) assert decorator.target == self.target_api assert decorator.full_thread == self.full_thread_api @@ -45,7 +46,9 @@ def test_init_message(self): decorator = TraceDecorator( target=self.target_msg, full_thread=self.full_thread_msg, - trace_reports=[x_trace_report,], + trace_reports=[ + x_trace_report, + ], ) assert decorator.target == self.target_msg assert decorator.full_thread == self.full_thread_msg @@ -78,7 +81,10 @@ def test_serialize_load(self): decorator = TraceDecorator( target=self.target_msg, full_thread=self.full_thread_msg, - trace_reports=[x_trace_report, x_trace_report,], + trace_reports=[ + x_trace_report, + x_trace_report, + ], ) dumped = decorator.serialize() @@ -99,7 +105,8 @@ def test_serialize_load(self): def test_trace_reports(self): decorator = TraceDecorator( - target=self.target_msg, full_thread=self.full_thread_msg, + target=self.target_msg, + full_thread=self.full_thread_msg, ) assert len(decorator.trace_reports) == 0 diff --git a/aries_cloudagent/messaging/decorators/thread_decorator.py b/aries_cloudagent/messaging/decorators/thread_decorator.py index 3d447f6b85..744dd7ba08 100644 --- a/aries_cloudagent/messaging/decorators/thread_decorator.py +++ b/aries_cloudagent/messaging/decorators/thread_decorator.py @@ -140,7 +140,8 @@ class Meta: received_orders = fields.Dict( keys=fields.Str(description="Sender key"), values=fields.Integer( - description="Highest sender_order value for sender", example="3", + description="Highest sender_order value for sender", + example="3", ), required=False, allow_none=True, diff --git a/aries_cloudagent/messaging/models/base_record.py b/aries_cloudagent/messaging/models/base_record.py index 4d013f481e..ef197e661e 100644 --- a/aries_cloudagent/messaging/models/base_record.py +++ b/aries_cloudagent/messaging/models/base_record.py @@ -452,7 +452,12 @@ class BaseExchangeRecord(BaseRecord): """Represents a base record with event tracing capability.""" def __init__( - self, id: str = None, state: str = None, *, trace: bool = False, **kwargs, + self, + id: str = None, + state: str = None, + *, + trace: bool = False, + **kwargs, ): """Initialize a new V10CredentialExchange.""" super().__init__(id, state, **kwargs) diff --git a/aries_cloudagent/messaging/schemas/routes.py b/aries_cloudagent/messaging/schemas/routes.py index bfae859cee..162ee50e8d 100644 --- a/aries_cloudagent/messaging/schemas/routes.py +++ b/aries_cloudagent/messaging/schemas/routes.py @@ -26,12 +26,19 @@ class SchemaSendRequestSchema(OpenAPISchema): """Request schema for schema send request.""" - schema_name = fields.Str(required=True, description="Schema name", example="prefs",) + schema_name = fields.Str( + required=True, + description="Schema name", + example="prefs", + ) schema_version = fields.Str( required=True, description="Schema version", **INDY_VERSION ) attributes = fields.List( - fields.Str(description="attribute name", example="score",), + fields.Str( + description="attribute name", + example="score", + ), required=True, description="List of schema attributes", ) @@ -52,11 +59,15 @@ class SchemaSchema(OpenAPISchema): ver = fields.Str(description="Node protocol version", **INDY_VERSION) ident = fields.Str(data_key="id", description="Schema identifier", **INDY_SCHEMA_ID) name = fields.Str( - description="Schema name", example=INDY_SCHEMA_ID["example"].split(":")[2], + description="Schema name", + example=INDY_SCHEMA_ID["example"].split(":")[2], ) version = fields.Str(description="Schema version", **INDY_VERSION) attr_names = fields.List( - fields.Str(description="Attribute name", example="score",), + fields.Str( + description="Attribute name", + example="score", + ), description="Schema attribute names", data_key="attrNames", ) @@ -132,7 +143,8 @@ async def schemas_send_schema(request: web.BaseRequest): @docs( - tags=["schema"], summary="Search for matching schema that agent originated", + tags=["schema"], + summary="Search for matching schema that agent originated", ) @querystring_schema(SchemaQueryStringSchema()) @response_schema(SchemasCreatedResultsSchema(), 200) diff --git a/aries_cloudagent/messaging/schemas/tests/test_routes.py b/aries_cloudagent/messaging/schemas/tests/test_routes.py index 946187af3d..e9ddee00f0 100644 --- a/aries_cloudagent/messaging/schemas/tests/test_routes.py +++ b/aries_cloudagent/messaging/schemas/tests/test_routes.py @@ -101,7 +101,8 @@ async def test_send_schema_x_ledger(self): async def test_created(self): mock_request = async_mock.MagicMock( - app=self.app, match_info={"schema_id": SCHEMA_ID}, + app=self.app, + match_info={"schema_id": SCHEMA_ID}, ) with async_mock.patch.object(test_module.web, "json_response") as mock_response: @@ -111,7 +112,8 @@ async def test_created(self): async def test_get_schema(self): mock_request = async_mock.MagicMock( - app=self.app, match_info={"schema_id": SCHEMA_ID}, + app=self.app, + match_info={"schema_id": SCHEMA_ID}, ) with async_mock.patch.object(test_module.web, "json_response") as mock_response: @@ -121,7 +123,8 @@ async def test_get_schema(self): async def test_get_schema_on_seq_no(self): mock_request = async_mock.MagicMock( - app=self.app, match_info={"schema_id": "12345"}, + app=self.app, + match_info={"schema_id": "12345"}, ) with async_mock.patch.object(test_module.web, "json_response") as mock_response: @@ -131,7 +134,8 @@ async def test_get_schema_on_seq_no(self): async def test_get_schema_no_ledger(self): mock_request = async_mock.MagicMock( - app=self.app, match_info={"schema_id": SCHEMA_ID}, + app=self.app, + match_info={"schema_id": SCHEMA_ID}, ) self.ledger.get_schema = async_mock.CoroutineMock( side_effect=test_module.LedgerError("Down for routine maintenance") @@ -143,7 +147,8 @@ async def test_get_schema_no_ledger(self): async def test_get_schema_x_ledger(self): mock_request = async_mock.MagicMock( - app=self.app, match_info={"schema_id": SCHEMA_ID}, + app=self.app, + match_info={"schema_id": SCHEMA_ID}, ) self.ledger.get_schema = async_mock.CoroutineMock( side_effect=test_module.LedgerError("Down for routine maintenance") diff --git a/aries_cloudagent/messaging/schemas/util.py b/aries_cloudagent/messaging/schemas/util.py index 4c71781003..c75642f5e0 100644 --- a/aries_cloudagent/messaging/schemas/util.py +++ b/aries_cloudagent/messaging/schemas/util.py @@ -10,13 +10,19 @@ class SchemaQueryStringSchema(OpenAPISchema): """Query string parameters for schema searches.""" schema_id = fields.Str( - description="Schema identifier", required=False, **INDY_SCHEMA_ID, + description="Schema identifier", + required=False, + **INDY_SCHEMA_ID, ) schema_issuer_did = fields.Str( - description="Schema issuer DID", required=False, **INDY_DID, + description="Schema issuer DID", + required=False, + **INDY_DID, ) schema_name = fields.Str( - description="Schema name", required=False, example="membership", + description="Schema name", + required=False, + example="membership", ) schema_version = fields.Str( description="Schema version", required=False, **INDY_VERSION diff --git a/aries_cloudagent/messaging/tests/test_util.py b/aries_cloudagent/messaging/tests/test_util.py index 50a76f3e8d..23614b511e 100644 --- a/aries_cloudagent/messaging/tests/test_util.py +++ b/aries_cloudagent/messaging/tests/test_util.py @@ -106,7 +106,10 @@ def test_encode(self): "encoded": "99769404535520360775991420569103450442789945655240760487761322098828903685777", }, "bool True": {"raw": True, "encoded": "1"}, - "bool False": {"raw": False, "encoded": "0",}, + "bool False": { + "raw": False, + "encoded": "0", + }, "str True": { "raw": "True", "encoded": "27471875274925838976481193902417661171675582237244292940724984695988062543640", diff --git a/aries_cloudagent/messaging/valid.py b/aries_cloudagent/messaging/valid.py index 3294205709..a23128c697 100644 --- a/aries_cloudagent/messaging/valid.py +++ b/aries_cloudagent/messaging/valid.py @@ -95,7 +95,8 @@ def __init__(self): """Initializer.""" super().__init__( - JSONWebToken.PATTERN, error="Value {input} is not a valid JSON Web token", + JSONWebToken.PATTERN, + error="Value {input} is not a valid JSON Web token", ) @@ -271,7 +272,8 @@ def __init__(self): """Initializer.""" super().__init__( - IndyWQL.PATTERN, error="Value {input} is not a valid WQL query", + IndyWQL.PATTERN, + error="Value {input} is not a valid WQL query", ) def __call__(self, value): @@ -298,7 +300,8 @@ def __init__(self): """Initializer.""" super().__init__( - IndyExtraWQL.PATTERN, error="Value {input} is not a valid extra WQL query", + IndyExtraWQL.PATTERN, + error="Value {input} is not a valid extra WQL query", ) def __call__(self, value): @@ -325,7 +328,8 @@ def __init__(self): """Initializer.""" super().__init__( - Base64.PATTERN, error="Value {input} is not a valid base64 encoding", + Base64.PATTERN, + error="Value {input} is not a valid base64 encoding", ) @@ -339,7 +343,8 @@ def __init__(self): """Initializer.""" super().__init__( - Base64URL.PATTERN, error="Value {input} is not a valid base64url encoding", + Base64URL.PATTERN, + error="Value {input} is not a valid base64url encoding", ) @@ -424,7 +429,8 @@ def __init__(self): """Initializer.""" super().__init__( - Endpoint.PATTERN, error="Value {input} is not a valid endpoint", + Endpoint.PATTERN, + error="Value {input} is not a valid endpoint", ) diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py b/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py index 8d30f66404..7e14715450 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py @@ -43,7 +43,11 @@ class Meta: model_class = Perform unknown = EXCLUDE - name = fields.Str(required=True, description="Menu option name", example="Query",) + name = fields.Str( + required=True, + description="Menu option name", + example="Query", + ) params = fields.Dict( required=False, keys=fields.Str(example="parameter"), # marshmallow/apispec v3.0 ignores diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form.py b/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form.py index 5e718500c5..645aa92160 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form.py @@ -50,7 +50,9 @@ class Meta: unknown = EXCLUDE title = fields.Str( - required=False, description="Menu form title", example="Preferences", + required=False, + description="Menu form title", + example="Preferences", ) description = fields.Str( required=False, diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form_param.py b/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form_param.py index f265aba953..52735a55bc 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form_param.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form_param.py @@ -53,13 +53,17 @@ class Meta: unknown = EXCLUDE name = fields.Str( - required=True, description="Menu parameter name", example="delay", + required=True, + description="Menu parameter name", + example="delay", ) title = fields.Str( required=True, description="Menu parameter title", example="Delay in seconds" ) default = fields.Str( - required=False, description="Default parameter value", example="0", + required=False, + description="Default parameter value", + example="0", ) description = fields.Str( required=False, @@ -73,5 +77,7 @@ class Meta: data_key="type", ) required = fields.Bool( - required=False, description="Whether parameter is required", example="False", + required=False, + description="Whether parameter is required", + example="False", ) diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_option.py b/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_option.py index c7f36ff068..9295d82b29 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_option.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_option.py @@ -56,7 +56,9 @@ class Meta: example="window_prefs", ) title = fields.Str( - required=True, description="Menu option title", example="Window Preferences", + required=True, + description="Menu option title", + example="Window Preferences", ) description = fields.Str( required=False, @@ -68,4 +70,7 @@ class Meta: description="Whether to show option as disabled", example="False", ) - form = fields.Nested(MenuFormSchema(), required=False,) + form = fields.Nested( + MenuFormSchema(), + required=False, + ) diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/routes.py b/aries_cloudagent/protocols/actionmenu/v1_0/routes.py index e9520eacb9..3aee780d28 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/routes.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/routes.py @@ -37,7 +37,11 @@ class PerformRequestSchema(OpenAPISchema): class MenuJsonSchema(OpenAPISchema): """Matches MenuSchema but without the inherited AgentMessage properties.""" - title = fields.Str(required=False, description="Menu title", example="My Menu",) + title = fields.Str( + required=False, + description="Menu title", + example="My Menu", + ) description = fields.Str( required=False, description="Introductory text for the menu", @@ -59,7 +63,9 @@ class SendMenuSchema(OpenAPISchema): """Request schema for sending a menu to a connection.""" menu = fields.Nested( - MenuJsonSchema(), required=True, description="Menu to send to connection", + MenuJsonSchema(), + required=True, + description="Menu to send to connection", ) diff --git a/aries_cloudagent/protocols/connections/v1_0/handlers/tests/test_request_handler.py b/aries_cloudagent/protocols/connections/v1_0/handlers/tests/test_request_handler.py index 2b77becbaf..0303bb6134 100644 --- a/aries_cloudagent/protocols/connections/v1_0/handlers/tests/test_request_handler.py +++ b/aries_cloudagent/protocols/connections/v1_0/handlers/tests/test_request_handler.py @@ -41,13 +41,23 @@ def did_doc(): ident = "1" pk_value = TEST_VERKEY pk = PublicKey( - TEST_DID, ident, pk_value, PublicKeyType.ED25519_SIG_2018, controller, False, + TEST_DID, + ident, + pk_value, + PublicKeyType.ED25519_SIG_2018, + controller, + False, ) doc.set(pk) recip_keys = [pk] router_keys = [] service = Service( - TEST_DID, "indy", "IndyAgent", recip_keys, router_keys, TEST_ENDPOINT, + TEST_DID, + "indy", + "IndyAgent", + recip_keys, + router_keys, + TEST_ENDPOINT, ) doc.set(service) yield doc diff --git a/aries_cloudagent/protocols/connections/v1_0/handlers/tests/test_response_handler.py b/aries_cloudagent/protocols/connections/v1_0/handlers/tests/test_response_handler.py index 4161b08147..96c1238eb8 100644 --- a/aries_cloudagent/protocols/connections/v1_0/handlers/tests/test_response_handler.py +++ b/aries_cloudagent/protocols/connections/v1_0/handlers/tests/test_response_handler.py @@ -44,13 +44,23 @@ def did_doc(): ident = "1" pk_value = TEST_VERKEY pk = PublicKey( - TEST_DID, ident, pk_value, PublicKeyType.ED25519_SIG_2018, controller, False, + TEST_DID, + ident, + pk_value, + PublicKeyType.ED25519_SIG_2018, + controller, + False, ) doc.set(pk) recip_keys = [pk] router_keys = [] service = Service( - TEST_DID, "indy", "IndyAgent", recip_keys, router_keys, TEST_ENDPOINT, + TEST_DID, + "indy", + "IndyAgent", + recip_keys, + router_keys, + TEST_ENDPOINT, ) doc.set(service) yield doc 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 0fd3a98393..fd228ce5fe 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 @@ -103,7 +103,8 @@ def test_make_model_invalid(self): endpoint="https://example.com/endpoint", ), ConnectionInvitation( - label="no-did-no-recip-keys", endpoint="https://example.com/endpoint", + label="no-did-no-recip-keys", + endpoint="https://example.com/endpoint", ), ConnectionInvitation( label="no-did-no-endpoint", diff --git a/aries_cloudagent/protocols/connections/v1_0/routes.py b/aries_cloudagent/protocols/connections/v1_0/routes.py index a80cf818eb..9c21695399 100644 --- a/aries_cloudagent/protocols/connections/v1_0/routes.py +++ b/aries_cloudagent/protocols/connections/v1_0/routes.py @@ -108,7 +108,11 @@ class ConnectionStaticResultSchema(OpenAPISchema): class ConnectionsListQueryStringSchema(OpenAPISchema): """Parameters and validators for connections list request query string.""" - alias = fields.Str(description="Alias", required=False, example="Barry",) + alias = fields.Str( + description="Alias", + required=False, + example="Barry", + ) initiator = fields.Str( description="Connection initiator", required=False, @@ -140,7 +144,11 @@ class ConnectionsListQueryStringSchema(OpenAPISchema): class CreateInvitationQueryStringSchema(OpenAPISchema): """Parameters and validators for create invitation request query string.""" - alias = fields.Str(description="Alias", required=False, example="Barry",) + alias = fields.Str( + description="Alias", + required=False, + example="Barry", + ) auto_accept = fields.Boolean( description="Auto-accept connection (default as per configuration)", required=False, @@ -156,7 +164,11 @@ class CreateInvitationQueryStringSchema(OpenAPISchema): class ReceiveInvitationQueryStringSchema(OpenAPISchema): """Parameters and validators for receive invitation request query string.""" - alias = fields.Str(description="Alias", required=False, example="Barry",) + alias = fields.Str( + description="Alias", + required=False, + example="Barry", + ) auto_accept = fields.Boolean( description="Auto-accept connection (defaults to configuration)", required=False, @@ -212,7 +224,8 @@ def connection_sort_key(conn): @docs( - tags=["connection"], summary="Query agent-to-agent connections", + tags=["connection"], + summary="Query agent-to-agent connections", ) @querystring_schema(ConnectionsListQueryStringSchema()) @response_schema(ConnectionListSchema(), 200) @@ -284,7 +297,8 @@ async def connections_retrieve(request: web.BaseRequest): @docs( - tags=["connection"], summary="Create a new connection invitation", + tags=["connection"], + summary="Create a new connection invitation", ) @querystring_schema(CreateInvitationQueryStringSchema()) @response_schema(InvitationResultSchema(), 200) @@ -332,7 +346,8 @@ async def connections_create_invitation(request: web.BaseRequest): @docs( - tags=["connection"], summary="Receive a new connection invitation", + tags=["connection"], + summary="Receive a new connection invitation", ) @querystring_schema(ReceiveInvitationQueryStringSchema()) @request_schema(ReceiveInvitationRequestSchema()) @@ -371,7 +386,8 @@ async def connections_receive_invitation(request: web.BaseRequest): @docs( - tags=["connection"], summary="Accept a stored connection invitation", + tags=["connection"], + summary="Accept a stored connection invitation", ) @match_info_schema(ConnIdMatchInfoSchema()) @querystring_schema(AcceptInvitationQueryStringSchema()) @@ -408,7 +424,8 @@ async def connections_accept_invitation(request: web.BaseRequest): @docs( - tags=["connection"], summary="Accept a stored connection request", + tags=["connection"], + summary="Accept a stored connection request", ) @match_info_schema(ConnIdMatchInfoSchema()) @querystring_schema(AcceptRequestQueryStringSchema()) diff --git a/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py index 28f22cb4a8..445e02f4db 100644 --- a/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py @@ -788,7 +788,11 @@ async def test_resolve_inbound_connection_wallet_not_found_error(self): assert await self.manager.resolve_inbound_connection(receipt) async def test_create_did_document(self): - did_info = DIDInfo(self.test_did, self.test_verkey, None,) + did_info = DIDInfo( + self.test_did, + self.test_verkey, + None, + ) mock_conn = async_mock.MagicMock() mock_conn.connection_id = "dummy" @@ -814,7 +818,11 @@ async def test_create_did_document(self): ) async def test_create_did_document_not_active(self): - did_info = DIDInfo(self.test_did, self.test_verkey, None,) + did_info = DIDInfo( + self.test_did, + self.test_verkey, + None, + ) mock_conn = async_mock.MagicMock() mock_conn.connection_id = "dummy" @@ -835,7 +843,11 @@ async def test_create_did_document_not_active(self): ) async def test_create_did_document_no_services(self): - did_info = DIDInfo(self.test_did, self.test_verkey, None,) + did_info = DIDInfo( + self.test_did, + self.test_verkey, + None, + ) mock_conn = async_mock.MagicMock() mock_conn.connection_id = "dummy" @@ -863,7 +875,11 @@ async def test_create_did_document_no_services(self): ) async def test_create_did_document_no_service_endpoint(self): - did_info = DIDInfo(self.test_did, self.test_verkey, None,) + did_info = DIDInfo( + self.test_did, + self.test_verkey, + None, + ) mock_conn = async_mock.MagicMock() mock_conn.connection_id = "dummy" @@ -894,7 +910,11 @@ async def test_create_did_document_no_service_endpoint(self): ) async def test_create_did_document_no_service_recip_keys(self): - did_info = DIDInfo(self.test_did, self.test_verkey, None,) + did_info = DIDInfo( + self.test_did, + self.test_verkey, + None, + ) mock_conn = async_mock.MagicMock() mock_conn.connection_id = "dummy" @@ -933,7 +953,11 @@ async def test_create_did_document_no_service_recip_keys(self): ) async def test_did_key_storage(self): - did_info = DIDInfo(self.test_did, self.test_verkey, None,) + did_info = DIDInfo( + self.test_did, + self.test_verkey, + None, + ) did_doc = self.make_did_doc( did=self.test_target_did, verkey=self.test_target_verkey @@ -977,7 +1001,8 @@ async def test_get_connection_targets_invitation_no_did(self): ) targets = await self.manager.get_connection_targets( - connection_id=None, connection=mock_conn, + connection_id=None, + connection=mock_conn, ) assert len(targets) == 1 target = targets[0] @@ -990,7 +1015,8 @@ async def test_get_connection_targets_invitation_no_did(self): # Next pass: exercise cache targets = await self.manager.get_connection_targets( - connection_id=None, connection=mock_conn, + connection_id=None, + connection=mock_conn, ) assert len(targets) == 1 target = targets[0] @@ -1038,7 +1064,8 @@ async def test_get_connection_targets_retrieve_connection(self): mock_conn_rec_retrieve_by_id.return_value = mock_conn mock_conn_target_ser.return_value = {"serialized": "value"} targets = await self.manager.get_connection_targets( - connection_id="dummy", connection=None, + connection_id="dummy", + connection=None, ) assert len(targets) == 1 target = targets[0] @@ -1081,7 +1108,8 @@ async def test_get_connection_targets_no_cache(self): ) targets = await self.manager.get_connection_targets( - connection_id=None, connection=mock_conn, + connection_id=None, + connection=mock_conn, ) assert len(targets) == 1 target = targets[0] 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 bb83673086..b17c4d675e 100644 --- a/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py +++ b/aries_cloudagent/protocols/connections/v1_0/tests/test_routes.py @@ -601,8 +601,10 @@ async def test_connections_create_static(self): ) as mock_conn_mgr, async_mock.patch.object( test_module.web, "json_response" ) as mock_response: - mock_conn_mgr.return_value.create_static_connection = async_mock.CoroutineMock( - return_value=(mock_my_info, mock_their_info, mock_conn_rec) + mock_conn_mgr.return_value.create_static_connection = ( + async_mock.CoroutineMock( + return_value=(mock_my_info, mock_their_info, mock_conn_rec) + ) ) await test_module.connections_create_static(mock_req) @@ -653,8 +655,8 @@ async def test_connections_create_static_x(self): with async_mock.patch.object( test_module, "ConnectionManager", autospec=True ) as mock_conn_mgr: - mock_conn_mgr.return_value.create_static_connection = async_mock.CoroutineMock( - side_effect=test_module.WalletError() + mock_conn_mgr.return_value.create_static_connection = ( + async_mock.CoroutineMock(side_effect=test_module.WalletError()) ) with self.assertRaises(test_module.web.HTTPBadRequest): diff --git a/aries_cloudagent/protocols/discovery/v1_0/routes.py b/aries_cloudagent/protocols/discovery/v1_0/routes.py index b3c864e003..3bf08bef64 100644 --- a/aries_cloudagent/protocols/discovery/v1_0/routes.py +++ b/aries_cloudagent/protocols/discovery/v1_0/routes.py @@ -27,7 +27,8 @@ class QueryFeaturesQueryStringSchema(OpenAPISchema): @docs( - tags=["server"], summary="Query supported features", + tags=["server"], + summary="Query supported features", ) @querystring_schema(QueryFeaturesQueryStringSchema()) @response_schema(QueryResultSchema(), 200) diff --git a/aries_cloudagent/protocols/introduction/v0_1/demo_service.py b/aries_cloudagent/protocols/introduction/v0_1/demo_service.py index 993141352d..787d3da3d3 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/demo_service.py +++ b/aries_cloudagent/protocols/introduction/v0_1/demo_service.py @@ -100,7 +100,8 @@ async def return_invitation( tag_filter = {"target_connection_id": target_connection_id} storage: BaseStorage = await self._context.inject(BaseStorage) records = await storage.search_records( - DemoIntroductionService.RECORD_TYPE, tag_filter, + DemoIntroductionService.RECORD_TYPE, + tag_filter, ).fetch_all() found = False diff --git a/aries_cloudagent/protocols/introduction/v0_1/handlers/tests/test_invitation_request_handler.py b/aries_cloudagent/protocols/introduction/v0_1/handlers/tests/test_invitation_request_handler.py index 2fec539ffc..fbe7e302c8 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/handlers/tests/test_invitation_request_handler.py +++ b/aries_cloudagent/protocols/introduction/v0_1/handlers/tests/test_invitation_request_handler.py @@ -31,7 +31,8 @@ async def setUp(self): self.context.connection_ready = True self.context.message = InvitationRequest( - responder="test-agent", message="Hello World", + responder="test-agent", + message="Hello World", ) self.context.update_settings({"accept_requests": False}) diff --git a/aries_cloudagent/protocols/introduction/v0_1/routes.py b/aries_cloudagent/protocols/introduction/v0_1/routes.py index 6424b0551f..7962d30414 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/routes.py +++ b/aries_cloudagent/protocols/introduction/v0_1/routes.py @@ -38,7 +38,8 @@ class ConnIdMatchInfoSchema(OpenAPISchema): @docs( - tags=["introduction"], summary="Start an introduction between two connections", + tags=["introduction"], + summary="Start an introduction between two connections", ) @match_info_schema(ConnIdMatchInfoSchema()) @querystring_schema(IntroStartQueryStringSchema()) diff --git a/aries_cloudagent/protocols/introduction/v0_1/tests/test_service.py b/aries_cloudagent/protocols/introduction/v0_1/tests/test_service.py index d1c1bc68b8..2ce827adc0 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/tests/test_service.py +++ b/aries_cloudagent/protocols/introduction/v0_1/tests/test_service.py @@ -47,7 +47,8 @@ async def test_service_start_introduction_init_conn_rec_not_active(self): ) conn_rec_init = ConnectionRecord( - connection_id=None, state=ConnectionRecord.STATE_INACTIVE, + connection_id=None, + state=ConnectionRecord.STATE_INACTIVE, ) await conn_rec_init.save(self.context) assert conn_rec_init._id @@ -66,7 +67,8 @@ async def test_service_start_introduction_no_target_conn_rec(self): ) conn_rec_init = ConnectionRecord( - connection_id=None, state=ConnectionRecord.STATE_ACTIVE, + connection_id=None, + state=ConnectionRecord.STATE_ACTIVE, ) await conn_rec_init.save(self.context) assert conn_rec_init._id @@ -85,13 +87,15 @@ async def test_service_start_introduction_target_conn_rec_not_active(self): ) conn_rec_init = ConnectionRecord( - connection_id=None, state=ConnectionRecord.STATE_ACTIVE, + connection_id=None, + state=ConnectionRecord.STATE_ACTIVE, ) await conn_rec_init.save(self.context) assert conn_rec_init._id conn_rec_target = ConnectionRecord( - connection_id=None, state=ConnectionRecord.STATE_INACTIVE, + connection_id=None, + state=ConnectionRecord.STATE_INACTIVE, ) await conn_rec_target.save(self.context) assert conn_rec_target._id @@ -111,13 +115,15 @@ async def test_service_start_and_return_introduction(self): start_responder = MockResponder() conn_rec_init = ConnectionRecord( - connection_id=None, state=ConnectionRecord.STATE_ACTIVE, + connection_id=None, + state=ConnectionRecord.STATE_ACTIVE, ) await conn_rec_init.save(self.context) assert conn_rec_init._id conn_rec_target = ConnectionRecord( - connection_id=None, state=ConnectionRecord.STATE_ACTIVE, + connection_id=None, + state=ConnectionRecord.STATE_ACTIVE, ) await conn_rec_target.save(self.context) assert conn_rec_target._id @@ -179,7 +185,8 @@ async def test_service_return_invitation_not_found(self): ) conn_rec_target = ConnectionRecord( - connection_id=None, state=ConnectionRecord.STATE_ACTIVE, + connection_id=None, + state=ConnectionRecord.STATE_ACTIVE, ) await conn_rec_target.save(self.context) assert conn_rec_target._id diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_issue.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_issue.py index e878b12f50..691a12eaf2 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_issue.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_issue.py @@ -69,7 +69,8 @@ class TestCredentialIssue(TestCase): comment="Test", credentials_attach=[ AttachDecorator.from_indy_dict( - indy_dict=indy_cred, ident=ATTACH_DECO_IDS[CREDENTIAL_ISSUE], + indy_dict=indy_cred, + ident=ATTACH_DECO_IDS[CREDENTIAL_ISSUE], ) ], ) @@ -80,7 +81,8 @@ def test_init(self): comment="Test", credentials_attach=[ AttachDecorator.from_indy_dict( - indy_dict=self.indy_cred, ident=ATTACH_DECO_IDS[CREDENTIAL_ISSUE], + indy_dict=self.indy_cred, + ident=ATTACH_DECO_IDS[CREDENTIAL_ISSUE], ) ], ) @@ -94,7 +96,8 @@ def test_type(self): comment="Test", credentials_attach=[ AttachDecorator.from_indy_dict( - indy_dict=self.indy_cred, ident=ATTACH_DECO_IDS[CREDENTIAL_ISSUE], + indy_dict=self.indy_cred, + ident=ATTACH_DECO_IDS[CREDENTIAL_ISSUE], ) ], ) diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_offer.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_offer.py index 87c7af20f5..8688accc6b 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_offer.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_offer.py @@ -43,7 +43,8 @@ class TestCredentialOffer(TestCase): credential_preview=preview, offers_attach=[ AttachDecorator.from_indy_dict( - indy_dict=indy_offer, ident=ATTACH_DECO_IDS[CREDENTIAL_OFFER], + indy_dict=indy_offer, + ident=ATTACH_DECO_IDS[CREDENTIAL_OFFER], ) ], ) @@ -55,7 +56,8 @@ def test_init(self): credential_preview=self.preview, offers_attach=[ AttachDecorator.from_indy_dict( - indy_dict=self.indy_offer, ident=ATTACH_DECO_IDS[CREDENTIAL_OFFER], + indy_dict=self.indy_offer, + ident=ATTACH_DECO_IDS[CREDENTIAL_OFFER], ) ], ) @@ -70,7 +72,8 @@ def test_type(self): credential_preview=self.preview, offers_attach=[ AttachDecorator.from_indy_dict( - indy_dict=self.indy_offer, ident=ATTACH_DECO_IDS[CREDENTIAL_OFFER], + indy_dict=self.indy_offer, + ident=ATTACH_DECO_IDS[CREDENTIAL_OFFER], ) ], ) @@ -103,7 +106,8 @@ def test_serialize(self, mock_credential_offer_schema_dump): credential_preview=self.preview, offers_attach=[ AttachDecorator.from_indy_dict( - indy_dict=self.indy_offer, ident=ATTACH_DECO_IDS[CREDENTIAL_OFFER], + indy_dict=self.indy_offer, + ident=ATTACH_DECO_IDS[CREDENTIAL_OFFER], ) ], ) diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_proposal.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_proposal.py index ba4e191d66..17d75170ab 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_proposal.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_proposal.py @@ -109,7 +109,9 @@ class TestCredentialProposalSchema(TestCase): """Test credential cred proposal schema.""" credential_proposals = [ - CredentialProposal(credential_proposal=CRED_PREVIEW,), + CredentialProposal( + credential_proposal=CRED_PREVIEW, + ), CredentialProposal( comment="Hello World", credential_proposal=CRED_PREVIEW, diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_request.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_request.py index 4e474a9194..79cd3a54a8 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_request.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/tests/test_credential_request.py @@ -34,7 +34,8 @@ class TestCredentialRequest(TestCase): comment="Test", requests_attach=[ AttachDecorator.from_indy_dict( - indy_dict=indy_cred_req, ident=ATTACH_DECO_IDS[CREDENTIAL_REQUEST], + indy_dict=indy_cred_req, + ident=ATTACH_DECO_IDS[CREDENTIAL_REQUEST], ) ], ) diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/routes.py b/aries_cloudagent/protocols/issue_credential/v1_0/routes.py index 55ae95ed1e..5591455dfa 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/routes.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/routes.py @@ -293,10 +293,14 @@ class RevokeQueryStringSchema(OpenAPISchema): """Parameters and validators for revocation request.""" rev_reg_id = fields.Str( - description="Revocation registry identifier", required=True, **INDY_REV_REG_ID, + description="Revocation registry identifier", + required=True, + **INDY_REV_REG_ID, ) cred_rev_id = fields.Int( - description="Credential revocation identifier", required=True, **NATURAL_NUM, + description="Credential revocation identifier", + required=True, + **NATURAL_NUM, ) publish = fields.Boolean( description=( @@ -431,7 +435,8 @@ async def credential_exchange_create(request: web.BaseRequest): **{t: body.get(t) for t in CRED_DEF_TAGS if body.get(t)}, ) credential_proposal.assign_trace_decorator( - context.settings, trace_msg, + context.settings, + trace_msg, ) trace_event( @@ -446,7 +451,9 @@ async def credential_exchange_create(request: web.BaseRequest): credential_exchange_record, credential_offer_message, ) = await credential_manager.prepare_send( - None, credential_proposal=credential_proposal, auto_remove=auto_remove, + None, + credential_proposal=credential_proposal, + auto_remove=auto_remove, ) except (StorageError, BaseModelError) as err: raise web.HTTPBadRequest(reason=err.roll_up) from err @@ -513,7 +520,8 @@ async def credential_exchange_send(request: web.BaseRequest): **{t: body.get(t) for t in CRED_DEF_TAGS if body.get(t)}, ) credential_proposal.assign_trace_decorator( - context.settings, trace_msg, + context.settings, + trace_msg, ) trace_event( @@ -614,7 +622,8 @@ async def credential_exchange_send_proposal(request: web.BaseRequest): ) await outbound_handler( - credential_proposal, connection_id=connection_id, + credential_proposal, + connection_id=connection_id, ) trace_event( @@ -646,7 +655,8 @@ async def _create_free_offer( cred_def_id=cred_def_id, ) credential_proposal.assign_trace_decorator( - context.settings, trace_msg, + context.settings, + trace_msg, ) credential_proposal_dict = credential_proposal.serialize() @@ -662,9 +672,10 @@ async def _create_free_offer( credential_manager = CredentialManager(context) - (cred_ex_record, credential_offer_message,) = await credential_manager.create_offer( - cred_ex_record, comment=comment - ) + ( + cred_ex_record, + credential_offer_message, + ) = await credential_manager.create_offer(cred_ex_record, comment=comment) return (cred_ex_record, credential_offer_message) @@ -1137,7 +1148,8 @@ async def credential_exchange_store(request: web.BaseRequest): @docs( - tags=["issue-credential"], summary="Revoke an issued credential", + tags=["issue-credential"], + summary="Revoke an issued credential", ) @querystring_schema(RevokeQueryStringSchema()) async def credential_exchange_revoke(request: web.BaseRequest): 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 cf2b0218b0..ccd5fcf5e6 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 @@ -1760,7 +1760,11 @@ async def test_credential_exchange_remove_x(self): async def test_credential_exchange_revoke(self): mock = async_mock.MagicMock( - query={"rev_reg_id": "rr_id", "cred_rev_id": "23", "publish": "false",} + query={ + "rev_reg_id": "rr_id", + "cred_rev_id": "23", + "publish": "false", + } ) mock.app = { "request_context": async_mock.patch.object( @@ -1783,7 +1787,11 @@ async def test_credential_exchange_revoke(self): async def test_credential_exchange_revoke_not_found(self): mock = async_mock.MagicMock( - query={"rev_reg_id": "rr_id", "cred_rev_id": "23", "publish": "false",} + query={ + "rev_reg_id": "rr_id", + "cred_rev_id": "23", + "publish": "false", + } ) mock.app = { "request_context": async_mock.patch.object( diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/models/invitation.py b/aries_cloudagent/protocols/out_of_band/v1_0/models/invitation.py index d5f8971458..e67c512012 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/models/invitation.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/models/invitation.py @@ -67,7 +67,9 @@ class Meta: model_class = Invitation invitation_id = fields.Str( - required=False, description="Invitation identifier", example=UUIDFour.EXAMPLE, + required=False, + description="Invitation identifier", + example=UUIDFour.EXAMPLE, ) state = fields.Str( required=False, @@ -75,5 +77,6 @@ class Meta: example=Invitation.STATE_AWAIT_RESPONSE, ) invitation = fields.Dict( - required=False, description="Out of band invitation object", + required=False, + description="Out of band invitation object", ) diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/routes.py b/aries_cloudagent/protocols/out_of_band/v1_0/routes.py index a185414913..484e374a03 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/routes.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/routes.py @@ -39,7 +39,8 @@ class InvitationReceiveRequestSchema(InvitationSchema): @docs( - tags=["out-of-band"], summary="Create a new connection invitation", + tags=["out-of-band"], + summary="Create a new connection invitation", ) @request_schema(InvitationCreateRequestSchema()) async def invitation_create(request: web.BaseRequest): @@ -77,7 +78,8 @@ async def invitation_create(request: web.BaseRequest): @docs( - tags=["out-of-band"], summary="Create a new connection invitation", + tags=["out-of-band"], + summary="Create a new connection invitation", ) @request_schema(InvitationReceiveRequestSchema()) async def invitation_receive(request: web.BaseRequest): 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 ed24c7f5f0..9358022bf9 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 @@ -104,11 +104,19 @@ async def test_called_auto_present(self): "requested_attributes": { "0_favourite_uuid": { "name": "favourite", - "restrictions": [{"cred_def_id": CD_ID,}], + "restrictions": [ + { + "cred_def_id": CD_ID, + } + ], }, "1_icon_uuid": { "name": "icon", - "restrictions": [{"cred_def_id": CD_ID,}], + "restrictions": [ + { + "cred_def_id": CD_ID, + } + ], }, }, "requested_predicates": {}, @@ -140,8 +148,10 @@ async def test_called_auto_present(self): handler, "BaseHolder", autospec=True ) as mock_holder: - mock_holder.get_credentials_for_presentation_request_by_referent = async_mock.CoroutineMock( - return_value=[{"cred_info": {"referent": "dummy"}}] + mock_holder.get_credentials_for_presentation_request_by_referent = ( + async_mock.CoroutineMock( + return_value=[{"cred_info": {"referent": "dummy"}}] + ) ) request_context.inject = async_mock.CoroutineMock(return_value=mock_holder) @@ -185,11 +195,19 @@ async def test_called_auto_present_no_preview(self): "requested_attributes": { "0_favourite_uuid": { "name": "favourite", - "restrictions": [{"cred_def_id": CD_ID,}], + "restrictions": [ + { + "cred_def_id": CD_ID, + } + ], }, "1_icon_uuid": { "name": "icon", - "restrictions": [{"cred_def_id": CD_ID,}], + "restrictions": [ + { + "cred_def_id": CD_ID, + } + ], }, }, "requested_predicates": {}, @@ -206,11 +224,13 @@ async def test_called_auto_present_no_preview(self): handler, "BaseHolder", autospec=True ) as mock_holder: - mock_holder.get_credentials_for_presentation_request_by_referent = async_mock.CoroutineMock( - return_value=[ - {"cred_info": {"referent": "dummy-0"}}, - {"cred_info": {"referent": "dummy-1"}}, - ] + mock_holder.get_credentials_for_presentation_request_by_referent = ( + async_mock.CoroutineMock( + return_value=[ + {"cred_info": {"referent": "dummy-0"}}, + {"cred_info": {"referent": "dummy-1"}}, + ] + ) ) request_context.inject = async_mock.CoroutineMock(return_value=mock_holder) @@ -257,7 +277,11 @@ async def test_called_auto_present_pred_no_match(self): "name": "score", "p_type": ">=", "p_value": "1000000", - "restrictions": [{"cred_def_id": CD_ID,}], + "restrictions": [ + { + "cred_def_id": CD_ID, + } + ], } }, } @@ -273,8 +297,8 @@ async def test_called_auto_present_pred_no_match(self): handler, "BaseHolder", autospec=True ) as mock_holder: - mock_holder.get_credentials_for_presentation_request_by_referent = async_mock.CoroutineMock( - return_value=[] + mock_holder.get_credentials_for_presentation_request_by_referent = ( + async_mock.CoroutineMock(return_value=[]) ) request_context.inject = async_mock.CoroutineMock(return_value=mock_holder) @@ -317,7 +341,11 @@ async def test_called_auto_present_pred_single_match(self): "name": "score", "p_type": ">=", "p_value": "1000000", - "restrictions": [{"cred_def_id": CD_ID,}], + "restrictions": [ + { + "cred_def_id": CD_ID, + } + ], } }, } @@ -333,8 +361,10 @@ async def test_called_auto_present_pred_single_match(self): handler, "BaseHolder", autospec=True ) as mock_holder: - mock_holder.get_credentials_for_presentation_request_by_referent = async_mock.CoroutineMock( - return_value=[{"cred_info": {"referent": "dummy-0"}}] + mock_holder.get_credentials_for_presentation_request_by_referent = ( + async_mock.CoroutineMock( + return_value=[{"cred_info": {"referent": "dummy-0"}}] + ) ) request_context.inject = async_mock.CoroutineMock(return_value=mock_holder) @@ -381,7 +411,11 @@ async def test_called_auto_present_pred_multi_match(self): "name": "score", "p_type": ">=", "p_value": "1000000", - "restrictions": [{"cred_def_id": CD_ID,}], + "restrictions": [ + { + "cred_def_id": CD_ID, + } + ], } }, } @@ -397,11 +431,13 @@ async def test_called_auto_present_pred_multi_match(self): handler, "BaseHolder", autospec=True ) as mock_holder: - mock_holder.get_credentials_for_presentation_request_by_referent = async_mock.CoroutineMock( - return_value=[ - {"cred_info": {"referent": "dummy-0"}}, - {"cred_info": {"referent": "dummy-1"}}, - ] + mock_holder.get_credentials_for_presentation_request_by_referent = ( + async_mock.CoroutineMock( + return_value=[ + {"cred_info": {"referent": "dummy-0"}}, + {"cred_info": {"referent": "dummy-1"}}, + ] + ) ) request_context.inject = async_mock.CoroutineMock(return_value=mock_holder) @@ -445,11 +481,19 @@ async def test_called_auto_present_multi_cred_match_reft(self): "requested_attributes": { "0_favourite_uuid": { "name": "favourite", - "restrictions": [{"cred_def_id": CD_ID,}], + "restrictions": [ + { + "cred_def_id": CD_ID, + } + ], }, "1_icon_uuid": { "name": "icon", - "restrictions": [{"cred_def_id": CD_ID,}], + "restrictions": [ + { + "cred_def_id": CD_ID, + } + ], }, }, "requested_predicates": {}, @@ -481,42 +525,44 @@ async def test_called_auto_present_multi_cred_match_reft(self): handler, "BaseHolder", autospec=True ) as mock_holder: - mock_holder.get_credentials_for_presentation_request_by_referent = async_mock.CoroutineMock( - return_value=[ - { - "cred_info": { - "referent": "dummy-0", - "cred_def_id": CD_ID, - "attrs": { - "ident": "zero", - "favourite": "potato", - "icon": "cG90YXRv", - }, - } - }, - { - "cred_info": { - "referent": "dummy-1", - "cred_def_id": CD_ID, - "attrs": { - "ident": "one", - "favourite": "spud", - "icon": "c3B1ZA==", - }, - } - }, - { - "cred_info": { - "referent": "dummy-2", - "cred_def_id": CD_ID, - "attrs": { - "ident": "two", - "favourite": "patate", - "icon": "cGF0YXRl", - }, - } - }, - ] + mock_holder.get_credentials_for_presentation_request_by_referent = ( + async_mock.CoroutineMock( + return_value=[ + { + "cred_info": { + "referent": "dummy-0", + "cred_def_id": CD_ID, + "attrs": { + "ident": "zero", + "favourite": "potato", + "icon": "cG90YXRv", + }, + } + }, + { + "cred_info": { + "referent": "dummy-1", + "cred_def_id": CD_ID, + "attrs": { + "ident": "one", + "favourite": "spud", + "icon": "c3B1ZA==", + }, + } + }, + { + "cred_info": { + "referent": "dummy-2", + "cred_def_id": CD_ID, + "attrs": { + "ident": "two", + "favourite": "patate", + "icon": "cGF0YXRl", + }, + } + }, + ] + ) ) request_context.inject = async_mock.CoroutineMock(return_value=mock_holder) @@ -560,7 +606,11 @@ async def test_called_auto_present_bait_and_switch(self): "requested_attributes": { "0_favourite_uuid": { "name": "favourite", - "restrictions": [{"cred_def_id": CD_ID,}], + "restrictions": [ + { + "cred_def_id": CD_ID, + } + ], } }, "requested_predicates": {}, diff --git a/aries_cloudagent/protocols/present_proof/v1_0/manager.py b/aries_cloudagent/protocols/present_proof/v1_0/manager.py index a4741ccf7a..518219a12c 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/manager.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/manager.py @@ -20,6 +20,8 @@ from .messages.presentation import Presentation from .message_types import ATTACH_DECO_IDS, PRESENTATION, PRESENTATION_REQUEST +LOGGER = logging.getLogger(__name__) + class PresentationManagerError(BaseError): """Presentation error.""" @@ -37,7 +39,6 @@ def __init__(self, context: InjectionContext): """ self._context = context - self._logger = logging.getLogger(__name__) @property def context(self) -> InjectionContext: @@ -393,7 +394,7 @@ async def create_presentation( ) ) except HolderError as e: - self._logger.error( + LOGGER.error( f"Failed to create revocation state: {e.error_code}, {e.message}" ) raise e @@ -615,7 +616,7 @@ async def send_presentation_ack( connection_id=presentation_exchange_record.connection_id, ) else: - self._logger.warning( + LOGGER.warning( "Configuration has no BaseResponder: cannot ack presentation on %s", presentation_exchange_record.thread_id, ) diff --git a/aries_cloudagent/protocols/present_proof/v1_0/messages/inner/presentation_preview.py b/aries_cloudagent/protocols/present_proof/v1_0/messages/inner/presentation_preview.py index 7acae7d918..605b7f9b20 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/messages/inner/presentation_preview.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/messages/inner/presentation_preview.py @@ -370,7 +370,8 @@ def non_revoc(cred_def_id: str) -> NonRevocationInterval: else: proof_req["requested_attributes"][ "{}_{}_uuid".format( - len(proof_req["requested_attributes"]), canon(attr_spec.name), + len(proof_req["requested_attributes"]), + canon(attr_spec.name), ) ] = { "name": attr_spec.name, diff --git a/aries_cloudagent/protocols/present_proof/v1_0/messages/tests/test_presentation.py b/aries_cloudagent/protocols/present_proof/v1_0/messages/tests/test_presentation.py index a8623bbdcd..c9c26446b4 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/messages/tests/test_presentation.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/messages/tests/test_presentation.py @@ -1661,7 +1661,8 @@ comment="Test", presentations_attach=[ AttachDecorator.from_indy_dict( - indy_dict=INDY_PROOF, ident=ATTACH_DECO_IDS[PRESENTATION], + indy_dict=INDY_PROOF, + ident=ATTACH_DECO_IDS[PRESENTATION], ) ], ) @@ -1687,7 +1688,8 @@ def test_deserialize(self): "comment": "Hello World", "presentations~attach": [ AttachDecorator.from_indy_dict( - indy_dict=INDY_PROOF, ident=ATTACH_DECO_IDS[PRESENTATION], + indy_dict=INDY_PROOF, + ident=ATTACH_DECO_IDS[PRESENTATION], ).serialize() ], } @@ -1705,7 +1707,8 @@ def test_serialize(self): "@type": PRESENTATION, "presentations~attach": [ AttachDecorator.from_indy_dict( - indy_dict=INDY_PROOF, ident=ATTACH_DECO_IDS[PRESENTATION], + indy_dict=INDY_PROOF, + ident=ATTACH_DECO_IDS[PRESENTATION], ).serialize() ], "comment": "Test", diff --git a/aries_cloudagent/protocols/present_proof/v1_0/messages/tests/test_presentation_request.py b/aries_cloudagent/protocols/present_proof/v1_0/messages/tests/test_presentation_request.py index 263f5283c1..ccb1cc4fcb 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/messages/tests/test_presentation_request.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/messages/tests/test_presentation_request.py @@ -67,7 +67,8 @@ comment="Test", request_presentations_attach=[ AttachDecorator.from_indy_dict( - indy_dict=INDY_PROOF_REQ, ident=ATTACH_DECO_IDS[PRESENTATION_REQUEST], + indy_dict=INDY_PROOF_REQ, + ident=ATTACH_DECO_IDS[PRESENTATION_REQUEST], ) ], ) diff --git a/aries_cloudagent/protocols/present_proof/v1_0/routes.py b/aries_cloudagent/protocols/present_proof/v1_0/routes.py index c8a85f9bb1..fecf22d8b4 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/routes.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/routes.py @@ -600,7 +600,8 @@ async def presentation_exchange_send_proposal(request: web.BaseRequest): trace_msg = body.get("trace") presentation_proposal_message.assign_trace_decorator( - context.settings, trace_msg, + context.settings, + trace_msg, ) auto_present = body.get( "auto_present", context.settings.get("debug.auto_respond_presentation_request") @@ -680,7 +681,8 @@ async def presentation_exchange_create_request(request: web.BaseRequest): ) trace_msg = body.get("trace") presentation_request_message.assign_trace_decorator( - context.settings, trace_msg, + context.settings, + trace_msg, ) presentation_manager = PresentationManager(context) @@ -757,7 +759,8 @@ async def presentation_exchange_send_free_request(request: web.BaseRequest): ) trace_msg = body.get("trace") presentation_request_message.assign_trace_decorator( - context.settings, trace_msg, + context.settings, + trace_msg, ) presentation_manager = PresentationManager(context) @@ -853,7 +856,8 @@ async def presentation_exchange_send_bound_request(request: web.BaseRequest): trace_msg = body.get("trace") presentation_request_message.assign_trace_decorator( - context.settings, trace_msg, + context.settings, + trace_msg, ) await outbound_handler(presentation_request_message, connection_id=connection_id) @@ -937,7 +941,8 @@ async def presentation_exchange_send_presentation(request: web.BaseRequest): trace_msg = body.get("trace") presentation_message.assign_trace_decorator( - context.settings, trace_msg, + context.settings, + trace_msg, ) await outbound_handler(presentation_message, connection_id=connection_id) @@ -1060,13 +1065,16 @@ async def register(app: web.Application): allow_head=False, ), web.post( - "/present-proof/send-proposal", presentation_exchange_send_proposal, + "/present-proof/send-proposal", + presentation_exchange_send_proposal, ), web.post( - "/present-proof/create-request", presentation_exchange_create_request, + "/present-proof/create-request", + presentation_exchange_create_request, ), web.post( - "/present-proof/send-request", presentation_exchange_send_free_request, + "/present-proof/send-request", + presentation_exchange_send_free_request, ), web.post( "/present-proof/records/{pres_ex_id}/send-request", 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 b58b4aaebf..cbf3dd0215 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 @@ -352,8 +352,8 @@ async def test_presentation_exchange_send_proposal(self): importlib.reload(test_module) mock_presentation_exchange_record = async_mock.MagicMock() - mock_presentation_manager.return_value.create_exchange_for_proposal = async_mock.CoroutineMock( - return_value=mock_presentation_exchange_record + mock_presentation_manager.return_value.create_exchange_for_proposal = ( + async_mock.CoroutineMock(return_value=mock_presentation_exchange_record) ) mock_preview.return_value.deserialize.return_value = async_mock.MagicMock() @@ -441,8 +441,8 @@ async def test_presentation_exchange_send_proposal_x(self): importlib.reload(test_module) mock_presentation_exchange_record = async_mock.MagicMock() - mock_presentation_manager.return_value.create_exchange_for_proposal = async_mock.CoroutineMock( - side_effect=test_module.StorageError() + mock_presentation_manager.return_value.create_exchange_for_proposal = ( + async_mock.CoroutineMock(side_effect=test_module.StorageError()) ) with self.assertRaises(test_module.web.HTTPBadRequest): @@ -473,7 +473,8 @@ async def test_presentation_exchange_create_request(self): "aries_cloudagent.protocols.present_proof.v1_0.models.presentation_exchange.V10PresentationExchange", autospec=True, ) as mock_presentation_exchange, async_mock.patch( - "aries_cloudagent.indy.util.generate_pr_nonce", autospec=True, + "aries_cloudagent.indy.util.generate_pr_nonce", + autospec=True, ) as mock_generate_nonce: # Since we are mocking import @@ -528,7 +529,8 @@ async def test_presentation_exchange_create_request_x(self): "aries_cloudagent.protocols.present_proof.v1_0.models.presentation_exchange.V10PresentationExchange", autospec=True, ) as mock_presentation_exchange, async_mock.patch( - "aries_cloudagent.indy.util.generate_pr_nonce", autospec=True, + "aries_cloudagent.indy.util.generate_pr_nonce", + autospec=True, ) as mock_generate_nonce: # Since we are mocking import @@ -569,7 +571,8 @@ async def test_presentation_exchange_send_free_request(self): "aries_cloudagent.protocols.present_proof.v1_0.manager.PresentationManager", autospec=True, ) as mock_presentation_manager, async_mock.patch( - "aries_cloudagent.indy.util.generate_pr_nonce", autospec=True, + "aries_cloudagent.indy.util.generate_pr_nonce", + autospec=True, ) as mock_generate_nonce, async_mock.patch( "aries_cloudagent.protocols.present_proof.v1_0.messages.inner.presentation_preview.PresentationPreview", autospec=True, @@ -681,7 +684,8 @@ async def test_presentation_exchange_send_free_request_x(self): "aries_cloudagent.protocols.present_proof.v1_0.manager.PresentationManager", autospec=True, ) as mock_presentation_manager, async_mock.patch( - "aries_cloudagent.indy.util.generate_pr_nonce", autospec=True, + "aries_cloudagent.indy.util.generate_pr_nonce", + autospec=True, ) as mock_generate_nonce, async_mock.patch.object( test_module, "PresentationPreview", autospec=True ) as mock_presentation_proposal, async_mock.patch.object( @@ -750,7 +754,8 @@ async def test_presentation_exchange_send_bound_request(self): "aries_cloudagent.protocols.present_proof.v1_0.manager.PresentationManager", autospec=True, ) as mock_presentation_manager, async_mock.patch( - "aries_cloudagent.indy.util.generate_pr_nonce", autospec=True, + "aries_cloudagent.indy.util.generate_pr_nonce", + autospec=True, ) as mock_generate_nonce, async_mock.patch.object( test_module, "PresentationPreview", autospec=True ) as mock_presentation_proposal, async_mock.patch.object( @@ -818,7 +823,8 @@ async def test_presentation_exchange_send_bound_request_not_found(self): "aries_cloudagent.protocols.present_proof.v1_0.manager.PresentationManager", autospec=True, ) as mock_presentation_manager, async_mock.patch( - "aries_cloudagent.indy.util.generate_pr_nonce", autospec=True, + "aries_cloudagent.indy.util.generate_pr_nonce", + autospec=True, ) as mock_generate_nonce, async_mock.patch.object( test_module, "PresentationPreview", autospec=True ) as mock_presentation_proposal, async_mock.patch.object( @@ -869,7 +875,8 @@ async def test_presentation_exchange_send_bound_request_not_ready(self): "aries_cloudagent.protocols.present_proof.v1_0.manager.PresentationManager", autospec=True, ) as mock_presentation_manager, async_mock.patch( - "aries_cloudagent.indy.util.generate_pr_nonce", autospec=True, + "aries_cloudagent.indy.util.generate_pr_nonce", + autospec=True, ) as mock_generate_nonce, async_mock.patch.object( test_module, "PresentationPreview", autospec=True ) as mock_presentation_proposal, async_mock.patch.object( @@ -953,7 +960,8 @@ async def test_presentation_exchange_send_bound_request_x(self): "aries_cloudagent.protocols.present_proof.v1_0.manager.PresentationManager", autospec=True, ) as mock_presentation_manager, async_mock.patch( - "aries_cloudagent.indy.util.generate_pr_nonce", autospec=True, + "aries_cloudagent.indy.util.generate_pr_nonce", + autospec=True, ) as mock_generate_nonce, async_mock.patch.object( test_module, "PresentationPreview", autospec=True ) as mock_presentation_proposal, async_mock.patch.object( @@ -1082,7 +1090,8 @@ async def test_presentation_exchange_send_presentation_not_found(self): "aries_cloudagent.protocols.present_proof.v1_0.manager.PresentationManager", autospec=True, ) as mock_presentation_manager, async_mock.patch( - "aries_cloudagent.indy.util.generate_pr_nonce", autospec=True, + "aries_cloudagent.indy.util.generate_pr_nonce", + autospec=True, ) as mock_generate_nonce, async_mock.patch.object( test_module, "PresentationPreview", autospec=True ) as mock_presentation_proposal, async_mock.patch.object( @@ -1128,7 +1137,8 @@ async def test_presentation_exchange_send_presentation_not_ready(self): "aries_cloudagent.protocols.present_proof.v1_0.manager.PresentationManager", autospec=True, ) as mock_presentation_manager, async_mock.patch( - "aries_cloudagent.indy.util.generate_pr_nonce", autospec=True, + "aries_cloudagent.indy.util.generate_pr_nonce", + autospec=True, ) as mock_generate_nonce, async_mock.patch.object( test_module, "PresentationPreview", autospec=True ) as mock_presentation_proposal, async_mock.patch.object( @@ -1207,7 +1217,8 @@ async def test_presentation_exchange_send_presentation_x(self): "aries_cloudagent.protocols.present_proof.v1_0.manager.PresentationManager", autospec=True, ) as mock_presentation_manager, async_mock.patch( - "aries_cloudagent.indy.util.generate_pr_nonce", autospec=True, + "aries_cloudagent.indy.util.generate_pr_nonce", + autospec=True, ) as mock_generate_nonce, async_mock.patch.object( test_module, "PresentationPreview", autospec=True ) as mock_presentation_proposal, async_mock.patch.object( @@ -1264,7 +1275,8 @@ async def test_presentation_exchange_verify_presentation(self): "aries_cloudagent.protocols.present_proof.v1_0.manager.PresentationManager", autospec=True, ) as mock_presentation_manager, async_mock.patch( - "aries_cloudagent.indy.util.generate_pr_nonce", autospec=True, + "aries_cloudagent.indy.util.generate_pr_nonce", + autospec=True, ) as mock_generate_nonce, async_mock.patch( "aries_cloudagent.protocols.present_proof.v1_0.messages.inner.presentation_preview.PresentationPreview", autospec=True, diff --git a/aries_cloudagent/protocols/routing/v1_0/handlers/tests/test_forward_handler.py b/aries_cloudagent/protocols/routing/v1_0/handlers/tests/test_forward_handler.py index 4a7ae35ce8..750ec81939 100644 --- a/aries_cloudagent/protocols/routing/v1_0/handlers/tests/test_forward_handler.py +++ b/aries_cloudagent/protocols/routing/v1_0/handlers/tests/test_forward_handler.py @@ -46,8 +46,14 @@ async def test_handle(self): mock_mgr.return_value.get_recipient = async_mock.CoroutineMock( return_value=RouteRecord(connection_id="dummy") ) - mock_connection_mgr.return_value.get_connection_targets = async_mock.CoroutineMock( - return_value=[ConnectionTarget(recipient_keys=["recip_key"],)] + mock_connection_mgr.return_value.get_connection_targets = ( + async_mock.CoroutineMock( + return_value=[ + ConnectionTarget( + recipient_keys=["recip_key"], + ) + ] + ) ) await handler.handle(self.context, responder) diff --git a/aries_cloudagent/protocols/routing/v1_0/handlers/tests/test_query_update_handlers.py b/aries_cloudagent/protocols/routing/v1_0/handlers/tests/test_query_update_handlers.py index 735820877a..7aa7044a69 100644 --- a/aries_cloudagent/protocols/routing/v1_0/handlers/tests/test_query_update_handlers.py +++ b/aries_cloudagent/protocols/routing/v1_0/handlers/tests/test_query_update_handlers.py @@ -79,7 +79,8 @@ async def test_handle_update_query(self): self.context.message = RouteUpdateRequest( updates=[ RouteUpdate( - recipient_key=TEST_VERKEY, action=RouteUpdate.ACTION_CREATE, + recipient_key=TEST_VERKEY, + action=RouteUpdate.ACTION_CREATE, ) ] ) diff --git a/aries_cloudagent/revocation/models/issuer_rev_reg_record.py b/aries_cloudagent/revocation/models/issuer_rev_reg_record.py index ec83a9373a..19d80f7098 100644 --- a/aries_cloudagent/revocation/models/issuer_rev_reg_record.py +++ b/aries_cloudagent/revocation/models/issuer_rev_reg_record.py @@ -196,19 +196,23 @@ async def set_tails_file_public_uri( await self.save(context, reason="Set tails file public URI") async def stage_pending_registry_definition( - self, context: InjectionContext, + self, + context: InjectionContext, ): """Prepare registry definition for future use.""" await shield(self.generate_registry(context)) tails_base_url = context.settings.get("tails_server_base_url") await self.set_tails_file_public_uri( - context, f"{tails_base_url}/{self.revoc_reg_id}", + context, + f"{tails_base_url}/{self.revoc_reg_id}", ) await self.publish_registry_definition(context) tails_server: BaseTailsServer = await context.inject(BaseTailsServer) await tails_server.upload_tails_file( - context, self.revoc_reg_id, self.tails_local_path, + context, + self.revoc_reg_id, + self.tails_local_path, ) async def publish_registry_definition(self, context: InjectionContext): diff --git a/aries_cloudagent/revocation/models/tests/test_issuer_rev_reg_record.py b/aries_cloudagent/revocation/models/tests/test_issuer_rev_reg_record.py index ca7e3e8633..62e54d8ee1 100644 --- a/aries_cloudagent/revocation/models/tests/test_issuer_rev_reg_record.py +++ b/aries_cloudagent/revocation/models/tests/test_issuer_rev_reg_record.py @@ -57,7 +57,9 @@ def setUp(self): async def test_generate_registry_etc(self): rec = IssuerRevRegRecord( - issuer_did=TEST_DID, cred_def_id=CRED_DEF_ID, revoc_reg_id=REV_REG_ID, + issuer_did=TEST_DID, + cred_def_id=CRED_DEF_ID, + revoc_reg_id=REV_REG_ID, ) issuer = async_mock.MagicMock(BaseIssuer) self.context.injector.bind_instance(BaseIssuer, issuer) diff --git a/aries_cloudagent/revocation/routes.py b/aries_cloudagent/revocation/routes.py index b6b6b0e219..1f390cb5fc 100644 --- a/aries_cloudagent/revocation/routes.py +++ b/aries_cloudagent/revocation/routes.py @@ -90,7 +90,9 @@ class RevRegIdMatchInfoSchema(OpenAPISchema): """Path parameters and validators for request taking rev reg id.""" rev_reg_id = fields.Str( - description="Revocation Registry identifier", required=True, **INDY_REV_REG_ID, + description="Revocation Registry identifier", + required=True, + **INDY_REV_REG_ID, ) @@ -141,7 +143,9 @@ async def revocation_create_registry(request: web.BaseRequest): issuer_did = credential_definition_id.split(":")[0] revoc = IndyRevocation(context) registry_record = await revoc.init_issuer_registry( - credential_definition_id, issuer_did, max_cred_num=max_cred_num, + credential_definition_id, + issuer_did, + max_cred_num=max_cred_num, ) except RevocationNotSupportedError as e: raise web.HTTPBadRequest(reason=e.message) from e @@ -181,7 +185,8 @@ async def revocation_registries_created(request: web.BaseRequest): @docs( - tags=["revocation"], summary="Get revocation registry by revocation registry id", + tags=["revocation"], + summary="Get revocation registry by revocation registry id", ) @match_info_schema(RevRegIdMatchInfoSchema()) @response_schema(RevRegCreateResultSchema(), 200) @@ -271,7 +276,8 @@ async def get_tails_file(request: web.BaseRequest) -> web.FileResponse: @docs( - tags=["revocation"], summary="Publish a given revocation registry", + tags=["revocation"], + summary="Publish a given revocation registry", ) @match_info_schema(RevRegIdMatchInfoSchema()) @response_schema(RevRegCreateResultSchema(), 200) diff --git a/aries_cloudagent/transport/inbound/tests/test_session.py b/aries_cloudagent/transport/inbound/tests/test_session.py index 2463c7a2ae..f049e69709 100644 --- a/aries_cloudagent/transport/inbound/tests/test_session.py +++ b/aries_cloudagent/transport/inbound/tests/test_session.py @@ -103,7 +103,10 @@ async def test_parse_inbound(self): async def test_receive(self): test_ctx = InjectionContext() sess = InboundSession( - context=test_ctx, inbound_handler=None, session_id=None, wire_format=None, + context=test_ctx, + inbound_handler=None, + session_id=None, + wire_format=None, ) test_msg = async_mock.MagicMock() @@ -200,7 +203,10 @@ def test_select_outbound(self): async def test_wait_response(self): test_ctx = InjectionContext() sess = InboundSession( - context=test_ctx, inbound_handler=None, session_id=None, wire_format=None, + context=test_ctx, + inbound_handler=None, + session_id=None, + wire_format=None, ) test_msg = OutboundMessage(payload=None) sess.set_response(test_msg) @@ -223,7 +229,10 @@ async def test_wait_response(self): async def test_wait_response_x(self): test_ctx = InjectionContext() sess = InboundSession( - context=test_ctx, inbound_handler=None, session_id=None, wire_format=None, + context=test_ctx, + inbound_handler=None, + session_id=None, + wire_format=None, ) test_msg = OutboundMessage(payload=None) sess.set_response(test_msg) @@ -267,13 +276,20 @@ async def test_encode_response(self): assert result is test_wire_format.encode_message.return_value test_wire_format.encode_message.assert_awaited_once_with( - test_ctx, test_msg.payload, [test_to_verkey], None, test_from_verkey, + test_ctx, + test_msg.payload, + [test_to_verkey], + None, + test_from_verkey, ) async def test_accept_response(self): test_ctx = InjectionContext() sess = InboundSession( - context=test_ctx, inbound_handler=None, session_id=None, wire_format=None, + context=test_ctx, + inbound_handler=None, + session_id=None, + wire_format=None, ) test_msg = OutboundMessage(payload=None) @@ -295,7 +311,10 @@ async def test_accept_response(self): async def test_context_mgr(self): test_ctx = InjectionContext() sess = InboundSession( - context=test_ctx, inbound_handler=None, session_id=None, wire_format=None, + context=test_ctx, + inbound_handler=None, + session_id=None, + wire_format=None, ) assert not sess.closed async with sess: diff --git a/aries_cloudagent/transport/outbound/tests/test_manager.py b/aries_cloudagent/transport/outbound/tests/test_manager.py index 25c6b2ebac..0b4bd829bb 100644 --- a/aries_cloudagent/transport/outbound/tests/test_manager.py +++ b/aries_cloudagent/transport/outbound/tests/test_manager.py @@ -102,7 +102,10 @@ async def test_send_message(self): mgr.get_running_transport_for_endpoint("localhost") message.target = ConnectionTarget( - endpoint="localhost", recipient_keys=[1, 2], routing_keys=[3], sender_key=4, + endpoint="localhost", + recipient_keys=[1, 2], + routing_keys=[3], + sender_key=4, ) with self.assertRaises(OutboundDeliveryError) as context: mgr.enqueue_message(send_context, message) @@ -173,7 +176,9 @@ async def test_process_done_x(self): async def test_process_finished_x(self): mock_queued = async_mock.MagicMock(retries=1) - mock_task = async_mock.MagicMock(exc_info=(KeyError, KeyError("nope"), None),) + mock_task = async_mock.MagicMock( + exc_info=(KeyError, KeyError("nope"), None), + ) context = InjectionContext() mgr = OutboundTransportManager(context) diff --git a/aries_cloudagent/transport/pack_format.py b/aries_cloudagent/transport/pack_format.py index 8c49fc1e83..272e24f73a 100644 --- a/aries_cloudagent/transport/pack_format.py +++ b/aries_cloudagent/transport/pack_format.py @@ -30,7 +30,9 @@ def __init__(self): self.task_queue: TaskQueue = None async def parse_message( - self, context: InjectionContext, message_body: Union[str, bytes], + self, + context: InjectionContext, + message_body: Union[str, bytes], ) -> Tuple[dict, MessageReceipt]: """ Deserialize an incoming message and further populate the request context. @@ -113,7 +115,11 @@ async def unpack( try: unpacked = await wallet.unpack_message(message_body) - (message_json, receipt.sender_verkey, receipt.recipient_verkey,) = unpacked + ( + message_json, + receipt.sender_verkey, + receipt.recipient_verkey, + ) = unpacked return message_json except WalletError as e: raise MessageParseError("Message unpack failed") from e diff --git a/aries_cloudagent/transport/wire_format.py b/aries_cloudagent/transport/wire_format.py index 8ad93e3df3..2c08eb82dd 100644 --- a/aries_cloudagent/transport/wire_format.py +++ b/aries_cloudagent/transport/wire_format.py @@ -23,7 +23,9 @@ def __init__(self): @abstractmethod async def parse_message( - self, context: InjectionContext, message_body: Union[str, bytes], + self, + context: InjectionContext, + message_body: Union[str, bytes], ) -> Tuple[dict, MessageReceipt]: """ Deserialize an incoming message and further populate the request context. @@ -73,7 +75,9 @@ class JsonWireFormat(BaseWireFormat): @abstractmethod async def parse_message( - self, context: InjectionContext, message_body: Union[str, bytes], + self, + context: InjectionContext, + message_body: Union[str, bytes], ) -> Tuple[dict, MessageReceipt]: """ Deserialize an incoming message and further populate the request context. diff --git a/aries_cloudagent/utils/tests/test_tracing.py b/aries_cloudagent/utils/tests/test_tracing.py index e5ce127a7b..c4d7b8342e 100644 --- a/aries_cloudagent/utils/tests/test_tracing.py +++ b/aries_cloudagent/utils/tests/test_tracing.py @@ -109,7 +109,10 @@ def test_log_event(self): outcome="processed Start", ) test_module.trace_event( - context, ping, perf_counter=ret, outcome="processed OK", + context, + ping, + perf_counter=ret, + outcome="processed OK", ) context["trace.label"] = "trace-label" test_module.trace_event(context, ping) diff --git a/aries_cloudagent/verifier/indy.py b/aries_cloudagent/verifier/indy.py index 2c805ab7d5..1f58971b18 100644 --- a/aries_cloudagent/verifier/indy.py +++ b/aries_cloudagent/verifier/indy.py @@ -36,6 +36,52 @@ def __init__(self, ledger: BaseLedger): """ self.ledger = ledger + def non_revoc_intervals(self, pres_req: dict, pres: dict, pop_global: bool): + """ + Remove superfluous non-revocation intervals in presentation request. + + Indy rejects proof requests with non-revocation intervals lining up + with non-revocable credentials in proof: seek and remove. + + Args: + pres_req: presentation request + pres: corresponding presentation + pop_global: whether to excise global non-revocation interval if present + + """ + + 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(): + if ( + pres["identifiers"][spec["sub_proof_index"]].get("timestamp") + is None + ): + if pres_req[pres_key][uuid].pop("non_revoked", None): + LOGGER.warning( + ( + "Amended presentation request (nonce=%s): removed " + "non-revocation interval at %s referent " + "%s; no corresponding revocable credential in proof" + ), + pres_req["nonce"], + pres_key, + uuid, + ) + + if pop_global: + if pres_req.pop("non_revoked", None): + LOGGER.warning( + ( + "Amended presentation request (nonce=%s); removed global " + "non-revocation interval; no revocable credentials in proof" + ), + pres_req["nonce"], + ) + async def pre_verify(self, pres_req: dict, pres: dict) -> (PreVerifyResult, str): """ Check for essential components and tampering in presentation. @@ -193,20 +239,15 @@ async def verify_presentation( rev_reg_entries: revocation registry entries """ - print("\n-- VERIFIER: VERIFY PRESENTATION") - print(f".. pres req: {json.dumps(presentation_request, indent=4)}") - print(f".. pres: {json.dumps(presentation, indent=4)}") - print(f".. schemas: {json.dumps(schemas, indent=4)}") - print(f".. cred-defs: {json.dumps(credential_definitions, indent=4)}") - print(f".. rev_reg_defs: {json.dumps(rev_reg_defs, indent=4)}") - print(f".. rev_reg_entries: {json.dumps(rev_reg_entries, indent=4)}") + print(f"\n\n## Verifying, input: {json.dumps(presentation)}") + self.non_revoc_intervals(presentation_request, presentation, not rev_reg_defs) + (pv_result, pv_msg) = await self.pre_verify(presentation_request, presentation) if pv_result != PreVerifyResult.OK: LOGGER.error( f"Presentation on nonce={presentation_request['nonce']} " f"cannot be validated: {pv_result.value} [{pv_msg}]" ) - print(f" !! Pre-verification fails") return False try: diff --git a/aries_cloudagent/verifier/tests/test_indy.py b/aries_cloudagent/verifier/tests/test_indy.py index ae9887b83f..0d89e50b7b 100644 --- a/aries_cloudagent/verifier/tests/test_indy.py +++ b/aries_cloudagent/verifier/tests/test_indy.py @@ -315,7 +315,9 @@ async def test_verify_presentation(self, mock_verify): with async_mock.patch.object( self.verifier, "pre_verify", async_mock.CoroutineMock() - ) as mock_pre_verify: + ) as mock_pre_verify, async_mock.patch.object( + self.verifier, "non_revoc_intervals", async_mock.MagicMock() + ) as mock_non_revox: mock_pre_verify.return_value = (PreVerifyResult.OK, None) verified = await self.verifier.verify_presentation( "presentation_request", @@ -343,7 +345,9 @@ async def test_verify_presentation_x_indy(self, mock_verify): with async_mock.patch.object( self.verifier, "pre_verify", async_mock.CoroutineMock() - ) as mock_pre_verify: + ) as mock_pre_verify, async_mock.patch.object( + self.verifier, "non_revoc_intervals", async_mock.MagicMock() + ) as mock_non_revox: mock_pre_verify.return_value = (PreVerifyResult.OK, None) verified = await self.verifier.verify_presentation( {"nonce": "1234567890"}, @@ -365,6 +369,126 @@ async def test_verify_presentation_x_indy(self, mock_verify): assert not verified + @async_mock.patch("indy.anoncreds.verifier_verify_proof") + async def test_non_revoc_intervals(self, mock_verify): + big_pres_req = { + "nonce": "12301197819298309547817", + "name": "proof_req", + "version": "0.0", + "requested_attributes": { + "17_uuid": { + "name": ["favouriteDrink"], + "restrictions": [ + {"cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:17:tag"} + ], + "non_revoked": {"from": 1579892963, "to": 1579892963}, + }, + "18_uuid": { + "names": [ + "effectiveDate", + "jurisdictionId", + "endDate", + "legalName", + "orgTypeId", + ], + "restrictions": [ + {"cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:18:tag"} + ], + "non_revoked": {"from": 1579892963, "to": 1579892963}, + }, + }, + "requested_predicates": { + "18_id_GE_uuid": { + "name": "id", + "p_type": ">=", + "p_value": 4, + "restrictions": [ + {"cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:18:tag"} + ], + "non_revoked": {"from": 1579892963, "to": 1579892963}, + }, + "18_busid_GE_uuid": { + "name": "busId", + "p_type": ">=", + "p_value": 11198760, + "restrictions": [ + {"cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:18:tag"} + ], + "non_revoked": {"from": 1579892963, "to": 1579892963}, + }, + }, + "non_revoked": {"from": 1579892963, "to": 1579892963}, + } + big_pres = { + "proof": { + "proofs": [ + { + "primary_proof": "...", + "non_revoc_proof": "...", + } + ], + "aggregated_proof": "...", + }, + "requested_proof": { + "revealed_attrs": { + "17_uuid": { + "sub_proof_index": 0, + "raw": "martini", + "encoded": "943924110058781320304650334433495169960", + } + }, + "revealed_attr_groups": { + "18_uuid": { + "sub_proof_index": 1, + "values": { + "effectiveDate": { + "raw": "2018-01-01", + "encoded": "200737126045061047957925549204159", + }, + "endDate": { + "raw": "", + "encoded": "10993379397001115665086549", + }, + "jurisdictionId": {"raw": "1", "encoded": "1"}, + "legalName": { + "raw": "Flan Nebula", + "encoded": "119967766011746391966411797095112", + }, + "orgTypeId": {"raw": "2", "encoded": "2"}, + }, + } + }, + "self_attested_attrs": {}, + "unrevealed_attrs": {}, + "predicates": { + "18_busid_GE_uuid": {"sub_proof_index": 1}, + "18_id_GE_uuid": {"sub_proof_index": 1}, + }, + }, + "identifiers": [ + { + "schema_id": "LjgpST2rjsoxYegQDRm7EL:2:bc-reg:1.0", + "cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:17:tag", + "rev_reg_id": None, + "timestamp": None, + }, + { + "schema_id": "LjgpST2rjsoxYegQDRm7EL:2:bc-reg:1.0", + "cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:18:tag", + "rev_reg_id": None, + "timestamp": None, + }, + ], + } + + self.verifier.non_revoc_intervals(big_pres_req, big_pres, True) + + assert "non_revoked" not in big_pres_req + for spec in big_pres_req["requested_attributes"].values(): + assert "non_revoked" not in spec + for spec in big_pres_req["requested_predicates"].values(): + assert "non_revoked" not in spec + async def test_pre_verify(self): assert ( PreVerifyResult.INCOMPLETE @@ -374,216 +498,189 @@ async def test_pre_verify(self): ) )[0] ) - assert ( - PreVerifyResult.INCOMPLETE - == ( - await self.verifier.pre_verify( - {"requested_predicates": "...", "requested_attributes": "..."}, - None, - ) - )[0] - ) - assert ( - PreVerifyResult.INCOMPLETE - == ( - await self.verifier.pre_verify( - {"requested_predicates": "...", "requested_attributes": "..."}, - {"requested_proof": "..."}, - ) - )[0] - ) - assert ( - PreVerifyResult.INCOMPLETE - == ( - await self.verifier.pre_verify( - {"requested_predicates": "...", "requested_attributes": "..."}, - {"proof": "..."}, - ) - )[0] - ) - assert ( - PreVerifyResult.INCOMPLETE - == ( - await self.verifier.pre_verify( - { - "requested_predicates": {"0_name_uuid": "..."}, - "requested_attributes": "...", + assert PreVerifyResult.INCOMPLETE == ( + await self.verifier.pre_verify( + {"requested_predicates": "...", "requested_attributes": "..."}, + None, + ) + )[0] + assert PreVerifyResult.INCOMPLETE == ( + await self.verifier.pre_verify( + {"requested_predicates": "...", "requested_attributes": "..."}, + {"requested_proof": "..."}, + ) + )[0] + assert PreVerifyResult.INCOMPLETE == ( + await self.verifier.pre_verify( + {"requested_predicates": "...", "requested_attributes": "..."}, + {"proof": "..."}, + ) + )[0] + assert PreVerifyResult.INCOMPLETE == ( + await self.verifier.pre_verify( + { + "requested_predicates": {"0_name_uuid": "..."}, + "requested_attributes": "...", + }, + INDY_PROOF_PRED_NAMES, + ) + )[0] + assert PreVerifyResult.INCOMPLETE == ( + await self.verifier.pre_verify( + INDY_PROOF_REQ_NAME, + { + "proof": "...", + "requested_proof": { + "revealed_attrs": {}, + "self_attested_attrs": {"19_uuid": "Chicken Hawk"}, + "unrevealed_attrs": {}, + "predicates": {}, }, - INDY_PROOF_PRED_NAMES, - ) - )[0] - ) - assert ( - PreVerifyResult.INCOMPLETE - == ( - await self.verifier.pre_verify( - INDY_PROOF_REQ_NAME, - { - "proof": "...", - "requested_proof": { - "revealed_attrs": {}, - "self_attested_attrs": {"19_uuid": "Chicken Hawk"}, - "unrevealed_attrs": {}, - "predicates": {}, - }, - "identifiers": [ - { - "schema_id": "LjgpST2rjsoxYegQDRm7EL:2:non-revo:1579888926.0", - "cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:19:tag", - "rev_reg_id": "LjgpST2rjsoxYegQDRm7EL:4:LjgpST2rjsoxYegQDRm7EL:3:CL:18:tag:CL_ACCUM:0", - "timestamp": 1579892963, - } - ], + "identifiers": [ + { + "schema_id": "LjgpST2rjsoxYegQDRm7EL:2:non-revo:1579888926.0", + "cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:19:tag", + "rev_reg_id": "LjgpST2rjsoxYegQDRm7EL:4:LjgpST2rjsoxYegQDRm7EL:3:CL:18:tag:CL_ACCUM:0", + "timestamp": 1579892963, + } + ], + }, + ) + )[0] + assert PreVerifyResult.INCOMPLETE == ( + await self.verifier.pre_verify( + { + "nonce": "15606741555044336341559", + "name": "proof_req", + "version": "0.0", + "requested_attributes": {"19_uuid": {"name": "Preferred Name"}}, + "requested_predicates": {}, + }, + { + "proof": "...", + "requested_proof": { + "revealed_attrs": {}, + "self_attested_attrs": {}, + "unrevealed_attrs": {}, + "predicates": {}, }, - ) - )[0] - ) - assert ( - PreVerifyResult.INCOMPLETE - == ( - await self.verifier.pre_verify( - { - "nonce": "15606741555044336341559", - "name": "proof_req", - "version": "0.0", - "requested_attributes": {"19_uuid": {"name": "Preferred Name"}}, - "requested_predicates": {}, + "identifiers": [ + { + "schema_id": "LjgpST2rjsoxYegQDRm7EL:2:non-revo:1579888926.0", + "cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:19:tag", + "rev_reg_id": "LjgpST2rjsoxYegQDRm7EL:4:LjgpST2rjsoxYegQDRm7EL:3:CL:18:tag:CL_ACCUM:0", + "timestamp": 1579892963, + } + ], + }, + ) + )[0] + assert PreVerifyResult.INCOMPLETE == ( + await self.verifier.pre_verify( + { + "nonce": "15606741555044336341559", + "name": "proof_req", + "version": "0.0", + "requested_attributes": { + "19_uuid": {"neither-name-nor-names": "Preferred Name"} }, - { - "proof": "...", - "requested_proof": { - "revealed_attrs": {}, - "self_attested_attrs": {}, - "unrevealed_attrs": {}, - "predicates": {}, - }, - "identifiers": [ - { - "schema_id": "LjgpST2rjsoxYegQDRm7EL:2:non-revo:1579888926.0", - "cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:19:tag", - "rev_reg_id": "LjgpST2rjsoxYegQDRm7EL:4:LjgpST2rjsoxYegQDRm7EL:3:CL:18:tag:CL_ACCUM:0", - "timestamp": 1579892963, + "requested_predicates": {}, + }, + { + "proof": "...", + "requested_proof": { + "revealed_attrs": { + "19_uuid": { + "sub_proof_index": 0, + "raw": "Chicken Hawk", + "encoded": "94607763023542937648705576709896212619553924110058781320304650334433495169960", } - ], - }, - ) - )[0] - ) - assert ( - PreVerifyResult.INCOMPLETE - == ( - await self.verifier.pre_verify( - { - "nonce": "15606741555044336341559", - "name": "proof_req", - "version": "0.0", - "requested_attributes": { - "19_uuid": {"neither-name-nor-names": "Preferred Name"} }, - "requested_predicates": {}, + "self_attested_attrs": {}, + "unrevealed_attrs": {}, + "predicates": {}, }, - { - "proof": "...", - "requested_proof": { - "revealed_attrs": { - "19_uuid": { - "sub_proof_index": 0, - "raw": "Chicken Hawk", - "encoded": "94607763023542937648705576709896212619553924110058781320304650334433495169960", - } - }, - "self_attested_attrs": {}, - "unrevealed_attrs": {}, - "predicates": {}, - }, - "identifiers": [ + "identifiers": [ + { + "schema_id": "LjgpST2rjsoxYegQDRm7EL:2:non-revo:1579888926.0", + "cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:19:tag", + "rev_reg_id": "LjgpST2rjsoxYegQDRm7EL:4:LjgpST2rjsoxYegQDRm7EL:3:CL:18:tag:CL_ACCUM:0", + "timestamp": 1579892963, + } + ], + }, + ) + )[0] + assert PreVerifyResult.INCOMPLETE == ( + await self.verifier.pre_verify( + INDY_PROOF_REQ_NAME, + { + "proof": { + "proofs": [ { - "schema_id": "LjgpST2rjsoxYegQDRm7EL:2:non-revo:1579888926.0", - "cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:19:tag", - "rev_reg_id": "LjgpST2rjsoxYegQDRm7EL:4:LjgpST2rjsoxYegQDRm7EL:3:CL:18:tag:CL_ACCUM:0", - "timestamp": 1579892963, - } - ], - }, - ) - )[0] - ) - assert ( - PreVerifyResult.INCOMPLETE - == ( - await self.verifier.pre_verify( - INDY_PROOF_REQ_NAME, - { - "proof": { - "proofs": [ - { - "primary_proof": { - "eq_proof": { - "revealed_attrs": {"otherthing": "..."}, - "...": "...", - }, - "ge_proofs": [], + "primary_proof": { + "eq_proof": { + "revealed_attrs": {"otherthing": "..."}, + "...": "...", }, - "...": "...", - } - ], - "...": "...", - }, - "requested_proof": { - "revealed_attrs": { - "19_uuid": { - "sub_proof_index": 0, - "raw": "Chicken Hawk", - "encoded": "94607763023542937648705576709896212619553924110058781320304650334433495169960", - } - }, - "self_attested_attrs": {}, - "unrevealed_attrs": {}, - "predicates": {}, - }, - "identifiers": [ - { - "schema_id": "LjgpST2rjsoxYegQDRm7EL:2:non-revo:1579888926.0", - "cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:19:tag", - "rev_reg_id": "LjgpST2rjsoxYegQDRm7EL:4:LjgpST2rjsoxYegQDRm7EL:3:CL:18:tag:CL_ACCUM:0", - "timestamp": 1579892963, + "ge_proofs": [], + }, + "...": "...", } ], + "...": "...", }, - ) - )[0] - ) - assert ( - PreVerifyResult.OK - == ( - await self.verifier.pre_verify( - { - "nonce": "15606741555044336341559", - "name": "proof_req", - "version": "0.0", - "requested_attributes": {"19_uuid": {"name": "Preferred Name"}}, - "requested_predicates": {}, - }, - { - "proof": "...", - "requested_proof": { - "revealed_attrs": {}, - "self_attested_attrs": {"19_uuid": "Chicken Hawk"}, - "unrevealed_attrs": {}, - "predicates": {}, - }, - "identifiers": [ - { - "schema_id": "LjgpST2rjsoxYegQDRm7EL:2:non-revo:1579888926.0", - "cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:19:tag", - "rev_reg_id": "LjgpST2rjsoxYegQDRm7EL:4:LjgpST2rjsoxYegQDRm7EL:3:CL:18:tag:CL_ACCUM:0", - "timestamp": 1579892963, + "requested_proof": { + "revealed_attrs": { + "19_uuid": { + "sub_proof_index": 0, + "raw": "Chicken Hawk", + "encoded": "94607763023542937648705576709896212619553924110058781320304650334433495169960", } - ], + }, + "self_attested_attrs": {}, + "unrevealed_attrs": {}, + "predicates": {}, }, - ) - )[0] - ) + "identifiers": [ + { + "schema_id": "LjgpST2rjsoxYegQDRm7EL:2:non-revo:1579888926.0", + "cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:19:tag", + "rev_reg_id": "LjgpST2rjsoxYegQDRm7EL:4:LjgpST2rjsoxYegQDRm7EL:3:CL:18:tag:CL_ACCUM:0", + "timestamp": 1579892963, + } + ], + }, + ) + )[0] + assert PreVerifyResult.OK == ( + await self.verifier.pre_verify( + { + "nonce": "15606741555044336341559", + "name": "proof_req", + "version": "0.0", + "requested_attributes": {"19_uuid": {"name": "Preferred Name"}}, + "requested_predicates": {}, + }, + { + "proof": "...", + "requested_proof": { + "revealed_attrs": {}, + "self_attested_attrs": {"19_uuid": "Chicken Hawk"}, + "unrevealed_attrs": {}, + "predicates": {}, + }, + "identifiers": [ + { + "schema_id": "LjgpST2rjsoxYegQDRm7EL:2:non-revo:1579888926.0", + "cred_def_id": "LjgpST2rjsoxYegQDRm7EL:3:CL:19:tag", + "rev_reg_id": "LjgpST2rjsoxYegQDRm7EL:4:LjgpST2rjsoxYegQDRm7EL:3:CL:18:tag:CL_ACCUM:0", + "timestamp": 1579892963, + } + ], + }, + ) + )[0] @async_mock.patch("indy.anoncreds.verifier_verify_proof") async def test_check_encoding_attr(self, mock_verify): diff --git a/aries_cloudagent/wallet/routes.py b/aries_cloudagent/wallet/routes.py index 19bd1b8a5b..5665e92c73 100644 --- a/aries_cloudagent/wallet/routes.py +++ b/aries_cloudagent/wallet/routes.py @@ -112,7 +112,8 @@ def format_did_info(info: DIDInfo): @docs( - tags=["wallet"], summary="List wallet DIDs", + tags=["wallet"], + summary="List wallet DIDs", ) @querystring_schema(DIDListQueryStringSchema()) @response_schema(DIDListSchema, 200) diff --git a/aries_cloudagent/wallet/tests/test_indy_wallet.py b/aries_cloudagent/wallet/tests/test_indy_wallet.py index a8a7790ee9..3ebd16c6c6 100644 --- a/aries_cloudagent/wallet/tests/test_indy_wallet.py +++ b/aries_cloudagent/wallet/tests/test_indy_wallet.py @@ -177,7 +177,10 @@ async def test_pack_message_x(self, wallet): ) with pytest.raises(test_module.WalletError) as excinfo: await wallet.pack_message( - b"hello world", [self.test_verkey,], + b"hello world", + [ + self.test_verkey, + ], ) assert "outlier" in str(excinfo.value) diff --git a/aries_cloudagent/wallet/tests/test_provider.py b/aries_cloudagent/wallet/tests/test_provider.py index 850e916637..a3d0184ed3 100644 --- a/aries_cloudagent/wallet/tests/test_provider.py +++ b/aries_cloudagent/wallet/tests/test_provider.py @@ -29,7 +29,11 @@ async def test_provide_basic(self): async def test_provide_indy(self): provider = test_module.WalletProvider() settings = Settings( - values={"wallet.type": "indy", "wallet.key": "key", "wallet.name": "name",} + values={ + "wallet.type": "indy", + "wallet.key": "key", + "wallet.name": "name", + } ) wallet = await provider.provide(settings, None) diff --git a/demo/runners/faber.py b/demo/runners/faber.py index 9a3e1bd558..b4907380e7 100644 --- a/demo/runners/faber.py +++ b/demo/runners/faber.py @@ -84,7 +84,8 @@ async def handle_issue_credential(self, message): self.log( "Credential: state = {}, credential_exchange_id = {}".format( - state, credential_exchange_id, + state, + credential_exchange_id, ) ) @@ -296,7 +297,9 @@ async def main( ) if SELF_ATTESTED: # test self-attested claims - req_attrs.append({"name": "self_attested_thing"},) + req_attrs.append( + {"name": "self_attested_thing"}, + ) req_preds = [ # test zero-knowledge proofs { diff --git a/demo/runners/support/agent.py b/demo/runners/support/agent.py index 41586fb6e0..f52db65a42 100644 --- a/demo/runners/support/agent.py +++ b/demo/runners/support/agent.py @@ -452,7 +452,9 @@ async def admin_GET(self, path, text=False, params=None) -> ClientResponse: EVENT_LOGGER.debug("Controller GET %s request to Agent", path) response = await self.admin_request("GET", path, None, text, params) EVENT_LOGGER.debug( - "Response from GET %s received: \n%s", path, repr_json(response), + "Response from GET %s received: \n%s", + path, + repr_json(response), ) return response except ClientError as e: @@ -470,7 +472,9 @@ async def admin_POST( ) response = await self.admin_request("POST", path, data, text, params) EVENT_LOGGER.debug( - "Response from POST %s received: \n%s", path, repr_json(response), + "Response from POST %s received: \n%s", + path, + repr_json(response), ) return response except ClientError as e: