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 #2

Open
wants to merge 145 commits into
base: init-agent-hj
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
7c03456
fix: problem report handler for connection specific problems
dbluhm Aug 17, 2021
62c23f3
Merge pull request #1356 from dbluhm/fix/connection-problem-report
andrewwhitehead Aug 18, 2021
257b686
Updates to the Read The Docs for 0.7.0/1
swcurran Aug 19, 2021
6e11786
Two more tweaks to improve the RTD process -- almost there
swcurran Aug 19, 2021
0f0d586
Remove whitespace to fix agent build
swcurran Aug 19, 2021
fadbbb5
fix: error not raised in predicate timestamp check
dbluhm Aug 20, 2021
6afe42f
test: check timestamp newly raised error
dbluhm Aug 20, 2021
feef78a
Merge pull request #1364 from dbluhm/fix/predicate-timestamp-check
andrewwhitehead Aug 20, 2021
dcedf1c
fix warnings; __all__ must contain strings
andrewwhitehead Aug 21, 2021
110b6d2
Merge branch 'main' into rtd-updates
andrewwhitehead Aug 21, 2021
55cb279
Merge pull request #1359 from swcurran/rtd-updates
swcurran Aug 22, 2021
49f707e
rename files to avoid ambiguity in docs
andrewwhitehead Aug 22, 2021
e853da2
clean up warnings during unit tests
andrewwhitehead Aug 22, 2021
b2cbbec
feat(IDENT-3086): Add Askar profile manager
acuderman Aug 16, 2021
cd08c18
fix(IDENT-3086): export Multitenant manager error outside base
acuderman Aug 16, 2021
3a94c51
fix(I-3086: remove __init__.py file
acuderman Aug 17, 2021
3babe95
test(IDENT-3086): Add tests for multi-tenancy managers
acuderman Aug 17, 2021
19c76aa
Added CLI arguments parsing
Aug 17, 2021
b1d70b2
test(IDENT-3086): Cover create_profile path and custom wallet name
acuderman Aug 17, 2021
c9ff3ac
style(IDENT-3086): fix lint issues
acuderman Aug 17, 2021
0e4ec1a
style(IDENT-3086): prettify assertions
acuderman Aug 17, 2021
79c539a
feat (IDENT-3083): multitenant provider
LisandroV Aug 18, 2021
c6891e9
Added example for CLI param
Aug 18, 2021
a4a821d
test(IDENT-3086): Add profile type check
acuderman Aug 18, 2021
ee6bbd0
fix(IDENT-3086): remove unneeded loggers
acuderman Aug 18, 2021
3fc6056
fix(IDENT-3086): await create_profile call
acuderman Aug 18, 2021
ab7e91d
Updated params description and no jwt param test
Aug 18, 2021
a4b07fd
Removed multitenant admin CLI param from test
Aug 18, 2021
fe7eda2
test(IDENT-3086): Set async method as create_profile stub
acuderman Aug 18, 2021
dbc3530
style(IDENT-3086): Removed unused imports & variable rename
acuderman Aug 18, 2021
95e1b70
fix (IDENT-3083): store provided instances
LisandroV Aug 18, 2021
859a6b6
feat(IDENT-3101): added support for raw key derivation from args
MaticDiba Aug 19, 2021
c5034dd
fix(IDENT-3083): Move manager_type init in lower scope
acuderman Aug 19, 2021
25071a0
feat IDENT-3072: adding walletid to profiles
zanost Aug 19, 2021
623f537
fix IDENT-3072: restoring run_test script
zanost Aug 19, 2021
e62241d
fix IDENT-3072: restoring run_test script
zanost Aug 19, 2021
b900afb
test(IDENT-3101): updated tests with newline. moved repeated values i…
MaticDiba Aug 19, 2021
8bb76ee
feat IDENT-3072:reanaming, fixing tests
zanost Aug 20, 2021
20f1edf
test IDENT-3072: removing none from test
zanost Aug 20, 2021
bd3d34b
test IDENT-3072: fixed var name
zanost Aug 20, 2021
8e18be1
Solved conflicts
Aug 20, 2021
7e060b9
Merge pull request #5 from zanost/IDENT-3072-walletID-on-profile
zanost Aug 20, 2021
f6ef539
Rmoved unneded stub setup and empty lines
Aug 20, 2021
bfba904
Merge branch 'feat-IDENT-3049-multitenancy-with-single-wallet' of git…
Aug 20, 2021
6a2b15b
Changed assert to check called with
Aug 20, 2021
4a495ce
Merge pull request #6 from globalid/IDENT-3075-fix-update-remove-methods
dejsenlitro Aug 20, 2021
36573b7
fix(IDENT-3049): fixed error that prevented acapy to run
MaticDiba Aug 20, 2021
fe5ac5f
fix(IDENT-3049): fixed errors in tests
MaticDiba Aug 20, 2021
4ffe013
feat(IDENT-3049): manager type changed
MaticDiba Aug 20, 2021
6938977
Updates to eliminate warnings on RTD doc generation
swcurran Aug 23, 2021
a304568
Merge pull request #1366 from andrewwhitehead/rtd-renames
andrewwhitehead Aug 23, 2021
cd1294b
Merge branch 'main' into rtd-updates-071
swcurran Aug 23, 2021
f20fb6e
Remove mocks from two internal modules
swcurran Aug 23, 2021
b333efe
Merge https://github.com/hyperledger/aries-cloudagent-python into fea…
acuderman Aug 24, 2021
3bcc443
updated to include timezone in proof
shaangill025 Aug 24, 2021
402e0b8
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 Aug 24, 2021
761155b
Merge pull request #1373 from shaangill025/issue_cred
ianco Aug 24, 2021
f752c28
Merge branch 'main' into rtd-updates-071
ianco Aug 24, 2021
39b0a8a
Merge pull request #1371 from swcurran/rtd-updates-071
ianco Aug 24, 2021
5c18e5c
Change log for 0.7.1 and update version
swcurran Aug 24, 2021
26cfea3
Merge branch 'main' into release-071-rc0
swcurran Aug 24, 2021
3f00929
fix: refine typing on base record
dbluhm Aug 24, 2021
99093a7
Merge pull request #1374 from swcurran/release-071-rc0
ianco Aug 24, 2021
aeb9690
feat: add inject_or
dbluhm Aug 24, 2021
5bbc5c0
Merge branch 'main' into fix/injector-typing
dbluhm Aug 24, 2021
bbf2373
Merge branch 'main' into fix/base-record-typing
dbluhm Aug 24, 2021
5d370a3
fix(IDENT-3049): Fix lint issues
acuderman Aug 25, 2021
4216f39
Merge https://github.com/hyperledger/aries-cloudagent-python into fea…
acuderman Aug 25, 2021
9a4967b
fix: send proposal schema
TimoGlastra Aug 25, 2021
a98ddf8
Merge branch 'main' into fix/send-proposal-schema
TimoGlastra Aug 25, 2021
0d79a0c
Merge pull request #1377 from TimoGlastra/fix/send-proposal-schema
swcurran Aug 25, 2021
5a8e6ea
Merge branch 'main' into feat-IDENT-3049-multitenancy-single-wallet
acuderman Aug 25, 2021
418130a
Allow underscore (`_`) character in endpoints
Fethbita Aug 25, 2021
edf7f33
Generate OpenAPI spec for new change
Fethbita Aug 25, 2021
eff7cbf
Refactor existing code to write wallet non secrets records for schema…
ianco Aug 27, 2021
2221a7f
Initial endpoints to fix non-secrets records
ianco Aug 27, 2021
1f77873
Fix formatting
ianco Aug 27, 2021
4f7d035
Check for duplicate records
ianco Aug 28, 2021
5ac6f6c
Formatting
ianco Aug 28, 2021
d30f52d
Merge branch 'main' into fix/base-record-typing
dbluhm Aug 31, 2021
50979ea
Merge branch 'main' into fix/injector-typing
dbluhm Aug 31, 2021
a4193c6
refactor: add inject_or to various inject capable components
dbluhm Aug 31, 2021
300da6d
refactor: use inject_or instead of inject(..., required=False)
dbluhm Aug 31, 2021
de43a5d
fix: instances of inject(..., required=True)
dbluhm Aug 31, 2021
e42bcf0
fix: injected falsey values not returning from injector
dbluhm Aug 31, 2021
4d27006
Merge pull request #1375 from dbluhm/fix/base-record-typing
andrewwhitehead Aug 31, 2021
d6571fb
Merge branch 'main' into main
andrewwhitehead Aug 31, 2021
06e01d0
Merge branch 'main' into write-schema-cred-def-non-secrets
ianco Aug 31, 2021
c413fab
Merge pull request #1379 from ianco/write-schema-cred-def-non-secrets
ianco Aug 31, 2021
f4981b9
Merge branch 'main' into main
ianco Aug 31, 2021
0485eda
Merge branch 'main' into fix/injector-typing
dbluhm Aug 31, 2021
102d9f1
Merge pull request #1378 from Fethbita/main
andrewwhitehead Aug 31, 2021
28ae318
Merge branch 'main' into fix/injector-typing
andrewwhitehead Aug 31, 2021
040b2f7
Merge pull request #1376 from dbluhm/fix/injector-typing
andrewwhitehead Aug 31, 2021
87603aa
update minimum shared components versions
andrewwhitehead Aug 31, 2021
4bba59d
use non-changing example dates in schemas; update open-api.json
andrewwhitehead Aug 31, 2021
814a940
update version to 0.7.1
andrewwhitehead Aug 31, 2021
1a4df0a
Merge pull request #1380 from andrewwhitehead/pre-release-0.7.1
andrewwhitehead Aug 31, 2021
6098bea
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
Sep 1, 2021
393c987
IDENT-3076: Removed unneded function and changed multitenancy manager…
Sep 1, 2021
3a52e58
Merge pull request #10 from globalid/IDENT-3076
vidp1 Sep 1, 2021
83b8381
Remove connection check on proof verify
ianco Sep 1, 2021
42fadfb
Oops removed too many tests
ianco Sep 1, 2021
f70e454
Merge pull request #1383 from ianco/proof-verify
andrewwhitehead Sep 1, 2021
a9fab19
fix(IDENT-3049): Separate aries profile id from wallet.id
acuderman Sep 1, 2021
9c59708
fix(IDENT-3049): Fix lint
acuderman Sep 1, 2021
b114373
Remove connection check on proof verify
ianco Sep 1, 2021
8f1b357
Oops removed too many tests
ianco Sep 1, 2021
b9d495c
fix(IDENT-3049): Fix profile remove method
acuderman Sep 2, 2021
434401f
Merge branch 'main' into feat-IDENT-3049-multitenancy-single-wallet
acuderman Sep 2, 2021
f12df9d
Refactoring step before introducing changes in mediation connection
chumbert Sep 1, 2021
aeac58b
fix: don't require push on outbound queue implementations
dbluhm Sep 2, 2021
53878e7
Merge pull request #1387 from dbluhm/fix/queue-base-push
andrewwhitehead Sep 2, 2021
c57aa2f
fix: typo in connection static result schema
dbluhm Sep 2, 2021
ee301d7
Merge branch 'main' into oob-connection-manager-api-alignment
dbluhm Sep 2, 2021
ef8004a
Refactoring in prep for adding connectionless proof demo
ianco Sep 2, 2021
b8ca1da
Merge pull request #1382 from sicpa-dlab/oob-connection-manager-api-a…
andrewwhitehead Sep 2, 2021
43e715a
Merge branch 'main' into fix/connection-static-result-typo
andrewwhitehead Sep 2, 2021
2f358df
Merge pull request #1389 from dbluhm/fix/connection-static-result-typo
andrewwhitehead Sep 2, 2021
6f11f6c
Merge branch 'main' into feat-IDENT-3049-multitenancy-single-wallet
acuderman Sep 3, 2021
adbaa42
fix: return type of inject
dbluhm Sep 3, 2021
cc70744
Merge pull request #1368 from globalid/feat-IDENT-3049-multitenancy-s…
andrewwhitehead Sep 3, 2021
7490875
add no-op handler for generic ack message (RFC 0015)
andrewwhitehead Sep 3, 2021
0baa310
Merge branch 'main' into fix/inject-return-type
dbluhm Sep 3, 2021
820971f
Merge pull request #1390 from andrewwhitehead/feat/recv-ack
swcurran Sep 3, 2021
504a3d0
Merge branch 'main' into fix/inject-return-type
andrewwhitehead Sep 3, 2021
136bed7
Merge pull request #1392 from dbluhm/fix/inject-return-type
andrewwhitehead Sep 3, 2021
b222937
import cleanups
andrewwhitehead Sep 3, 2021
515db7e
Merge pull request #1393 from andrewwhitehead/cleanups
swcurran Sep 3, 2021
89426ab
Add connectionless proof request support
ianco Sep 3, 2021
ebfb22c
Display url's
ianco Sep 3, 2021
cf70c69
Fix url for qr code
ianco Sep 7, 2021
aadcec9
Fix url for qr code
ianco Sep 7, 2021
58bd7a5
Fix url's for proof request
ianco Sep 7, 2021
6b3d871
Use birth date instead of age in cred and proof request
ianco Sep 7, 2021
6a36213
Update some docs
ianco Sep 7, 2021
ced0ce9
Update some docs
ianco Sep 7, 2021
8b3f83e
Merge remote-tracking branch 'upstream/main' into connectionless-proo…
ianco Sep 7, 2021
38ae87e
Run integration tests using external ledger and tails server
ianco Sep 7, 2021
a583b34
Run integration tests using external ledger and tails server
ianco Sep 7, 2021
d307b13
Run integration tests using external ledger and tails server
ianco Sep 7, 2021
46729f0
Merge pull request #1400 from ianco/master
andrewwhitehead Sep 8, 2021
c22988b
Merge branch 'main' into connectionless-proof-demo
ianco Sep 8, 2021
32e7014
Merge pull request #1395 from ianco/connectionless-proof-demo
ianco Sep 8, 2021
df0fb87
Merge branch 'init-agent-hj' into merge-0909
timo-kang Sep 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/integrationtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
uses: actions/checkout@v2
with:
path: acapy
- name: run-von-network
uses: ./acapy/actions/run-von-network
- name: run-indy-tails-server
uses: ./acapy/actions/run-indy-tails-server
#- name: run-von-network
# uses: ./acapy/actions/run-von-network
#- name: run-indy-tails-server
# uses: ./acapy/actions/run-indy-tails-server
- name: run-integration-tests
uses: ./acapy/actions/run-integration-tests
# to run with a specific set of tests include the following parameter:
Expand Down
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
# 0.7.1

## August 31, 2021

A relatively minor maintenance release to address issues found since the 0.7.0 Release.
Includes some cleanups of JSON-LD Verifiable Credentials and Verifiable Presentations

- W3C Verifiable Credential cleanups
- Timezone inclusion [ISO 8601] for W3C VC and Proofs ([#1373](https://github.com/hyperledger/aries-cloudagent-python/pull/1373))
- W3C VC handling where attachment is JSON and not Base64 encoded ([#1352](https://github.com/hyperledger/aries-cloudagent-python/pull/1352))
- Refactor outbound queue interface ([#1348](https://github.com/hyperledger/aries-cloudagent-python/pull/1348))
- Command line parameter handling for arbitrary plugins ([#1347](https://github.com/hyperledger/aries-cloudagent-python/pull/1347))
- Add an optional parameter '--ledger-socks-proxy' ([#1342](https://github.com/hyperledger/aries-cloudagent-python/pull/1342))
- OOB Protocol - CredentialOffer Support ([#1316](https://github.com/hyperledger/aries-cloudagent-python/pull/1316)), ([#1216](https://github.com/hyperledger/aries-cloudagent-python/pull/1216))
- Updated IndyCredPrecisSchema - pres_referents renamed to presentation_referents ([#1334](https://github.com/hyperledger/aries-cloudagent-python/pull/1334))
- Handle unpadded protected header in PackWireFormat::get_recipient_keys ([#1324](https://github.com/hyperledger/aries-cloudagent-python/pull/1324))
- Initial cut of OpenAPI Code Generation guidelines ([#1339](https://github.com/hyperledger/aries-cloudagent-python/pull/1339))
- Correct revocation API in credential revocation documentation ([#612](https://github.com/hyperledger/aries-cloudagent-python/pull/612))
- Documentation updates for Read-The-Docs ([#1359](https://github.com/hyperledger/aries-cloudagent-python/pull/1359),
[#1366](https://github.com/hyperledger/aries-cloudagent-python/pull/1366), [#1371](https://github.com/hyperledger/aries-cloudagent-python/pull/1371))
- Add `inject_or` method to dynamic injection framework to resolve typing ambiguity ([#1376](https://github.com/hyperledger/aries-cloudagent-python/pull/1376))
- Other fixes:
- Indy Proof processing fix, error not raised in predicate timestamp check ([#1364](https://github.com/hyperledger/aries-cloudagent-python/pull/1364))
- Problem Report handler for connection specific problems ([#1356](https://github.com/hyperledger/aries-cloudagent-python/pull/1356))
- fix: error on deserializing conn record with protocol ([#1325](https://github.com/hyperledger/aries-cloudagent-python/pull/1325))
- fix: failure to verify jsonld on non-conformant doc but vaild vmethod ([#1301](https://github.com/hyperledger/aries-cloudagent-python/pull/1301))
- fix: allow underscore in endpoints ([#1378](https://github.com/hyperledger/aries-cloudagent-python/pull/1378))


# 0.7.0

## July 14, 2021
Expand Down
10 changes: 9 additions & 1 deletion actions/run-integration-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@ inputs:
description: "Set of flags that defines the test scope"
required: false
default: "-t @GHA"
IN_LEDGER_URL:
description: "URL to the von network ledger browser"
required: false
default: "http://test.bcovrin.vonx.io"
IN_PUBLIC_TAILS_URL:
description: "URL to the tails server"
required: false
default: "https://tails.vonx.io"
runs:
using: "composite"
steps:
- name: run-integration-tests-acapy
# to run with external ledger and tails server run as follows (and remove the ledger and tails actions from the workflow):
# run: LEDGER_URL=http://test.bcovrin.vonx.io PUBLIC_TAILS_URL=https://tails.vonx.io ./run_bdd ${{ inputs.TEST_SCOPE }}
run: ./run_bdd ${{ inputs.TEST_SCOPE }}
run: LEDGER_URL=${{inputs.IN_LEDGER_URL}} PUBLIC_TAILS_URL=${{inputs.IN_PUBLIC_TAILS_URL}} ./run_bdd ${{ inputs.TEST_SCOPE }}
shell: bash
env:
NO_TTY: "1"
Expand Down
41 changes: 34 additions & 7 deletions aries_cloudagent/admin/request_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ def inject(
self,
base_cls: Type[InjectType],
settings: Mapping[str, object] = None,
*,
required: bool = True
) -> Optional[InjectType]:
) -> InjectType:
"""
Get the provided instance of a given class identifier.

Expand All @@ -75,7 +73,27 @@ def inject(
An instance of the base class, or None

"""
return self._context.inject(base_cls, settings, required=required)
return self._context.inject(base_cls, settings)

def inject_or(
self,
base_cls: Type[InjectType],
settings: Mapping[str, object] = None,
default: Optional[InjectType] = None,
) -> Optional[InjectType]:
"""
Get the provided instance of a given class identifier or default if not found.

Args:
base_cls: The base class to retrieve an instance of
settings: An optional dict providing configuration to the provider
default: default return value if no instance is found

Returns:
An instance of the base class, or None

"""
return self._context.inject_or(base_cls, settings, default)

def update_settings(self, settings: Mapping[str, object]):
"""Update the current scope with additional settings."""
Expand All @@ -96,17 +114,26 @@ def test_context(
def _test_session(self) -> ProfileSession:
session = self.profile.session(self._context)

def _inject(base_cls, required=True):
def _inject(base_cls):
if session._active and base_cls in self.session_inject:
ret = self.session_inject[base_cls]
if ret is None and required:
if ret is None:
raise InjectionError(
"No instance provided for class: {}".format(base_cls.__name__)
)
return ret
return session._context.injector.inject(base_cls, required=required)
return session._context.injector.inject(base_cls)

def _inject_or(base_cls, default=None):
if session._active and base_cls in self.session_inject:
ret = self.session_inject[base_cls]
if ret is None:
ret = default
return ret
return session._context.injector.inject_or(base_cls, default)

setattr(session, "inject", _inject)
setattr(session, "inject_or", _inject_or)
return session

def __repr__(self) -> str:
Expand Down
18 changes: 9 additions & 9 deletions aries_cloudagent/admin/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from ..ledger.error import LedgerConfigError, LedgerTransactionError
from ..messaging.models.openapi import OpenAPISchema
from ..messaging.responder import BaseResponder
from ..multitenant.manager import MultitenantManager, MultitenantManagerError
from ..multitenant.base import BaseMultitenantManager, MultitenantManagerError
from ..storage.error import StorageNotFoundError
from ..transport.outbound.message import OutboundMessage
from ..transport.outbound.status import OutboundSendStatus
Expand Down Expand Up @@ -251,7 +251,7 @@ def __init__(
self.webhook_router = webhook_router
self.websocket_queues = {}
self.site = None
self.multitenant_manager = context.inject(MultitenantManager, required=False)
self.multitenant_manager = context.inject_or(BaseMultitenantManager)

self.server_paths = []

Expand Down Expand Up @@ -293,7 +293,7 @@ async def check_token(request: web.Request, handler):

middlewares.append(check_token)

collector = self.context.inject(Collector, required=False)
collector = self.context.inject_or(Collector)

if self.multitenant_manager:

Expand Down Expand Up @@ -393,7 +393,7 @@ async def setup_context(request: web.Request, handler):
self.server_paths = [route.path for route in server_routes]
app.add_routes(server_routes)

plugin_registry = self.context.inject(PluginRegistry, required=False)
plugin_registry = self.context.inject_or(PluginRegistry)
if plugin_registry:
await plugin_registry.register_admin_routes(app)

Expand Down Expand Up @@ -445,11 +445,11 @@ def sort_dict(raw: dict) -> dict:
runner = web.AppRunner(self.app)
await runner.setup()

plugin_registry = self.context.inject(PluginRegistry, required=False)
plugin_registry = self.context.inject_or(PluginRegistry)
if plugin_registry:
plugin_registry.post_process_routes(self.app)

event_bus = self.context.inject(EventBus, required=False)
event_bus = self.context.inject_or(EventBus)
if event_bus:
event_bus.subscribe(EVENT_PATTERN_WEBHOOK, self._on_webhook_event)
event_bus.subscribe(EVENT_PATTERN_RECORD, self._on_record_event)
Expand Down Expand Up @@ -548,7 +548,7 @@ async def plugins_handler(self, request: web.BaseRequest):
The module list response

"""
registry = self.context.inject(PluginRegistry, required=False)
registry = self.context.inject_or(PluginRegistry)
plugins = registry and sorted(registry.plugin_names) or []
return web.json_response({"result": plugins})

Expand Down Expand Up @@ -602,7 +602,7 @@ async def status_handler(self, request: web.BaseRequest):
"""
status = {"version": __version__}
status["label"] = self.context.settings.get("default_label")
collector = self.context.inject(Collector, required=False)
collector = self.context.inject_or(Collector)
if collector:
status["timing"] = collector.results
if self.conductor_stats:
Expand All @@ -622,7 +622,7 @@ async def status_reset_handler(self, request: web.BaseRequest):
The web response

"""
collector = self.context.inject(Collector, required=False)
collector = self.context.inject_or(Collector)
if collector:
collector.reset()
return web.json_response({})
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudagent/admin/tests/test_admin_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ async def test_import_routes_multitenant_middleware(self):
context.injector.bind_instance(ProtocolRegistry, ProtocolRegistry())
profile = InMemoryProfile.test_profile()
context.injector.bind_instance(
test_module.MultitenantManager,
test_module.MultitenantManager(profile),
test_module.BaseMultitenantManager,
test_module.BaseMultitenantManager(profile),
)
await DefaultContextBuilder().load_plugins(context)
server = self.get_admin_server(
Expand Down
2 changes: 1 addition & 1 deletion aries_cloudagent/admin/tests/test_request_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ async def test_session_inject_x(self):
test_ctx = test_module.AdminRequestContext.test_context({Collector: None})
async with test_ctx.session() as test_sesn:
with self.assertRaises(test_module.InjectionError):
test_sesn.inject(Collector, required=True)
test_sesn.inject(Collector)
12 changes: 9 additions & 3 deletions aries_cloudagent/askar/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ def store(self) -> Store:
"""Accessor for the opened Store instance."""
return self.opened.store

async def remove(self):
"""Remove the profile."""
if self.settings.get("multitenant.wallet_type") == "askar-profile":
await self.store.remove_profile(self.settings.get("wallet.askar_profile"))

def init_ledger_pool(self):
"""Initialize the ledger pool."""
if self.settings.get("ledger.disabled"):
Expand All @@ -67,7 +72,7 @@ def init_ledger_pool(self):
if read_only:
LOGGER.error("Note: setting ledger to read-only mode")
genesis_transactions = self.settings.get("ledger.genesis_transactions")
cache = self.context.injector.inject(BaseCache, required=False)
cache = self.context.injector.inject_or(BaseCache)
self.ledger_pool = IndyVdrLedgerPool(
pool_name,
keepalive=keepalive,
Expand Down Expand Up @@ -154,10 +159,11 @@ def __init__(
):
"""Create a new IndySdkProfileSession instance."""
super().__init__(profile=profile, context=context, settings=settings)
profile_id = profile.context.settings.get("wallet.askar_profile")
if is_txn:
self._opener = self.profile.store.transaction()
self._opener = self.profile.store.transaction(profile_id)
else:
self._opener = self.profile.store.session()
self._opener = self.profile.store.session(profile_id)
self._handle: Session = None
self._acquire_start: float = None
self._acquire_end: float = None
Expand Down
9 changes: 9 additions & 0 deletions aries_cloudagent/askar/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ def __init__(self, config: dict = None):
self.key_derivation_method = (
config.get("key_derivation_method") or self.DEFAULT_KEY_DERIVATION
)

if (
self.key_derivation_method.lower() == self.KEY_DERIVATION_RAW.lower()
and self.key == ""
):
raise ProfileError(
f"With key derivation method '{self.KEY_DERIVATION_RAW}',"
"key should also be provided"
)
# self.rekey = config.get("rekey")
# self.rekey_derivation_method = config.get("rekey_derivation_method")

Expand Down
86 changes: 86 additions & 0 deletions aries_cloudagent/askar/tests/test_profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import asyncio
import pytest

from asynctest import TestCase as AsyncTestCase, mock

from ...askar.profile import AskarProfile
from ...config.injection_context import InjectionContext

from .. import profile as test_module


class TestProfile(AsyncTestCase):
@mock.patch("aries_cloudagent.askar.store.AskarOpenStore")
async def test_init_success(self, AskarOpenStore):
askar_profile = AskarProfile(
AskarOpenStore,
)

assert askar_profile.opened == AskarOpenStore

@mock.patch("aries_cloudagent.askar.store.AskarOpenStore")
async def test_remove_success(self, AskarOpenStore):
openStore = AskarOpenStore
context = InjectionContext()
profile_id = "profile_id"
context.settings = {
"multitenant.wallet_type": "askar-profile",
"wallet.askar_profile": profile_id,
}
askar_profile = AskarProfile(openStore, context)
remove_profile_stub = asyncio.Future()
remove_profile_stub.set_result(True)
openStore.store.remove_profile.return_value = remove_profile_stub

await askar_profile.remove()

openStore.store.remove_profile.assert_called_once_with(profile_id)

@mock.patch("aries_cloudagent.askar.store.AskarOpenStore")
async def test_remove_profile_not_removed_if_wallet_type_not_askar_profile(
self, AskarOpenStore
):
openStore = AskarOpenStore
context = InjectionContext()
context.settings = {"multitenant.wallet_type": "basic"}
askar_profile = AskarProfile(openStore, context)

await askar_profile.remove()

openStore.store.remove_profile.assert_not_called()

@pytest.mark.asyncio
async def test_profile_manager_transaction(self):
profile = "profileId"

with mock.patch("aries_cloudagent.askar.profile.AskarProfile") as AskarProfile:
askar_profile = AskarProfile(None, True)
askar_profile_transaction = mock.MagicMock()
askar_profile.store.transaction.return_value = askar_profile_transaction
askar_profile.context.settings.get.return_value = profile

transactionProfile = test_module.AskarProfileSession(askar_profile, True)

assert transactionProfile._opener == askar_profile_transaction
askar_profile.context.settings.get.assert_called_once_with(
"wallet.askar_profile"
)
askar_profile.store.transaction.assert_called_once_with(profile)

@pytest.mark.asyncio
async def test_profile_manager_store(self):
profile = "profileId"

with mock.patch("aries_cloudagent.askar.profile.AskarProfile") as AskarProfile:
askar_profile = AskarProfile(None, False)
askar_profile_session = mock.MagicMock()
askar_profile.store.session.return_value = askar_profile_session
askar_profile.context.settings.get.return_value = profile

sessionProfile = test_module.AskarProfileSession(askar_profile, False)

assert sessionProfile._opener == askar_profile_session
askar_profile.context.settings.get.assert_called_once_with(
"wallet.askar_profile"
)
askar_profile.store.session.assert_called_once_with(profile)
Loading