Skip to content

Commit

Permalink
Merge branch 'main' into bugfix/base-wallet-routes-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
jamshale authored Jan 16, 2025
2 parents a093992 + 315537c commit 3391793
Show file tree
Hide file tree
Showing 46 changed files with 89 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ jobs:
- name: Ruff Format and Lint Check
uses: chartboost/ruff-action@v1
with:
version: 0.8.0
version: 0.9.1
args: "format --check"
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
additional_dependencies: ['@commitlint/config-conventional']
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ensure this is synced with pyproject.toml
rev: v0.8.1
rev: v0.9.1
hooks:
# Run the linter
- id: ruff
Expand Down
2 changes: 1 addition & 1 deletion acapy_agent/anoncreds/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async def create_and_register_schema(
)
if schemas:
raise AnonCredsSchemaAlreadyExists(
f"Schema with {name}: {version} " f"already exists for {issuer_id}",
f"Schema with {name}: {version} already exists for {issuer_id}",
schemas[0].name,
AnonCredsSchema.deserialize(schemas[0].value_json),
)
Expand Down
3 changes: 1 addition & 2 deletions acapy_agent/anoncreds/revocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ async def set_active_registry(self, rev_reg_def_id: str):
)
if not entry:
raise AnonCredsRevocationError(
f"{CATEGORY_REV_REG_DEF} with id "
f"{rev_reg_def_id} could not be found"
f"{CATEGORY_REV_REG_DEF} with id {rev_reg_def_id} could not be found"
)

if entry.tags["active"] == json.dumps(True):
Expand Down
13 changes: 4 additions & 9 deletions acapy_agent/anoncreds/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ async def check_timestamps(
)
elif uuid in unrevealed_attrs:
# nothing to do, attribute value is not revealed
msgs.append(
f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::" f"{uuid}"
)
msgs.append(f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::{uuid}")
elif uuid not in self_attested:
raise ValueError(
f"Presentation attributes mismatch requested attribute {uuid}"
Expand Down Expand Up @@ -236,8 +234,7 @@ async def check_timestamps(
< non_revoc_intervals[uuid].get("to", now)
):
msgs.append(
f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::"
f"{uuid}"
f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::{uuid}"
)
LOGGER.warning(
f"Timestamp {timestamp} from ledger for item"
Expand Down Expand Up @@ -266,7 +263,7 @@ async def check_timestamps(
< non_revoc_intervals[uuid].get("to", now)
):
msgs.append(
f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::" f"{uuid}"
f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::{uuid}"
)
LOGGER.warning(
f"Best-effort timestamp {timestamp} "
Expand Down Expand Up @@ -333,9 +330,7 @@ async def pre_verify(self, pres_req: dict, pres: dict) -> list:
elif uuid in unrevealed_attrs:
# unrevealed attribute, nothing to do
pres_req_attr_spec = {}
msgs.append(
f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::" f"{uuid}"
)
msgs.append(f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::{uuid}")
elif uuid in self_attested:
if not req_attr.get("restrictions"):
continue
Expand Down
14 changes: 5 additions & 9 deletions acapy_agent/config/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,24 +269,22 @@ def add_arguments(self, parser: ArgumentParser):
action="store_true",
env_var="ACAPY_DEBUG_CREDENTIALS",
help=(
"Enable additional logging around credential exchanges. "
"Default: false."
"Enable additional logging around credential exchanges. Default: false."
),
)
parser.add_argument(
"--debug-presentations",
action="store_true",
env_var="ACAPY_DEBUG_PRESENTATIONS",
help=(
"Enable additional logging around presentation exchanges. "
"Default: false."
"Enable additional logging around presentation exchanges. Default: false."
),
)
parser.add_argument(
"--debug-webhooks",
action="store_true",
env_var="ACAPY_DEBUG_WEBHOOKS",
help=("Emit protocol state object as webhook. " "Default: false."),
help=("Emit protocol state object as webhook. Default: false."),
)
parser.add_argument(
"--invite",
Expand Down Expand Up @@ -416,17 +414,15 @@ def add_arguments(self, parser: ArgumentParser):
action="store_true",
env_var="ACAPY_AUTO_STORE_CREDENTIAL",
help=(
"Automatically store an issued credential upon receipt. "
"Default: false."
"Automatically store an issued credential upon receipt. Default: false."
),
)
parser.add_argument(
"--auto-verify-presentation",
action="store_true",
env_var="ACAPY_AUTO_VERIFY_PRESENTATION",
help=(
"Automatically verify a presentation when it is received. "
"Default: false."
"Automatically verify a presentation when it is received. Default: false."
),
)

Expand Down
2 changes: 1 addition & 1 deletion acapy_agent/config/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ async def select_aml_tty(taa_info, provision: bool = False) -> Optional[str]:
num_mechanisms = {}
for idx, opt in enumerate(found):
num_mechanisms[str(idx + 1)] = opt
opts.append(f" {idx+1}. {allow_opts[opt]}")
opts.append(f" {idx + 1}. {allow_opts[opt]}")
opts.append(" X. Skip the transaction author agreement")
opts_text = "\nPlease select an option:\n" + "\n".join(opts) + "\n[1]> "

Expand Down
3 changes: 1 addition & 2 deletions acapy_agent/connections/base_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,8 +1026,7 @@ async def resolve_inbound_connection(
receipt.recipient_did_public = True
except InjectionError:
self._logger.warning(
"Cannot resolve recipient verkey, no wallet defined by "
"context: %s",
"Cannot resolve recipient verkey, no wallet defined by context: %s",
receipt.recipient_verkey,
)
except WalletNotFoundError:
Expand Down
10 changes: 5 additions & 5 deletions acapy_agent/indy/models/tests/test_pres_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@
"name": "player",
"restrictions": [
{{
"cred_def_id": "{CD_ID['score']}"
"cred_def_id": "{CD_ID["score"]}"
}}
]
}},
"1_screencapture_uuid": {{
"name": "screenCapture",
"restrictions": [
{{
"cred_def_id": "{CD_ID['score']}"
"cred_def_id": "{CD_ID["score"]}"
}}
]
}}
Expand All @@ -108,7 +108,7 @@
"p_value": 1000000,
"restrictions": [
{{
"cred_def_id": "{CD_ID['score']}"
"cred_def_id": "{CD_ID["score"]}"
}}
]
}}
Expand All @@ -125,15 +125,15 @@
"names": ["player", "screenCapture"],
"restrictions": [
{{
"cred_def_id": "{CD_ID['score']}"
"cred_def_id": "{CD_ID["score"]}"
}}
]
}},
"1_member_uuid": {{
"names": ["member", "since"],
"restrictions": [
{{
"cred_def_id": "{CD_ID['membership']}"
"cred_def_id": "{CD_ID["membership"]}"
}}
]
}}
Expand Down
13 changes: 4 additions & 9 deletions acapy_agent/indy/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,7 @@ async def check_timestamps(
)
elif uuid in unrevealed_attrs:
# nothing to do, attribute value is not revealed
msgs.append(
f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::" f"{uuid}"
)
msgs.append(f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::{uuid}")
elif uuid not in self_attested:
raise ValueError(
f"Presentation attributes mismatch requested attribute {uuid}"
Expand Down Expand Up @@ -242,8 +240,7 @@ async def check_timestamps(
< non_revoc_intervals[uuid].get("to", now)
):
msgs.append(
f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::"
f"{uuid}"
f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::{uuid}"
)
LOGGER.warning(
f"Timestamp {timestamp} from ledger for item"
Expand Down Expand Up @@ -272,7 +269,7 @@ async def check_timestamps(
< non_revoc_intervals[uuid].get("to", now)
):
msgs.append(
f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::" f"{uuid}"
f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::{uuid}"
)
LOGGER.warning(
f"Best-effort timestamp {timestamp} "
Expand Down Expand Up @@ -339,9 +336,7 @@ async def pre_verify(self, pres_req: dict, pres: dict) -> list:
elif uuid in unrevealed_attrs:
# unrevealed attribute, nothing to do
pres_req_attr_spec = {}
msgs.append(
f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::" f"{uuid}"
)
msgs.append(f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::{uuid}")
elif uuid in self_attested:
if not req_attr.get("restrictions"):
continue
Expand Down
3 changes: 1 addition & 2 deletions acapy_agent/ledger/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,7 @@ async def send_schema_anoncreds(
)
if schema_info:
LOGGER.warning(
"Schema already exists on ledger. Returning details."
" Error: %s",
"Schema already exists on ledger. Returning details. Error: %s",
e,
)
raise LedgerObjectAlreadyExistsError(
Expand Down
4 changes: 2 additions & 2 deletions acapy_agent/messaging/decorators/signature_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def __str__(self):
"""Get a string representation of this class."""
return (
f"{self.__class__.__name__}"
+ f"(signature_type='{self.signature_type,}', "
+ f"signature='{self.signature,}', "
+ f"(signature_type='{(self.signature_type,)}', "
+ f"signature='{(self.signature,)}', "
+ f"sig_data='{self.sig_data}', signer='{self.signer}')"
)

Expand Down
2 changes: 1 addition & 1 deletion acapy_agent/messaging/jsonld/create_verify_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def create_verify_data(data, signature_options, document_loader=None):
)
dropped = set(data.keys()) - set(for_diff.keys())
raise DroppedAttributeError(
f"{dropped} attributes dropped. " "Provide definitions in context to correct."
f"{dropped} attributes dropped. Provide definitions in context to correct."
)
# Check proof for dropped attributes
attr = [
Expand Down
6 changes: 3 additions & 3 deletions acapy_agent/messaging/jsonld/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"issuer": ("did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"),
"issuanceDate": "2020-03-10T04:24:12.164Z",
"credentialSubject": {
"id": ("did:key:" "z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"),
"id": ("did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"),
"degree": {
"type": "BachelorDegree",
"name": "Bachelor of Science and Arts",
Expand Down Expand Up @@ -244,7 +244,7 @@
"issuer": ("did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"),
"issuanceDate": "2020-03-10T04:24:12.164Z",
"credentialSubject": {
"id": ("did:key:" "z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"),
"id": ("did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"),
"degree": {
"type": "BachelorDegree",
"name": "Bachelor of Science and Arts",
Expand Down Expand Up @@ -365,7 +365,7 @@
"issuer": ("did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"),
"issuanceDate": "2020-03-10T04:24:12.164Z",
"credentialSubject": {
"id": ("did:key:" "z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"),
"id": ("did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"),
"degree": {
"type": "BachelorDegree",
"name": "Bachelor of Science and Arts",
Expand Down
6 changes: 2 additions & 4 deletions acapy_agent/messaging/valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ class JSONWebToken(Regexp):
"""Validate JSON Web Token."""

EXAMPLE = (
"eyJhbGciOiJFZERTQSJ9."
"eyJhIjogIjAifQ."
"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
"eyJhbGciOiJFZERTQSJ9.eyJhIjogIjAifQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
)
PATTERN = r"^[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]+$"

Expand Down Expand Up @@ -926,7 +924,7 @@ def __call__(self, value):
uri_validator(subject["id"])
except ValidationError:
raise ValidationError(
f'credential subject id {subject["id"]} must be URI'
f"credential subject id {subject['id']} must be URI"
) from None

return value
Expand Down
6 changes: 2 additions & 4 deletions acapy_agent/multitenant/admin/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,7 @@ class RemoveWalletRequestSchema(OpenAPISchema):
wallet_key = fields.Str(
metadata={
"description": (
"Master key used for key derivation. Only required for"
" unmanaged wallets."
"Master key used for key derivation. Only required for unmanaged wallets."
),
"example": "MySecretKey123",
}
Expand All @@ -328,8 +327,7 @@ class CreateWalletTokenRequestSchema(OpenAPISchema):
wallet_key = fields.Str(
metadata={
"description": (
"Master key used for key derivation. Only required for"
" unmanaged wallets."
"Master key used for key derivation. Only required for unmanaged wallets."
),
"example": "MySecretKey123",
}
Expand Down
2 changes: 1 addition & 1 deletion acapy_agent/protocols/connections/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ async def receive_request(
if not connection:
if not self.profile.settings.get("requests_through_public_did"):
raise ConnectionManagerError(
"Unsolicited connection requests to " "public DID is not enabled"
"Unsolicited connection requests to public DID is not enabled"
)
connection = ConnRecord()
connection.invitation_key = connection_key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from ..models.connection_detail import ConnectionDetail, ConnectionDetailSchema

HANDLER_CLASS = (
f"{PROTOCOL_PACKAGE}.handlers."
"connection_response_handler.ConnectionResponseHandler"
f"{PROTOCOL_PACKAGE}.handlers.connection_response_handler.ConnectionResponseHandler"
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
KEYLIST_QUERY: f"{PROTOCOL_PACKAGE}.messages.keylist_query.KeylistQuery",
KEYLIST_UPDATE: f"{PROTOCOL_PACKAGE}.messages.keylist_update.KeylistUpdate",
KEYLIST_UPDATE_RESPONSE: (
f"{PROTOCOL_PACKAGE}."
"messages.keylist_update_response.KeylistUpdateResponse"
f"{PROTOCOL_PACKAGE}.messages.keylist_update_response.KeylistUpdateResponse"
),
MEDIATE_DENY: f"{PROTOCOL_PACKAGE}.messages.mediate_deny.MediationDeny",
MEDIATE_GRANT: f"{PROTOCOL_PACKAGE}.messages.mediate_grant.MediationGrant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ..message_types import PROBLEM_REPORT, PROTOCOL_PACKAGE

HANDLER_CLASS = (
f"{PROTOCOL_PACKAGE}.handlers" ".problem_report_handler.CMProblemReportHandler"
f"{PROTOCOL_PACKAGE}.handlers.problem_report_handler.CMProblemReportHandler"
)

LOGGER = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ def test_type(self):
assert self.request._type == DIDCommPrefix.qualify_current(DIDX_REQUEST)

@mock.patch(
"acapy_agent.protocols.didexchange.v1_0.messages."
"request.DIDXRequestSchema.load"
"acapy_agent.protocols.didexchange.v1_0.messages.request.DIDXRequestSchema.load"
)
def test_deserialize(self, mock_request_schema_load):
"""
Expand All @@ -97,8 +96,7 @@ def test_deserialize(self, mock_request_schema_load):
assert request is mock_request_schema_load.return_value

@mock.patch(
"acapy_agent.protocols.didexchange.v1_0.messages."
"request.DIDXRequestSchema.dump"
"acapy_agent.protocols.didexchange.v1_0.messages.request.DIDXRequestSchema.dump"
)
def test_serialize(self, mock_request_schema_dump):
"""
Expand Down
Loading

0 comments on commit 3391793

Please sign in to comment.