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

Allow Configuration Settings on a per-tenant basis #2233

Merged
merged 12 commits into from
Jun 28, 2023
32 changes: 16 additions & 16 deletions Multitenancy.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,22 +383,22 @@ To allow configurablity of ACA-Py startup parameters/environment variables at a

| Labels | | Setting |
|---|---|---|
| ACAPY_LOG_LEVEL | log_level | log.level |
| ACAPY_INVITE_PUBLIC | invite_public | debug.invite_public |
| ACAPY_PUBLIC_INVITES | public_invites | public_invites |
| ACAPY_AUTO_ACCEPT_INVITES | auto_accept_invites | debug.auto_accept_invites |
| ACAPY_AUTO_ACCEPT_REQUESTS | auto_accept_requests | debug.auto_accept_requests |
| ACAPY_AUTO_PING_CONNECTION | auto_ping_connection | auto_ping_connection |
| ACAPY_MONITOR_PING | monitor_ping | debug.monitor_ping |
| ACAPY_AUTO_RESPOND_MESSAGES | auto_respond_messages | debug.auto_respond_messages |
| ACAPY_AUTO_RESPOND_CREDENTIAL_OFFER | auto_respond_credential_offer | debug.auto_resopnd_credential_offer |
| ACAPY_AUTO_RESPOND_CREDENTIAL_REQUEST | auto_respond_credential_request | debug.auto_respond_credential_request |
| ACAPY_AUTO_VERIFY_PRESENTATION | auto_verify_presentation | debug.auto_verify_presentation |
| ACAPY_NOTIFY_REVOCATION | notify_revocation | revocation.notify |
| ACAPY_AUTO_REQUEST_ENDORSEMENT | auto_request_endorsement | endorser.auto_request |
| ACAPY_AUTO_WRITE_TRANSACTIONS | auto_write_transactions | endorser.auto_write |
| ACAPY_CREATE_REVOCATION_TRANSACTIONS | auto_create_revocation_transactions | endorser.auto_create_rev_reg |
| ACAPY_ENDORSER_ROLE | endorser_protocol_role | endorser.protocol_role |
| ACAPY_LOG_LEVEL | log-level | log.level |
shaangill025 marked this conversation as resolved.
Show resolved Hide resolved
| ACAPY_INVITE_PUBLIC | invite-public | debug.invite_public |
| ACAPY_PUBLIC_INVITES | public-invites | public_invites |
| ACAPY_AUTO_ACCEPT_INVITES | auto-accept-invites | debug.auto_accept_invites |
| ACAPY_AUTO_ACCEPT_REQUESTS | auto-accept-requests | debug.auto_accept_requests |
| ACAPY_AUTO_PING_CONNECTION | auto-ping-connection | auto_ping_connection |
| ACAPY_MONITOR_PING | monitor-ping | debug.monitor_ping |
| ACAPY_AUTO_RESPOND_MESSAGES | auto-respond-messages | debug.auto_respond_messages |
| ACAPY_AUTO_RESPOND_CREDENTIAL_OFFER | auto-respond-credential-offer | debug.auto_resopnd_credential_offer |
| ACAPY_AUTO_RESPOND_CREDENTIAL_REQUEST | auto-respond-credential-request | debug.auto_respond_credential_request |
| ACAPY_AUTO_VERIFY_PRESENTATION | auto-verify-presentation | debug.auto_verify_presentation |
| ACAPY_NOTIFY_REVOCATION | notify-revocation | revocation.notify |
| ACAPY_AUTO_REQUEST_ENDORSEMENT | auto-request-endorsement | endorser.auto_request |
| ACAPY_AUTO_WRITE_TRANSACTIONS | auto-write-transactions | endorser.auto_write |
| ACAPY_CREATE_REVOCATION_TRANSACTIONS | auto-create-revocation-transactions | endorser.auto_create_rev_reg |
| ACAPY_ENDORSER_ROLE | endorser-protocol-role | endorser.protocol_role |

- `POST /multitenancy/wallet`

Expand Down
10 changes: 8 additions & 2 deletions aries_cloudagent/settings/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _get_filtered_settings_dict(wallet_settings: dict):

@docs(
tags=["settings"],
summary="Update settings or config associated with the profile.",
summary="Update configurable settings associated with the profile.",
)
@request_schema(UpdateProfileSettingsSchema())
@response_schema(ProfileSettingsSchema(), 200, description="")
Expand All @@ -79,11 +79,17 @@ async def update_profile_settings(request: web.BaseRequest):
multitenant_mgr = session.inject_or(BaseMultitenantManager)
if multitenant_mgr:
wallet_id = context.metadata.get("wallet_id")
wallet_key = context.metadata.get("wallet_key")
wallet_record = await multitenant_mgr.update_wallet(
wallet_id, extra_settings
)
wallet_record, profile = await multitenant_mgr.get_wallet_and_profile(
root_profile.context, wallet_id, wallet_key
)
profile_settings = profile.settings.to_dict()
wallet_settings = wallet_record.settings
settings_dict = _get_filtered_settings_dict(wallet_settings)
all_settings = {**profile_settings, **wallet_settings}
settings_dict = _get_filtered_settings_dict(all_settings)
shaangill025 marked this conversation as resolved.
Show resolved Hide resolved
else:
root_profile.context.update_settings(extra_settings)
settings_dict = _get_filtered_settings_dict(
Expand Down
24 changes: 23 additions & 1 deletion aries_cloudagent/settings/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,26 @@ async def test_update_profile_settings(mock_response):
)
with async_mock.patch.object(
multi_tenant_manager, "update_wallet"
) as update_wallet:
) as update_wallet, async_mock.patch.object(
multi_tenant_manager, "get_wallet_and_profile"
) as get_wallet_and_profile:
get_wallet_and_profile.return_value = (
async_mock.MagicMock(
settings={
"admin.admin_client_max_request_size": 1,
"debug.auto_respond_credential_offer": True,
"debug.auto_respond_credential_request": True,
"debug.auto_respond_presentation_proposal": True,
"debug.auto_verify_presentation": True,
"public_invites": False,
"debug.invite_public": False,
"debug.auto_accept_invites": False,
"debug.auto_accept_requests": False,
"auto_ping_connection": False,
}
),
profile,
)
update_wallet.return_value = async_mock.MagicMock(
settings={
"public_invites": False,
Expand All @@ -195,4 +214,7 @@ async def test_update_profile_settings(mock_response):
"debug.auto_accept_invites": False,
"debug.auto_accept_requests": False,
"auto_ping_connection": False,
"debug.auto_respond_credential_offer": True,
"debug.auto_respond_credential_request": True,
"debug.auto_verify_presentation": True,
}