Skip to content

Commit

Permalink
Merge pull request #2756 from ff137/fix-deprecation-warnings
Browse files Browse the repository at this point in the history
Fix deprecation warnings
  • Loading branch information
swcurran committed Feb 18, 2024
2 parents 27bce43 + 8822abb commit 75e35c1
Show file tree
Hide file tree
Showing 21 changed files with 363 additions and 263 deletions.
10 changes: 8 additions & 2 deletions aries_cloudagent/admin/tests/test_admin_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
from ..server import AdminServer, AdminSetupError


# Ignore Marshmallow warning, as well as 'NotAppKeyWarning' coming from apispec packages
@pytest.mark.filterwarnings(
"ignore:The 'missing' attribute of fields is deprecated. Use 'load_default' instead.",
"ignore:It is recommended to use web.AppKey instances for keys.",
)
class TestAdminServer(IsolatedAsyncioTestCase):
async def asyncSetUp(self):
self.message_results = []
Expand Down Expand Up @@ -507,5 +512,6 @@ def _smaller_scope():
with pytest.raises(RuntimeError):
await responder.send_outbound(None)

with pytest.raises(RuntimeError):
await responder.send_webhook("test", {})
with pytest.deprecated_call():
with pytest.raises(RuntimeError):
await responder.send_webhook("test", {})
6 changes: 3 additions & 3 deletions aries_cloudagent/anoncreds/default/legacy_indy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,8 @@ async def _revoc_reg_entry_with_fix(
# Ledger rejected transaction request: client request invalid:
# InvalidClientRequest(...)
# In this scenario we try to post a correction
LOGGER.warn("Retry ledger update/fix due to error")
LOGGER.warn(err)
LOGGER.warning("Retry ledger update/fix due to error")
LOGGER.warning(err)
(_, _, rev_entry_res) = await self.fix_ledger_entry(
profile,
rev_list,
Expand All @@ -806,7 +806,7 @@ async def _revoc_reg_entry_with_fix(
write_ledger,
endorser_did,
)
LOGGER.warn("Ledger update/fix applied")
LOGGER.warning("Ledger update/fix applied")
elif "InvalidClientTaaAcceptanceError" in err.roll_up:
# if no write access (with "InvalidClientTaaAcceptanceError")
# e.g. aries_cloudagent.ledger.error.LedgerTransactionError:
Expand Down
75 changes: 49 additions & 26 deletions aries_cloudagent/anoncreds/models/anoncreds_cred_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
NUM_STR_WHOLE_VALIDATE,
)

NUM_STR_WHOLE = {"validate": NUM_STR_WHOLE_VALIDATE, "example": NUM_STR_WHOLE_EXAMPLE}
NUM_STR_WHOLE = {
"validate": NUM_STR_WHOLE_VALIDATE,
"metadata": {"example": NUM_STR_WHOLE_EXAMPLE},
}


class CredDefValuePrimary(BaseModel):
Expand Down Expand Up @@ -126,17 +129,27 @@ class Meta:
model_class = CredDefValueRevocation
unknown = EXCLUDE

g = fields.Str(example="1 1F14F&ECB578F 2 095E45DDF417D")
g_dash = fields.Str(example="1 1D64716fCDC00C 1 0C781960FA66E3D3 2 095E45DDF417D")
h = fields.Str(example="1 16675DAE54BFAE8 2 095E45DD417D")
h0 = fields.Str(example="1 21E5EF9476EAF18 2 095E45DDF417D")
h1 = fields.Str(example="1 236D1D99236090 2 095E45DDF417D")
h2 = fields.Str(example="1 1C3AE8D1F1E277 2 095E45DDF417D")
htilde = fields.Str(example="1 1D8549E8C0F8 2 095E45DDF417D")
h_cap = fields.Str(example="1 1B2A32CF3167 1 2490FEBF6EE55 1 0000000000000000")
u = fields.Str(example="1 0C430AAB2B4710 1 1CB3A0932EE7E 1 0000000000000000")
pk = fields.Str(example="1 142CD5E5A7DC 1 153885BD903312 2 095E45DDF417D")
y = fields.Str(example="1 153558BD903312 2 095E45DDF417D 1 0000000000000000")
g = fields.Str(metadata={"example": "1 1F14F&ECB578F 2 095E45DDF417D"})
g_dash = fields.Str(
metadata={"example": "1 1D64716fCDC00C 1 0C781960FA66E3D3 2 095E45DDF417D"}
)
h = fields.Str(metadata={"example": "1 16675DAE54BFAE8 2 095E45DD417D"})
h0 = fields.Str(metadata={"example": "1 21E5EF9476EAF18 2 095E45DDF417D"})
h1 = fields.Str(metadata={"example": "1 236D1D99236090 2 095E45DDF417D"})
h2 = fields.Str(metadata={"example": "1 1C3AE8D1F1E277 2 095E45DDF417D"})
htilde = fields.Str(metadata={"example": "1 1D8549E8C0F8 2 095E45DDF417D"})
h_cap = fields.Str(
metadata={"example": "1 1B2A32CF3167 1 2490FEBF6EE55 1 0000000000000000"}
)
u = fields.Str(
metadata={"example": "1 0C430AAB2B4710 1 1CB3A0932EE7E 1 0000000000000000"}
)
pk = fields.Str(
metadata={"example": "1 142CD5E5A7DC 1 153885BD903312 2 095E45DDF417D"}
)
y = fields.Str(
metadata={"example": "1 153558BD903312 2 095E45DDF417D 1 0000000000000000"}
)


class CredDefValue(BaseModel):
Expand Down Expand Up @@ -178,11 +191,11 @@ class Meta:

primary = fields.Nested(
CredDefValuePrimarySchema(),
description="Primary value for credential definition",
metadata={"description": "Primary value for credential definition"},
)
revocation = fields.Nested(
CredDefValueRevocationSchema(),
description="Revocation value for credential definition",
metadata={"description": "Revocation value for credential definition"},
required=False,
)

Expand Down Expand Up @@ -243,20 +256,26 @@ class Meta:
unknown = EXCLUDE

issuer_id = fields.Str(
description="Issuer Identifier of the credential definition or schema",
metadata={
"description": "Issuer Identifier of the credential definition or schema",
"example": INDY_OR_KEY_DID_EXAMPLE,
},
data_key="issuerId",
example=INDY_OR_KEY_DID_EXAMPLE,
)
schema_id = fields.Str(
data_key="schemaId",
description="Schema identifier",
example=INDY_SCHEMA_ID_EXAMPLE,
metadata={
"description": "Schema identifier",
"example": INDY_SCHEMA_ID_EXAMPLE,
},
)
type = fields.Str(validate=OneOf(["CL"]))
tag = fields.Str(
description="""The tag value passed in by the Issuer to
metadata={
"description": """The tag value passed in by the Issuer to
an AnonCred's Credential Definition create and store implementation.""",
example="default",
"example": "default",
}
)
value = fields.Nested(CredDefValueSchema())

Expand Down Expand Up @@ -315,12 +334,14 @@ class Meta:
)
)
credential_definition_id = fields.Str(
description="credential definition id",
metadata={
"description": "credential definition id",
"example": INDY_CRED_DEF_ID_EXAMPLE,
},
allow_none=True,
example=INDY_CRED_DEF_ID_EXAMPLE,
)
credential_definition = fields.Nested(
CredDefSchema(), description="credential definition"
CredDefSchema(), metadata={"description": "credential definition"}
)


Expand Down Expand Up @@ -418,11 +439,13 @@ class Meta:
unknown = EXCLUDE

credential_definition_id = fields.Str(
description="credential definition id",
example=INDY_CRED_DEF_ID_EXAMPLE,
metadata={
"description": "credential definition id",
"example": INDY_CRED_DEF_ID_EXAMPLE,
},
)
credential_definition = fields.Nested(
CredDefSchema(), description="credential definition"
CredDefSchema(), metadata={"description": "credential definition"}
)
resolution_metadata = fields.Dict()
credential_definitions_metadata = fields.Dict()
70 changes: 47 additions & 23 deletions aries_cloudagent/anoncreds/models/anoncreds_revocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,18 @@ class Meta:
unknown = EXCLUDE

public_keys = fields.Dict(
data_key="publicKeys", example=INDY_RAW_PUBLIC_KEY_EXAMPLE
data_key="publicKeys", metadata={"example": INDY_RAW_PUBLIC_KEY_EXAMPLE}
)
max_cred_num = fields.Int(data_key="maxCredNum", example=666)
max_cred_num = fields.Int(data_key="maxCredNum", metadata={"example": 777})
tails_location = fields.Str(
data_key="tailsLocation",
example="https://tails-server.com/hash/7Qen9RDyemMuV7xGQvp7NjwMSpyHieJyBakycxN7dX7P",
metadata={
"example": "https://tails-server.com/hash/7Qen9RDyemMuV7xGQvp7NjwMSpyHieJyBakycxN7dX7P"
},
)
tails_hash = fields.Str(
data_key="tailsHash", example="7Qen9RDyemMuV7xGQvp7NjwMSpyHieJyBakycxN7dX7P"
data_key="tailsHash",
metadata={"example": "7Qen9RDyemMuV7xGQvp7NjwMSpyHieJyBakycxN7dX7P"},
)


Expand Down Expand Up @@ -130,18 +133,25 @@ class Meta:
unknown = EXCLUDE

issuer_id = fields.Str(
description="Issuer Identifier of the credential definition or schema",
metadata={
"description": "Issuer Identifier of the credential definition or schema",
"example": INDY_OR_KEY_DID_EXAMPLE,
},
data_key="issuerId",
example=INDY_OR_KEY_DID_EXAMPLE,
)
type = fields.Str(data_key="revocDefType")
cred_def_id = fields.Str(
description="Credential definition identifier",
metadata={
"description": "Credential definition identifier",
"example": INDY_CRED_DEF_ID_EXAMPLE,
},
data_key="credDefId",
example=INDY_CRED_DEF_ID_EXAMPLE,
)
tag = fields.Str(
description="tag for the revocation registry definition", example="default"
metadata={
"description": "tag for the revocation registry definition",
"example": "default",
}
)
value = fields.Nested(RevRegDefValueSchema())

Expand Down Expand Up @@ -204,11 +214,13 @@ class Meta:
)
)
revocation_registry_definition_id = fields.Str(
description="revocation registry definition id",
example=INDY_REV_REG_ID_EXAMPLE,
metadata={
"description": "revocation registry definition id",
"example": INDY_REV_REG_ID_EXAMPLE,
}
)
revocation_registry_definition = fields.Nested(
RevRegDefSchema(), description="revocation registry definition"
RevRegDefSchema(), metadata={"description": "revocation registry definition"}
)


Expand Down Expand Up @@ -381,30 +393,40 @@ class Meta:
unknown = EXCLUDE

issuer_id = fields.Str(
description="Issuer Identifier of the credential definition or schema",
metadata={
"description": "Issuer Identifier of the credential definition or schema",
"example": INDY_OR_KEY_DID_EXAMPLE,
},
data_key="issuerId",
example=INDY_OR_KEY_DID_EXAMPLE,
)
rev_reg_def_id = fields.Str(
description="The ID of the revocation registry definition",
metadata={
"description": "The ID of the revocation registry definition",
"example": INDY_REV_REG_ID_EXAMPLE,
},
data_key="revRegDefId",
example=INDY_REV_REG_ID_EXAMPLE,
)
revocation_list = fields.List(
fields.Int(),
description="Bit list representing revoked credentials",
metadata={
"description": "Bit list representing revoked credentials",
"example": [0, 1, 1, 0],
},
data_key="revocationList",
example=[0, 1, 1, 0],
)
current_accumulator = fields.Str(
description="The current accumalator value",
example="21 118...1FB",
metadata={
"description": "The current accumalator value",
"example": "21 118...1FB",
},
data_key="currentAccumulator",
)
timestamp = fields.Int(
description="Timestamp at which revocation list is applicable",
metadata={
"description": "Timestamp at which revocation list is applicable",
"example": INDY_ISO8601_DATETIME_EXAMPLE,
},
required=False,
example=INDY_ISO8601_DATETIME_EXAMPLE,
)


Expand Down Expand Up @@ -458,7 +480,9 @@ class Meta:
]
)
)
revocation_list = fields.Nested(RevListSchema(), description="revocation list")
revocation_list = fields.Nested(
RevListSchema(), metadata={"description": "revocation list"}
)


class RevListResult(BaseModel):
Expand Down
28 changes: 18 additions & 10 deletions aries_cloudagent/anoncreds/models/anoncreds_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,26 @@ class Meta:
unknown = EXCLUDE

issuer_id = fields.Str(
description="Issuer Identifier of the credential definition or schema",
metadata={
"description": "Issuer Identifier of the credential definition or schema",
"example": INDY_OR_KEY_DID_EXAMPLE,
},
data_key="issuerId",
example=INDY_OR_KEY_DID_EXAMPLE,
)
attr_names = fields.List(
fields.Str(
description="Attribute name",
example="score",
metadata={
"description": "Attribute name",
"example": "score",
}
),
description="Schema attribute names",
metadata={"description": "Schema attribute names"},
data_key="attrNames",
)
name = fields.Str(description="Schema name", example="Example schema")
version = fields.Str(description="Schema version", example="1.0")
name = fields.Str(
metadata={"description": "Schema name", "example": "Example schema"}
)
version = fields.Str(metadata={"description": "Schema version", "example": "1.0"})


class GetSchemaResult(BaseModel):
Expand Down Expand Up @@ -130,7 +136,7 @@ class Meta:

schema_value = fields.Nested(AnonCredsSchemaSchema(), data_key="schema")
schema_id = fields.Str(
description="Schema identifier", example=INDY_SCHEMA_ID_EXAMPLE
metadata={"description": "Schema identifier", "example": INDY_SCHEMA_ID_EXAMPLE}
)
resolution_metadata = fields.Dict()
schema_metadata = fields.Dict()
Expand Down Expand Up @@ -184,8 +190,10 @@ class Meta:
)
)
schema_id = fields.Str(
description="Schema identifier",
example=INDY_SCHEMA_ID_EXAMPLE,
metadata={
"description": "Schema identifier",
"example": INDY_SCHEMA_ID_EXAMPLE,
}
)
schema_value = fields.Nested(AnonCredsSchemaSchema(), data_key="schema")

Expand Down
6 changes: 3 additions & 3 deletions aries_cloudagent/anoncreds/revocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,15 +1209,15 @@ async def revoke_pending_credentials(
)
failed_crids.add(rev_id)
elif rev_id >= rev_info["next_index"]:
LOGGER.warn(
LOGGER.warning(
"Skipping requested credential revocation"
"on rev reg id %s, cred rev id=%s not yet issued",
revoc_reg_id,
rev_id,
)
failed_crids.add(rev_id)
elif rev_list.revocation_list[rev_id] == 1:
LOGGER.warn(
LOGGER.warning(
"Skipping requested credential revocation"
"on rev reg id %s, cred rev id=%s already revoked",
revoc_reg_id,
Expand Down Expand Up @@ -1259,7 +1259,7 @@ async def revoke_pending_credentials(
CATEGORY_REV_LIST, revoc_reg_id, for_update=True
)
if not rev_info_upd:
LOGGER.warn(
LOGGER.warning(
"Revocation registry missing, skipping update: {}",
revoc_reg_id,
)
Expand Down
Loading

0 comments on commit 75e35c1

Please sign in to comment.