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

feat(did creation route): reject unregistered did methods #2262

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 7 additions & 1 deletion aries_cloudagent/wallet/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,13 @@ async def wallet_create_did(request: web.BaseRequest):
info = None
async with context.session() as session:
did_methods = session.inject(DIDMethods)
method = did_methods.from_method(body.get("method", "")) or SOV

method = did_methods.from_method(body.get("method", "sov"))
if not method:
raise web.HTTPForbidden(
reason=(f"method {body.get('method')} is not supported by the agent.")
)

key_types = session.inject(KeyTypes)
# set default method and key type for backwards compat
key_type = (
Expand Down
11 changes: 11 additions & 0 deletions aries_cloudagent/wallet/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ async def test_create_did(self):
)
assert result is json_response.return_value

async def test_create_did_unsupported_method(self):
self.request.json = async_mock.AsyncMock(
return_value={
"method": "madeupmethod",
"options": {"key_type": "bls12381g2"},
}
)

with self.assertRaises(test_module.web.HTTPForbidden):
await test_module.wallet_create_did(self.request)

async def test_create_did_unsupported_key_type(self):
self.request.json = async_mock.AsyncMock(
return_value={"method": "sov", "options": {"key_type": "bls12381g2"}}
Expand Down