Skip to content

Commit 71e4e56

Browse files
authored
Merge branch 'hyperledger:main' into feature/create-all-registered-dids
2 parents 224b93e + 4c20dcd commit 71e4e56

19 files changed

Lines changed: 159 additions & 110 deletions

File tree

.github/workflows/blackformat.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ jobs:
1010
name: lint
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-python@v2
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-python@v4
15+
with:
16+
python-version: "3.9"
1517
- name: Black Code Formatter Check
1618
uses: psf/black@stable

.github/workflows/codeql.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ jobs:
1212
runs-on: ubuntu-latest
1313
if: (github.event_name == 'pull_request' && github.repository == 'hyperledger/aries-cloudagent-python') || (github.event_name != 'pull_request')
1414

15+
permissions:
16+
security-events: write
17+
1518
steps:
1619
- name: Checkout repository
17-
uses: actions/checkout@v2
20+
uses: actions/checkout@v3
1821

1922
# Initializes the CodeQL tools for scanning.
2023
- name: Initialize CodeQL
21-
uses: github/codeql-action/init@v1
24+
uses: github/codeql-action/init@v2
2225
with:
2326
languages: python
2427

2528
- name: Perform CodeQL Analysis
26-
uses: github/codeql-action/analyze@v1
29+
uses: github/codeql-action/analyze@v2

.github/workflows/integrationtests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
if: (github.event_name == 'pull_request' && github.repository == 'hyperledger/aries-cloudagent-python') || (github.event_name != 'pull_request')
1414
steps:
1515
- name: checkout-acapy
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v3
1717
with:
1818
path: acapy
1919
#- name: run-von-network

.github/workflows/pythonpublish.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ jobs:
88
deploy:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v1
12-
- name: Set up Python
13-
uses: actions/setup-python@v1
14-
with:
15-
python-version: '3.x'
16-
- name: Install dependencies
17-
run: |
18-
python -m pip install --upgrade pip
19-
pip install setuptools wheel twine
20-
- name: Build and publish
21-
env:
22-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
23-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
24-
run: |
25-
python setup.py sdist bdist_wheel
26-
twine upload dist/*
11+
- uses: actions/checkout@v3
12+
- name: Set up Python
13+
uses: actions/setup-python@v4
14+
with:
15+
python-version: "3.x"
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install setuptools wheel twine
20+
- name: Build and publish
21+
env:
22+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
23+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
24+
run: |
25+
python setup.py sdist bdist_wheel
26+
twine upload dist/*

.github/workflows/tests-indy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
${{ runner.os }}-buildx-test-
3030
3131
- name: Set up Docker Buildx
32-
uses: docker/setup-buildx-action@v1
32+
uses: docker/setup-buildx-action@v2
3333

3434
- name: Build test image
3535
uses: docker/build-push-action@v3

Mediation.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
* `--open-mediation` - Instructs mediators to automatically grant all incoming mediation requests.
1717
* `--mediator-invitation` - Receive invitation, send mediation request and set as default mediator.
18+
* `--mediator-connections-invite` - Connect to mediator through a connection invitation. If not specified, connect using an OOB invitation.
1819
* `--default-mediator-id` - Set pre-existing mediator as default mediator.
1920
* `--clear-default-mediator` - Clear the stored default mediator.
2021

@@ -72,4 +73,4 @@ See [Aries RFC 0211: Coordinate Mediation Protocol](https://github.com/hyperledg
7273
## Using a Mediator
7374

7475
After establishing a connection with a mediator also having mediation granted, you can use that mediator id for future did_comm connections.
75-
When creating, receiving or accepting a invitation intended to be Mediated, you provide `mediation_id` with the desired mediator id. if using a single mediator for all future connections, You can set a default mediation id. If no mediation_id is provided the default mediation id will be used instead.
76+
When creating, receiving or accepting a invitation intended to be Mediated, you provide `mediation_id` with the desired mediator id. if using a single mediator for all future connections, You can set a default mediation id. If no mediation_id is provided the default mediation id will be used instead.

aries_cloudagent/connections/base_manager.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,16 +269,18 @@ async def resolve_invitation(
269269

270270
endpoint = first_didcomm_service.service_endpoint
271271
recipient_keys: List[VerificationMethod] = [
272-
doc.dereference(url) for url in first_didcomm_service.recipient_keys
272+
await resolver.dereference(self._profile, url, document=doc)
273+
for url in first_didcomm_service.recipient_keys
273274
]
274275
routing_keys: List[VerificationMethod] = [
275-
doc.dereference(url) for url in first_didcomm_service.routing_keys
276+
await resolver.dereference(self._profile, url, document=doc)
277+
for url in first_didcomm_service.routing_keys
276278
]
277279

278280
for key in [*recipient_keys, *routing_keys]:
279281
if not isinstance(key, self.SUPPORTED_KEY_TYPES):
280282
raise BaseConnectionManagerError(
281-
f"Key type {key.type} is not supported"
283+
f"Key type {type(key).__name__} is not supported"
282284
)
283285

284286
return (

aries_cloudagent/messaging/jsonld/routes.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from marshmallow import INCLUDE, Schema, fields
66
from pydid.verification_method import (
77
Ed25519VerificationKey2018,
8-
KnownVerificationMethods,
98
)
109

1110
from ...admin.request_context import AdminRequestContext
@@ -148,7 +147,6 @@ async def verify(request: web.BaseRequest):
148147
vmethod = await resolver.dereference(
149148
profile,
150149
doc["proof"]["verificationMethod"],
151-
cls=KnownVerificationMethods,
152150
)
153151

154152
if not isinstance(vmethod, SUPPORTED_VERIFICATION_METHOD_TYPES):

aries_cloudagent/messaging/jsonld/tests/test_routes.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -234,22 +234,22 @@ async def test_verify_bad_ver_meth_deref_req_error(
234234
assert "error" in mock_response.call_args[0][0]
235235

236236

237-
@pytest.mark.asyncio
238-
async def test_verify_bad_ver_meth_not_ver_meth(
239-
mock_resolver, mock_verify_request, mock_response, request_body
240-
):
241-
request_body["doc"]["proof"][
242-
"verificationMethod"
243-
] = "did:example:1234abcd#did-communication"
244-
await test_module.verify(mock_verify_request(request_body))
245-
assert "error" in mock_response.call_args[0][0]
246-
247-
237+
@pytest.mark.parametrize(
238+
"vmethod",
239+
[
240+
"did:example:1234abcd#key-2",
241+
"did:example:1234abcd#did-communication",
242+
],
243+
)
248244
@pytest.mark.asyncio
249245
async def test_verify_bad_vmethod_unsupported(
250-
mock_resolver, mock_verify_request, mock_response, request_body
246+
mock_resolver,
247+
mock_verify_request,
248+
mock_response,
249+
request_body,
250+
vmethod,
251251
):
252-
request_body["doc"]["proof"]["verificationMethod"] = "did:example:1234abcd#key-2"
252+
request_body["doc"]["proof"]["verificationMethod"] = vmethod
253253
with pytest.raises(web.HTTPBadRequest):
254254
await test_module.verify(mock_verify_request(request_body))
255255

aries_cloudagent/messaging/valid.py

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,60 +23,41 @@
2323
class StrOrDictField(Field):
2424
"""URI or Dict field for Marshmallow."""
2525

26-
def _serialize(self, value, attr, obj, **kwargs):
27-
return value
28-
2926
def _deserialize(self, value, attr, data, **kwargs):
30-
if isinstance(value, (str, dict)):
31-
return value
32-
else:
27+
if not isinstance(value, (str, dict)):
3328
raise ValidationError("Field should be str or dict")
29+
return super()._deserialize(value, attr, data, **kwargs)
3430

3531

3632
class StrOrNumberField(Field):
3733
"""String or Number field for Marshmallow."""
3834

39-
def _serialize(self, value, attr, obj, **kwargs):
40-
return value
41-
4235
def _deserialize(self, value, attr, data, **kwargs):
43-
if isinstance(value, (str, float, int)):
44-
return value
45-
else:
36+
if not isinstance(value, (str, float, int)):
4637
raise ValidationError("Field should be str or int or float")
38+
return super()._deserialize(value, attr, data, **kwargs)
4739

4840

4941
class DictOrDictListField(Field):
5042
"""Dict or Dict List field for Marshmallow."""
5143

52-
def _serialize(self, value, attr, obj, **kwargs):
53-
return value
54-
5544
def _deserialize(self, value, attr, data, **kwargs):
56-
# dict
57-
if isinstance(value, dict):
58-
return value
59-
# list of dicts
60-
elif isinstance(value, list) and all(isinstance(item, dict) for item in value):
61-
return value
62-
else:
63-
raise ValidationError("Field should be dict or list of dicts")
45+
if not isinstance(value, dict):
46+
if not isinstance(value, list) or not all(
47+
isinstance(item, dict) for item in value
48+
):
49+
raise ValidationError("Field should be dict or list of dicts")
50+
return super()._deserialize(value, attr, data, **kwargs)
6451

6552

6653
class UriOrDictField(StrOrDictField):
6754
"""URI or Dict field for Marshmallow."""
6855

69-
def __init__(self, *args, **kwargs):
70-
"""Initialize new UriOrDictField instance."""
71-
super().__init__(*args, **kwargs)
72-
73-
# Insert validation into self.validators so that multiple errors can be stored.
74-
self.validators.insert(0, self._uri_validator)
75-
76-
def _uri_validator(self, value):
77-
# Check if URI when
56+
def _deserialize(self, value, attr, data, **kwargs):
7857
if isinstance(value, str):
79-
return Uri()(value)
58+
# Check regex
59+
Uri()(value)
60+
return super()._deserialize(value, attr, data, **kwargs)
8061

8162

8263
class IntEpoch(Range):
@@ -775,7 +756,7 @@ def __call__(self, value):
775756
except ValidationError:
776757
raise ValidationError(
777758
f"credential subject id {value[0]} must be URI"
778-
)
759+
) from None
779760

780761
return value
781762

0 commit comments

Comments
 (0)