Skip to content

Commit 23a8172

Browse files
authored
Merge branch 'main' into fix/public-did-mediator-routing-keys
2 parents 827263a + 7b1c457 commit 23a8172

10 files changed

Lines changed: 57 additions & 73 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/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

aries_cloudagent/protocols/connections/v1_0/models/connection_detail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _serialize(self, value, attr, obj, **kwargs):
2323
"""
2424
return value.serialize()
2525

26-
def _deserialize(self, value, attr, data, **kwargs):
26+
def _deserialize(self, value, attr=None, data=None, **kwargs):
2727
"""
2828
Deserialize a value into a DIDDoc.
2929

aries_cloudagent/protocols/out_of_band/v1_0/messages/invitation.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,17 @@ def _serialize(self, value, attr, obj, **kwargs):
9696
def _deserialize(self, value, attr, data, **kwargs):
9797
if isinstance(value, dict):
9898
return Service.deserialize(value)
99+
elif isinstance(value, Service):
100+
return value
99101
elif isinstance(value, str):
100-
if bool(DIDValidation.PATTERN.match(value)):
101-
return value
102-
else:
102+
if not DIDValidation.PATTERN.match(value):
103103
raise ValidationError(
104104
"Service item must be a valid decentralized identifier (DID)"
105105
)
106+
return value
107+
raise ValidationError(
108+
"Service item must be a valid decentralized identifier (DID) or object"
109+
)
106110

107111

108112
class InvitationMessage(AgentMessage):
@@ -221,9 +225,6 @@ class Meta:
221225
fields.Str(
222226
description="Handshake protocol",
223227
example=DIDCommPrefix.qualify_current(HSProto.RFC23.name),
224-
validate=lambda hsp: (
225-
DIDCommPrefix.unqualify(hsp) in [p.name for p in HSProto]
226-
),
227228
),
228229
required=False,
229230
)
@@ -276,13 +277,10 @@ def validate_fields(self, data, **kwargs):
276277
"""
277278
handshake_protocols = data.get("handshake_protocols")
278279
requests_attach = data.get("requests_attach")
279-
if not (
280-
(handshake_protocols and len(handshake_protocols) > 0)
281-
or (requests_attach and len(requests_attach) > 0)
282-
):
280+
if not handshake_protocols and not requests_attach:
283281
raise ValidationError(
284282
"Model must include non-empty "
285-
"handshake_protocols or requests_attach or both"
283+
"handshake_protocols or requests~attach or both"
286284
)
287285

288286
# services = data.get("services")

aries_cloudagent/protocols/out_of_band/v1_0/messages/tests/test_invitation.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,8 @@ def test_invalid_invi_wrong_type_services(self):
139139
"services": [123],
140140
}
141141

142-
invi_schema = InvitationMessageSchema()
143-
with pytest.raises(test_module.ValidationError):
144-
invi_schema.validate_fields(obj_x)
142+
errs = InvitationMessageSchema().validate(obj_x)
143+
assert errs and "services" in errs
145144

146145
def test_assign_msg_type_version_to_model_inst(self):
147146
test_msg = InvitationMessage()

0 commit comments

Comments
 (0)