Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge from upstream #4

Merged
merged 147 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
10e8b54
refactor: remove unused mediation terms
dbluhm Sep 25, 2023
d18fb69
test: mediator_terms record backwards compat
dbluhm Sep 25, 2023
3b51670
fix: mediation ids on test records
dbluhm Sep 25, 2023
387fd47
Change arg_parse to always set --emit-new-didcomm-prefix and --emit-n…
swcurran Sep 26, 2023
c88266e
Merge branch 'main' into default-emits
swcurran Sep 26, 2023
1ec6cc5
fix: Problem Report Before Connection
Sep 26, 2023
90ba448
fix: Problem Report Before Exchange
Sep 26, 2023
ad2fa1c
fix: Problem Report Before Exchange
Sep 27, 2023
7f877ff
fix: Problem Report Before Exchange
Sep 27, 2023
f68914b
fix: Problem Report Before Exchange
Sep 27, 2023
7283b43
fix: Problem Report Before Exchange
Sep 27, 2023
10e211f
Merge pull request #2517 from swcurran/default-emits
dbluhm Sep 27, 2023
2556f49
Merge branch 'main' into fix/ProblemReportBeforeConnection
dbluhm Sep 27, 2023
04304aa
Merge pull request #2519 from Ennovate-com/fix/ProblemReportBeforeCon…
dbluhm Sep 27, 2023
5af00ba
Merge branch 'main' into refactor/mediation-terms-remove
swcurran Sep 27, 2023
bad688e
Merge pull request #2515 from dbluhm/refactor/mediation-terms-remove
swcurran Sep 28, 2023
6bf1324
fix concurrent sessions
andrewwhitehead Sep 27, 2023
ced024a
avoid carrying open wallet instance in WalletKeyPair
andrewwhitehead Sep 28, 2023
950732f
Merge pull request #2521 from andrewwhitehead/fix/session-usage
swcurran Sep 29, 2023
59d93fe
chore(deps): Bump urllib3 in /demo/playground/scripts
dependabot[bot] Oct 2, 2023
0d77e87
chore(deps): Bump urllib3 from 2.0.5 to 2.0.6
dependabot[bot] Oct 3, 2023
c999e9d
Merge pull request #2525 from hyperledger/dependabot/pip/urllib3-2.0.6
swcurran Oct 3, 2023
ed1987b
Merge pull request #2524 from hyperledger/dependabot/pip/demo/playgro…
swcurran Oct 3, 2023
06ffa79
chore: update pydid
dbluhm Oct 3, 2023
506ec31
impl tenant profile + root_profile upgradation process
shaangill025 Oct 4, 2023
9387824
fixes
shaangill025 Oct 4, 2023
ef30678
unit tests + doc update
shaangill025 Oct 5, 2023
760e9bf
Merge pull request #2527 from dbluhm/chore/update-pydid
swcurran Oct 5, 2023
5600481
use basestoragesearch instead of query
shaangill025 Oct 6, 2023
a4c61ad
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 Oct 6, 2023
2623583
fix: correct minor typos
Oct 11, 2023
3c8012f
fix: minor typos
Oct 11, 2023
a0666ef
Merge branch 'fix/minor-typos' of github.com:Ennovate-com/aries-cloud…
Oct 11, 2023
e096f7f
:art: clarify LedgerError message: if TAA is not accepted it may also…
ff137 Oct 13, 2023
4c8f64a
Merge pull request #2545 from ff137/art/improve-ledger-error-message
swcurran Oct 13, 2023
9688a2c
Merge branch 'main' into fix/minor-typos
Ennovate-com Oct 14, 2023
ea22d3a
Update .readthedocs.yaml
swcurran Oct 14, 2023
f503a2e
Merge pull request #2544 from Ennovate-com/fix/minor-typos
swcurran Oct 15, 2023
d11f89f
Merge branch 'main' into swcurran-rtd-fix-1
swcurran Oct 15, 2023
f768ec8
Merge pull request #2547 from hyperledger/swcurran-rtd-fix-1
swcurran Oct 15, 2023
3ce4a60
Update .readthedocs.yaml
swcurran Oct 15, 2023
b1eb224
Merge pull request #2548 from hyperledger/swcurran-rtd-2
swcurran Oct 15, 2023
718e74c
Fixed: https://github.com/hyperledger/aries-cloudagent-python/issues/…
codespree Oct 7, 2023
58fd7c0
style: minor style correction
dbluhm Oct 7, 2023
7e52305
test: did:key to did:key ref
dbluhm Oct 7, 2023
d901028
fix: remove redundant transform step
dbluhm Oct 7, 2023
a7d2833
Merge pull request #2536 from dbluhm/fix/routing-keys
swcurran Oct 16, 2023
28a2e2b
Merge branch 'main' into subwallet_upgrade
shaangill025 Oct 16, 2023
ebf1544
Merge pull request #2529 from shaangill025/subwallet_upgrade
swcurran Oct 17, 2023
fc7ca4a
chore(deps): Bump urllib3 in /demo/playground/scripts
dependabot[bot] Oct 17, 2023
1f0c3ad
chore(deps): Bump urllib3 from 2.0.6 to 2.0.7
dependabot[bot] Oct 17, 2023
ac1dde3
Merge pull request #2552 from hyperledger/dependabot/pip/urllib3-2.0.7
swcurran Oct 17, 2023
dece021
Merge branch 'main' into dependabot/pip/demo/playground/scripts/urlli…
swcurran Oct 17, 2023
12ec11b
fix: taa rough timestamp timezone from datetime
dbluhm Oct 18, 2023
bf871f7
Merge pull request #2554 from dbluhm/fix/taa-rough-timestamp
dbluhm Oct 18, 2023
de09845
fix: mediator routing keys should be did:key
dbluhm Sep 25, 2023
581e566
fix: store mediation routing keys as did:key
dbluhm Sep 25, 2023
ed9b31b
fix: optimize Dockerfile.run for faster rebuilds
dbluhm Sep 26, 2023
2e9bc5d
refactor: don't treat routing keys as owned keys
dbluhm Sep 26, 2023
78304f7
fix!: oob and did doc routing keys should be refs
dbluhm Sep 26, 2023
8d9dceb
refactor: normalize only in manager for grant
dbluhm Oct 7, 2023
64ecf0b
refactor: routing_info delegates default endpoint to caller
dbluhm Oct 7, 2023
34d800f
revert: create_did_doc svc_endpoints optional
dbluhm Oct 7, 2023
dd9aa59
fix: request granted, normalize routing keys to did key ref
dbluhm Oct 7, 2023
21926d5
refactor: route manager returns list
dbluhm Oct 7, 2023
1f2934d
refactor: route connection as invitee handles list
dbluhm Oct 7, 2023
6e80963
refactor: route connection as inviter handles list
dbluhm Oct 7, 2023
858f546
refactor: route connection handles list
dbluhm Oct 7, 2023
f4a03ba
test: changes to base conn manager
dbluhm Oct 7, 2023
060426b
fix: broken tests in multitenant route manager
dbluhm Oct 7, 2023
ea5a336
fix: broken tests in connection manager
dbluhm Oct 8, 2023
311a7ee
fix: broken test on grant handler
dbluhm Oct 8, 2023
abaff65
fix: mediation manager tests
dbluhm Oct 8, 2023
ac03106
fix: coordinate mediation manager tests
dbluhm Oct 8, 2023
1f3f41a
fix: didexchange manager tests
dbluhm Oct 8, 2023
113ca85
fix: oob invitation accept either did key or ref
dbluhm Oct 8, 2023
f62b1fe
fix: oob manager tests
dbluhm Oct 8, 2023
a8cf6ad
feat: for legacy support, continue using raw routing keys
dbluhm Oct 16, 2023
0662c6e
refactor: replace multiformats library
dbluhm Oct 19, 2023
9d13f5d
test: multiformats
dbluhm Oct 19, 2023
2c901a9
Merge pull request #2559 from dbluhm/refactor/replace-multiformats
usingtechnology Oct 19, 2023
6017f1c
Merge branch 'main' into fix/mediation-routing-keys-as-did-key
swcurran Oct 19, 2023
900b1d8
Merge pull request #2516 from dbluhm/fix/mediation-routing-keys-as-di…
swcurran Oct 20, 2023
024c5f7
Merge branch 'main' into dependabot/pip/demo/playground/scripts/urlli…
swcurran Oct 20, 2023
b8c00ec
Merge pull request #2551 from hyperledger/dependabot/pip/demo/playgro…
swcurran Oct 20, 2023
43ff133
Migrate python scripts into runnable container
usingtechnology Oct 24, 2023
c5a9458
refactor: use did-peer-2 instead of peerdid
dbluhm Oct 24, 2023
2ea7886
fix: clean up requests and invites
dbluhm Oct 24, 2023
84df2f1
Merge pull request #2560 from dbluhm/fix/cleanup-requests-and-invites
swcurran Oct 24, 2023
2c24dc4
Merge branch 'main' into refactor/did-peer-2
swcurran Oct 24, 2023
a91d99e
add multi-tenant examples
usingtechnology Oct 24, 2023
f74995b
Merge branch 'usingtechnology-issue-2555-playground-scripts'
usingtechnology Oct 24, 2023
24d7cc9
having conflict issues...
usingtechnology Oct 24, 2023
ba17e93
Merge branch 'main' into issue-2555-playground-scripts
usingtechnology Oct 24, 2023
830ea97
now remove it
usingtechnology Oct 25, 2023
6e9630b
Merge pull request #2562 from usingtechnology/issue-2555-playground-s…
usingtechnology Oct 25, 2023
b4ebb86
Merge branch 'main' into refactor/did-peer-2
swcurran Oct 25, 2023
c616ac6
Merge pull request #2561 from dbluhm/refactor/did-peer-2
swcurran Oct 25, 2023
eed1d70
Merge remote-tracking branch 'upstream/main'
usingtechnology Oct 25, 2023
3bc6b51
Readme for demo/playground
usingtechnology Oct 25, 2023
f7db243
Merge pull request #2563 from usingtechnology/issue-2555-playground-s…
dbluhm Oct 25, 2023
c59e65a
Playground needs optionally external network
usingtechnology Oct 25, 2023
8311adc
Merge pull request #2564 from usingtechnology/issue-2555-playground-s…
dbluhm Oct 25, 2023
a733857
chore: dependency updates
dbluhm Oct 25, 2023
f80639c
Merge pull request #2565 from dbluhm/chore/update-pytest-asyncio
swcurran Oct 25, 2023
e81fc79
fix: drop asynctest
dbluhm Oct 25, 2023
fd41c62
fix: mt admin test routes mock issues
dbluhm Oct 25, 2023
8b77dfa
fix: conn v1 manager mock issues
dbluhm Oct 25, 2023
6d102c0
chore: normalize references to mock, replace async_mock
dbluhm Oct 27, 2023
818ee7f
chore: split unittest mock imports
dbluhm Oct 27, 2023
cfc2b8c
fix: provide CoroutineMock adapter
dbluhm Oct 27, 2023
2b8cf85
fix: xfail 3 tests that never worked
dbluhm Oct 27, 2023
ce2bb16
fix: never awaited error in PPv1 test routes
dbluhm Oct 27, 2023
d920e02
fix: never awaited warnings in wallet test routes
dbluhm Oct 27, 2023
0447250
fix: never awaited error in default verkey strat tests
dbluhm Oct 27, 2023
0a6746e
fix: test validation result async issue
dbluhm Oct 27, 2023
5005c84
fix: unawaited task in test basic message q
dbluhm Oct 27, 2023
0b581a5
fix: bad assertion in inbound test session
dbluhm Oct 27, 2023
b43f174
fix: mock logger.exception isn't a coroutine
dbluhm Oct 27, 2023
956a129
fix: introductiont tests bad assertion
dbluhm Oct 27, 2023
eee5e67
fix: bad assertions for called once with
dbluhm Oct 27, 2023
e77e8fe
fix: the "fixed" tests
dbluhm Oct 27, 2023
f257101
fix: test trie should be asyncio test case
dbluhm Oct 27, 2023
698808b
fix: inbound test message should be async test case
dbluhm Oct 27, 2023
9ca6b5e
fix: warnings on vc holder tests
dbluhm Oct 27, 2023
1998cab
fix: inbound ws transport test warning
dbluhm Oct 27, 2023
b69ff45
fix: in mem storage test warning
dbluhm Oct 27, 2023
13a65cc
fix: bad called once assertions on mocks
dbluhm Oct 27, 2023
1b5f923
fix: storage tests missing fixtures
dbluhm Oct 27, 2023
f15bdd9
fix: bad log assertions
dbluhm Oct 27, 2023
f754f95
fix: inbound message router not coroutine mock
dbluhm Oct 27, 2023
eff84bc
fix: bad mock in discovery tests
dbluhm Oct 27, 2023
3e61029
fix: bad mock in multiledger tests
dbluhm Oct 27, 2023
5b64fc1
fix: bad mocks in test dispatcher
dbluhm Oct 27, 2023
89e87c1
fix: unawaited coroutines in test conductor
dbluhm Oct 27, 2023
6ecd912
fix: unawaited coroutines in test start
dbluhm Oct 27, 2023
baa72c0
fix: unawaited coroutines in test_upgrade
dbluhm Oct 27, 2023
0da450c
chore: drop asynctest dep
dbluhm Oct 27, 2023
8a7e463
Merge pull request #2566 from dbluhm/chore/drop-asynctest
dbluhm Oct 28, 2023
db33302
chore: point to official sd-jwt lib release
dbluhm Oct 30, 2023
7b81c5e
0.11.0-rc0
swcurran Oct 30, 2023
08d5a4b
Missed some changes
swcurran Oct 30, 2023
60c376b
Merge pull request #2575 from swcurran/0.11.0-rc0
swcurran Oct 30, 2023
c33f474
Merge branch 'main' into chore/sd-jwt-lib-official
swcurran Oct 30, 2023
f7eff5d
Merge pull request #2573 from dbluhm/chore/sd-jwt-lib-official
swcurran Oct 30, 2023
82385d8
0.11.0-rc1
swcurran Oct 30, 2023
37c4bc2
Merge pull request #2576 from swcurran/0.11.0-rc1
swcurran Oct 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ build:
sphinx:
builder: dirhtml
configuration: docs/conf.py

python:
install:
- requirements: docs/requirements.txt
302 changes: 210 additions & 92 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Endorser.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

ACA-Py supports an [Endorser Protocol](https://github.com/hyperledger/aries-rfcs/pull/586), that allows an un-privileged agent (an "Author") to request another agent (the "Endorser") to sign their transactions so they can write these transactions to the ledger. This is required on Indy ledgers, where new agents will typically be granted only "Author" privileges.

Transaction Endorsement is built into the protocols for Schema, Credential Definition and Revocation, and endorsements can be explicitely requested, or ACA-Py can be configured to automate the endorsement workflow.
Transaction Endorsement is built into the protocols for Schema, Credential Definition and Revocation, and endorsements can be explicitly requested, or ACA-Py can be configured to automate the endorsement workflow.

## Setting up Connections between Authors and Endorsers

Expand All @@ -12,7 +12,7 @@ Once the connection is established and `active`, the "role" (either Author or En

## Requesting Transaction Endorsement

Transaction Endorsement is built into the protocols for Schema, Credential Definition and Revocation. When executing one of the endpoints that will trigger a ledger write, an endorsement protocol can be explicitely requested by specifying the `connection_id` (of the Endorser connection) and `create_transaction_for_endorser`.
Transaction Endorsement is built into the protocols for Schema, Credential Definition and Revocation. When executing one of the endpoints that will trigger a ledger write, an endorsement protocol can be explicitly requested by specifying the `connection_id` (of the Endorser connection) and `create_transaction_for_endorser`.

(Note that endorsement requests can be automated, see the secion on "Configuring ACA-Py" below.)

Expand Down
2 changes: 1 addition & 1 deletion UnitTests.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class TestDidExchangeManager(AsyncTestCase, TestConfig):
self.responder = MockResponder()

self.oob_mock = async_mock.MagicMock(
clean_finished_oob_record=async_mock.CoroutineMock(return_value=None)
clean_finished_oob_record=async_mock.AsyncMock(return_value=None)
)

self.route_manager = async_mock.MagicMock(RouteManager)
Expand Down
12 changes: 12 additions & 0 deletions UpgradingACA-Py.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,19 @@ In case, running multiple tags [say test1 & test2]:
./scripts/run_docker upgrade --force-upgrade --named-tag test1 --named-tag test2
```

## Subwallet upgrades
With multitenant enabled, there is a subwallet associated with each tenant profile, so there is a need to upgrade those sub wallets in addition to the base wallet associated with root profile.

There are 2 options to perform such upgrades:
- `--upgrade-all-subwallets`

This will apply the upgrade steps to all sub wallets [tenant profiles] and the base wallet [root profiles].

- `--upgrade-subwallet`

This will apply the upgrade steps to specified sub wallets [identified by wallet id] and the base wallet.

Note: multiple specification allowed

## Exceptions

Expand Down
108 changes: 51 additions & 57 deletions aries_cloudagent/admin/tests/test_admin_server.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

import pytest
import mock as async_mock
from aries_cloudagent.tests import mock
from unittest import IsolatedAsyncioTestCase
from aiohttp import ClientSession, DummyCookieJar, TCPConnector, web
from aiohttp.test_utils import unused_port
Expand Down Expand Up @@ -36,66 +36,62 @@ async def asyncTearDown(self):
self.client_session = None

async def test_debug_middleware(self):
with async_mock.patch.object(
test_module, "LOGGER", async_mock.MagicMock()
) as mock_logger:
mock_logger.isEnabledFor = async_mock.MagicMock(return_value=True)
mock_logger.debug = async_mock.MagicMock()
with mock.patch.object(test_module, "LOGGER", mock.MagicMock()) as mock_logger:
mock_logger.isEnabledFor = mock.MagicMock(return_value=True)
mock_logger.debug = mock.MagicMock()

request = async_mock.MagicMock(
request = mock.MagicMock(
method="GET",
path_qs="/hello/world?a=1&b=2",
match_info={"match": "info"},
text=async_mock.AsyncMock(return_value="abc123"),
text=mock.CoroutineMock(return_value="abc123"),
)
handler = async_mock.AsyncMock()
handler = mock.CoroutineMock()

await test_module.debug_middleware(request, handler)
mock_logger.isEnabledFor.assert_called_once()
assert mock_logger.debug.call_count == 3

async def test_ready_middleware(self):
with async_mock.patch.object(
test_module, "LOGGER", async_mock.MagicMock()
) as mock_logger:
mock_logger.isEnabledFor = async_mock.MagicMock(return_value=True)
mock_logger.debug = async_mock.MagicMock()
mock_logger.info = async_mock.MagicMock()
mock_logger.error = async_mock.MagicMock()

request = async_mock.MagicMock(
rel_url="/", app=async_mock.MagicMock(_state={"ready": False})
with mock.patch.object(test_module, "LOGGER", mock.MagicMock()) as mock_logger:
mock_logger.isEnabledFor = mock.MagicMock(return_value=True)
mock_logger.debug = mock.MagicMock()
mock_logger.info = mock.MagicMock()
mock_logger.error = mock.MagicMock()

request = mock.MagicMock(
rel_url="/", app=mock.MagicMock(_state={"ready": False})
)
handler = async_mock.AsyncMock(return_value="OK")
handler = mock.CoroutineMock(return_value="OK")
with self.assertRaises(test_module.web.HTTPServiceUnavailable):
await test_module.ready_middleware(request, handler)

request.app._state["ready"] = True
assert await test_module.ready_middleware(request, handler) == "OK"

request.app._state["ready"] = True
handler = async_mock.AsyncMock(
handler = mock.CoroutineMock(
side_effect=test_module.LedgerConfigError("Bad config")
)
with self.assertRaises(test_module.LedgerConfigError):
await test_module.ready_middleware(request, handler)

request.app._state["ready"] = True
handler = async_mock.AsyncMock(
handler = mock.CoroutineMock(
side_effect=test_module.web.HTTPFound(location="/api/doc")
)
with self.assertRaises(test_module.web.HTTPFound):
await test_module.ready_middleware(request, handler)

request.app._state["ready"] = True
handler = async_mock.AsyncMock(
handler = mock.CoroutineMock(
side_effect=test_module.asyncio.CancelledError("Cancelled")
)
with self.assertRaises(test_module.asyncio.CancelledError):
await test_module.ready_middleware(request, handler)

request.app._state["ready"] = True
handler = async_mock.AsyncMock(side_effect=KeyError("No such thing"))
handler = mock.CoroutineMock(side_effect=KeyError("No such thing"))
with self.assertRaises(KeyError):
await test_module.ready_middleware(request, handler)

Expand All @@ -110,10 +106,8 @@ def get_admin_server(
# middleware is task queue xor collector: cover both over test suite
task_queue = (settings or {}).pop("task_queue", None)

plugin_registry = async_mock.MagicMock(
test_module.PluginRegistry, autospec=True
)
plugin_registry.post_process_routes = async_mock.MagicMock()
plugin_registry = mock.MagicMock(test_module.PluginRegistry, autospec=True)
plugin_registry.post_process_routes = mock.MagicMock()
context.injector.bind_instance(test_module.PluginRegistry, plugin_registry)

collector = Collector()
Expand All @@ -129,10 +123,10 @@ def get_admin_server(
profile,
self.outbound_message_router,
self.webhook_router,
conductor_stop=async_mock.AsyncMock(),
conductor_stop=mock.CoroutineMock(),
task_queue=TaskQueue(max_active=4) if task_queue else None,
conductor_stats=(
None if task_queue else async_mock.AsyncMock(return_value={"a": 1})
None if task_queue else mock.CoroutineMock(return_value={"a": 1})
),
)

Expand Down Expand Up @@ -165,16 +159,16 @@ async def test_start_stop(self):
server = self.get_admin_server(settings)
await server.start()
assert server.app._client_max_size == 4 * 1024 * 1024
with async_mock.patch.object(
server, "websocket_queues", async_mock.MagicMock()
with mock.patch.object(
server, "websocket_queues", mock.MagicMock()
) as mock_wsq:
mock_wsq.values = async_mock.MagicMock(
return_value=[async_mock.MagicMock(stop=async_mock.MagicMock())]
mock_wsq.values = mock.MagicMock(
return_value=[mock.MagicMock(stop=mock.MagicMock())]
)
await server.stop()

with async_mock.patch.object(
web.TCPSite, "start", async_mock.AsyncMock()
with mock.patch.object(
web.TCPSite, "start", mock.CoroutineMock()
) as mock_start:
mock_start.side_effect = OSError("Failure to launch")
with self.assertRaises(AdminSetupError):
Expand All @@ -199,7 +193,7 @@ async def test_import_routes_multitenant_middleware(self):
context.injector.bind_instance(GoalCodeRegistry, GoalCodeRegistry())
context.injector.bind_instance(
test_module.BaseMultitenantManager,
async_mock.MagicMock(spec=test_module.BaseMultitenantManager),
mock.MagicMock(spec=test_module.BaseMultitenantManager),
)
await DefaultContextBuilder().load_plugins(context)
server = self.get_admin_server(
Expand All @@ -220,66 +214,66 @@ async def test_import_routes_multitenant_middleware(self):
m for m in app.middlewares if ".check_multitenant_authorization" in str(m)
]

mock_request = async_mock.MagicMock(
mock_request = mock.MagicMock(
method="GET",
headers={"Authorization": "Bearer ..."},
path="/multitenancy/etc",
text=async_mock.AsyncMock(return_value="abc123"),
text=mock.CoroutineMock(return_value="abc123"),
)
with self.assertRaises(test_module.web.HTTPUnauthorized):
await mt_authz_middle(mock_request, None)

mock_request = async_mock.MagicMock(
mock_request = mock.MagicMock(
method="GET",
headers={},
path="/protected/non-multitenancy/non-server",
text=async_mock.AsyncMock(return_value="abc123"),
text=mock.CoroutineMock(return_value="abc123"),
)
with self.assertRaises(test_module.web.HTTPUnauthorized):
await mt_authz_middle(mock_request, None)

mock_request = async_mock.MagicMock(
mock_request = mock.MagicMock(
method="GET",
headers={"Authorization": "Bearer ..."},
path="/protected/non-multitenancy/non-server",
text=async_mock.AsyncMock(return_value="abc123"),
text=mock.CoroutineMock(return_value="abc123"),
)
mock_handler = async_mock.AsyncMock()
mock_handler = mock.CoroutineMock()
await mt_authz_middle(mock_request, mock_handler)
assert mock_handler.called_once_with(mock_request)
mock_handler.assert_called_once_with(mock_request)

mock_request = async_mock.MagicMock(
mock_request = mock.MagicMock(
method="GET",
headers={"Authorization": "Non-bearer ..."},
path="/test",
text=async_mock.AsyncMock(return_value="abc123"),
text=mock.CoroutineMock(return_value="abc123"),
)
mock_handler = async_mock.AsyncMock()
mock_handler = mock.CoroutineMock()
await mt_authz_middle(mock_request, mock_handler)
assert mock_handler.called_once_with(mock_request)
mock_handler.assert_called_once_with(mock_request)

# multitenant setup context exception paths
[setup_ctx_middle] = [m for m in app.middlewares if ".setup_context" in str(m)]

mock_request = async_mock.MagicMock(
mock_request = mock.MagicMock(
method="GET",
headers={"Authorization": "Non-bearer ..."},
path="/protected/non-multitenancy/non-server",
text=async_mock.AsyncMock(return_value="abc123"),
text=mock.CoroutineMock(return_value="abc123"),
)
with self.assertRaises(test_module.web.HTTPUnauthorized):
await setup_ctx_middle(mock_request, None)

mock_request = async_mock.MagicMock(
mock_request = mock.MagicMock(
method="GET",
headers={"Authorization": "Bearer ..."},
path="/protected/non-multitenancy/non-server",
text=async_mock.AsyncMock(return_value="abc123"),
text=mock.CoroutineMock(return_value="abc123"),
)
with async_mock.patch.object(
with mock.patch.object(
server.multitenant_manager,
"get_profile_for_token",
async_mock.AsyncMock(),
mock.CoroutineMock(),
) as mock_get_profile:
mock_get_profile.side_effect = [
test_module.MultitenantManagerError("corrupt token"),
Expand Down Expand Up @@ -493,8 +487,8 @@ async def server():
)
async def test_on_record_event(server, event_topic, webhook_topic):
profile = InMemoryProfile.test_profile()
with async_mock.patch.object(
server, "send_webhook", async_mock.AsyncMock()
with mock.patch.object(
server, "send_webhook", mock.CoroutineMock()
) as mock_send_webhook:
await server._on_record_event(profile, Event(event_topic, None))
mock_send_webhook.assert_called_once_with(profile, webhook_topic, None)
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudagent/admin/tests/test_request_context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from asynctest import TestCase as AsyncTestCase
from unittest import IsolatedAsyncioTestCase

from ...core.in_memory import InMemoryProfile
from ...core.profile import ProfileSession
Expand All @@ -7,7 +7,7 @@
from .. import request_context as test_module


class TestAdminRequestContext(AsyncTestCase):
class TestAdminRequestContext(IsolatedAsyncioTestCase):
def setUp(self):
self.ctx = test_module.AdminRequestContext(InMemoryProfile.test_profile())
assert self.ctx.__class__.__name__ in str(self.ctx)
Expand Down
18 changes: 9 additions & 9 deletions aries_cloudagent/askar/didcomm/tests/test_v2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json

from asynctest import mock as async_mock
from unittest import mock
import pytest

from aries_askar import AskarError, Key, KeyAlg, Session
Expand Down Expand Up @@ -70,19 +70,19 @@ async def test_es_encrypt_x(self, session: Session):
):
_ = test_module.ecdh_es_encrypt({}, MESSAGE)

with async_mock.patch(
with mock.patch(
"aries_askar.Key.generate",
async_mock.MagicMock(side_effect=AskarError(99, "")),
mock.MagicMock(side_effect=AskarError(99, "")),
):
with pytest.raises(
test_module.DidcommEnvelopeError,
match="Error creating content encryption key",
):
_ = test_module.ecdh_es_encrypt({BOB_KID: bob_pk}, MESSAGE)

with async_mock.patch(
with mock.patch(
"aries_askar.Key.aead_encrypt",
async_mock.MagicMock(side_effect=AskarError(99, "")),
mock.MagicMock(side_effect=AskarError(99, "")),
):
with pytest.raises(
test_module.DidcommEnvelopeError,
Expand Down Expand Up @@ -188,9 +188,9 @@ async def test_1pu_encrypt_x(self, session: Session):
{BOB_KID: bob_pk, "alt": alt_pk}, ALICE_KID, alice_sk, MESSAGE
)

with async_mock.patch(
with mock.patch(
"aries_askar.Key.generate",
async_mock.MagicMock(side_effect=AskarError(99, "")),
mock.MagicMock(side_effect=AskarError(99, "")),
):
with pytest.raises(
test_module.DidcommEnvelopeError,
Expand All @@ -200,9 +200,9 @@ async def test_1pu_encrypt_x(self, session: Session):
{BOB_KID: bob_pk}, ALICE_KID, alice_sk, MESSAGE
)

with async_mock.patch(
with mock.patch(
"aries_askar.Key.aead_encrypt",
async_mock.MagicMock(side_effect=AskarError(99, "")),
mock.MagicMock(side_effect=AskarError(99, "")),
):
with pytest.raises(
test_module.DidcommEnvelopeError,
Expand Down
2 changes: 1 addition & 1 deletion aries_cloudagent/askar/tests/test_profile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import pytest

from asynctest import mock
from unittest import mock

from ...askar.profile import AskarProfile
from ...config.injection_context import InjectionContext
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudagent/askar/tests/test_store.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from asynctest import TestCase as AsyncTestCase
from unittest import IsolatedAsyncioTestCase

from ...core.error import ProfileError

from ..store import AskarStoreConfig


class TestStoreConfig(AsyncTestCase):
class TestStoreConfig(IsolatedAsyncioTestCase):
key_derivation_method = "Raw"
key = "key"
storage_type = "postgres"
Expand Down
Loading
Loading