Skip to content

Commit

Permalink
Merge branch 'data-integrity-routes' of github.com:OpSecId/aries-clou…
Browse files Browse the repository at this point in the history
…dagent-python into data-integrity-routes
  • Loading branch information
PatStLouis committed Sep 27, 2024
2 parents a53f017 + 8dad323 commit d0d24ba
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/actions/run-unit-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ runs:
- name: Tests
shell: bash
run: |
poetry run pytest --cov=aries_cloudagent --cov-report term-missing --cov-report xml --ignore-glob=/tests/* --ignore-glob=demo/* --ignore-glob=docker/* --ignore-glob=docs/* --ignore-glob=scripts/* 2>&1 | tee pytest.log
poetry run pytest --cov=aries_cloudagent --cov-report term-missing --cov-report xml --ignore-glob=/tests/* --ignore-glob=demo/* --ignore-glob=docker/* --ignore-glob=docs/* --ignore-glob=scripts/* --ignore-glob=scenarios/* 2>&1 | tee pytest.log
PYTEST_EXIT_CODE=${PIPESTATUS[0]}
if grep -Eq "RuntimeWarning: coroutine .* was never awaited" pytest.log; then
echo "Failure: Detected unawaited coroutine warning in pytest output."
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/bdd-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
src:
- aries_cloudagent/**/*
- poetry.lock
- pyproject.toml
demo: "demo/**/*"
- name: Check if demo or src files changed
id: check-if-demo-or-src-changed
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/bdd-interop-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
src:
- aries_cloudagent/**/*
- poetry.lock
- pyproject.toml
- name: Check if src files changed
id: check-if-src-changed
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/scenario-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
src:
- aries_cloudagent/**/*
- poetry.lock
- pyproject.toml
- name: Check if scenarios or src files changed
id: check-if-scenarios-or-src-changed
run: |
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/sonar-merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
if: github.repository == 'hyperledger/aries-cloudagent-python'
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -30,5 +31,6 @@ jobs:
with:
args: >
-Dsonar.python.coverage.reportPaths=test-reports/coverage.xml
-Dsonar.coverage.exclusions=**/tests/*,**/demo/*,**/docs/*,**/docker/*,**/scripts/*
-Dsonar.coverage.exclusions=**/tests/**,**/demo/**,**/docs/**,**/docker/**,**/scripts/**,**/scenarios/**
-Dsonar.cpd.exclusions=**/tests/**,**/demo/**,**/docs/**,**/docker/**,**/scripts/**,**/scenarios/**
-Dsonar.sources=./
5 changes: 3 additions & 2 deletions .github/workflows/sonar-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
SonarCloud:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
if: github.event.workflow_run.conclusion == 'success' && github.repository == 'hyperledger/aries-cloudagent-python'
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -68,6 +68,7 @@ jobs:
-Dsonar.pullrequest.key=${{ fromJson(steps.get_pr_data.outputs.data).number }}
-Dsonar.pullrequest.branch=${{ fromJson(steps.get_pr_data.outputs.data).head.ref }}
-Dsonar.pullrequest.base=${{ fromJson(steps.get_pr_data.outputs.data).base.ref }}
-Dsonar.coverage.exclusions=**/tests/*,**/demo/*,**/docs/*,**/docker/*,**/scripts/*
-Dsonar.coverage.exclusions=**/tests/**,**/demo/**,**/docs/**,**/docker/**,**/scripts/**,**/scenarios/**
-Dsonar.cpd.exclusions=**/tests/**,**/demo/**,**/docs/**,**/docker/**,**/scripts/**,**/scenarios/**
-Dsonar.python.coverage.reportPaths=test-reports/coverage.xml
-Dsonar.sources=./
26 changes: 25 additions & 1 deletion aries_cloudagent/wallet/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
NON_SD_LIST_VALIDATE,
SD_JWT_EXAMPLE,
SD_JWT_VALIDATE,
UUID4_EXAMPLE,
UUID4_VALIDATE,
IndyDID,
StrOrDictField,
Uri,
Expand Down Expand Up @@ -172,6 +174,14 @@ class DIDEndpointWithTypeSchema(OpenAPISchema):
"example": ENDPOINT_TYPE_EXAMPLE,
},
)
mediation_id = fields.Str(
required=False,
validate=UUID4_VALIDATE,
metadata={
"description": "Medation ID to use for endpoint information.",
"example": UUID4_EXAMPLE,
},
)


class JWSCreateSchema(OpenAPISchema):
Expand Down Expand Up @@ -896,7 +906,7 @@ async def promote_wallet_public_did(
async with (
context.session() if is_ctx_admin_request else profile.session()
) as session:
wallet = session.inject_or(BaseWallet)
wallet = session.inject(BaseWallet)
did_info = await wallet.get_local_did(did)
info = await wallet.set_public_did(did_info)

Expand Down Expand Up @@ -951,6 +961,7 @@ async def wallet_set_did_endpoint(request: web.BaseRequest):
did = body["did"]
endpoint = body.get("endpoint")
endpoint_type = EndpointType.get(body.get("endpoint_type", EndpointType.ENDPOINT.w3c))
mediation_id = body.get("mediation_id")

create_transaction_for_endorser = json.loads(
request.query.get("create_transaction_for_endorser", "false")
Expand All @@ -960,6 +971,17 @@ async def wallet_set_did_endpoint(request: web.BaseRequest):
connection_id = request.query.get("conn_id")
attrib_def = None

profile = context.profile
route_manager = profile.inject(RouteManager)
mediation_record = await route_manager.mediation_record_if_id(
profile=profile, mediation_id=mediation_id, or_default=True
)
routing_keys, mediator_endpoint = await route_manager.routing_info(
profile,
mediation_record,
)
LOGGER.debug("Mediation info: %s, %s", routing_keys, mediator_endpoint)

# check if we need to endorse
if is_author_role(context.profile):
# authors cannot write to the ledger
Expand Down Expand Up @@ -1005,6 +1027,7 @@ async def wallet_set_did_endpoint(request: web.BaseRequest):
if not wallet:
raise web.HTTPForbidden(reason="No wallet available")
try:
endpoint = mediator_endpoint or endpoint
ledger = context.profile.inject_or(BaseLedger)
attrib_def = await wallet.set_did_endpoint(
did,
Expand All @@ -1013,6 +1036,7 @@ async def wallet_set_did_endpoint(request: web.BaseRequest):
endpoint_type,
write_ledger=write_ledger,
endorser_did=endorser_did,
routing_keys=routing_keys,
)
except WalletNotFoundError as err:
raise web.HTTPNotFound(reason=err.roll_up) from err
Expand Down
7 changes: 5 additions & 2 deletions aries_cloudagent/wallet/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ class TestWalletRoutes(IsolatedAsyncioTestCase):
def setUp(self):
self.wallet = mock.create_autospec(BaseWallet)
self.session_inject = {BaseWallet: self.wallet}
self.route_mgr = mock.MagicMock()
self.route_mgr.mediation_record_if_id = mock.CoroutineMock(return_value=None)
self.route_mgr.routing_info = mock.CoroutineMock(return_value=(None, None))
self.profile = InMemoryProfile.test_profile(
settings={"admin.admin_api_key": "secret-key"}
settings={"admin.admin_api_key": "secret-key"},
bind={KeyTypes: KeyTypes(), RouteManager: self.route_mgr},
)
self.context = AdminRequestContext.test_context(self.session_inject, self.profile)
self.context.injector.bind_instance(KeyTypes, KeyTypes())
self.request_dict = {
"context": self.context,
"outbound_message_router": mock.CoroutineMock(),
Expand Down

0 comments on commit d0d24ba

Please sign in to comment.