Skip to content

Commit

Permalink
Fix: Enable webhook events for verification; Handle exception in dele…
Browse files Browse the repository at this point in the history
…te and read verification record endpoints

Signed-off-by: George J Padayatti <[email protected]>
  • Loading branch information
georgepadayatti committed Apr 30, 2024
1 parent 34211be commit e133153
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
14 changes: 9 additions & 5 deletions eudi_wallet/ebsi/entry_points/server/routes/v2/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@
)
from eudi_wallet.ebsi.usecases.v2.organisation.read_verification_request_usecase import (
ReadVerificationRequestUsecase,
ReadVerificationRequestUsecaseError
)
from eudi_wallet.ebsi.usecases.v2.organisation.delete_verification_request_usecase import (
DeleteVerificationRequestUsecase,
DeleteVerificationRequestUsecaseError
)

from eudi_wallet.ebsi.usecases.v2.organisation.list_verification_request_usecase import (
Expand Down Expand Up @@ -788,6 +790,7 @@ async def handle_post_create_verification_request(
organisation_id=organisation_id,
presentation_definition=request_body.presentationDefinition,
requestByReference=request_body.requestByReference,
webhook_url=context.legal_entity_service.legal_entity_entity.webhook_url
)
return web.json_response(verification_record.to_dict())
except ValidationError as e:
Expand Down Expand Up @@ -829,6 +832,8 @@ async def handle_get_read_verification_history(
verification_record_id=verification_record_id
)
return web.json_response(verification_record.to_dict())
except ReadVerificationRequestUsecaseError as e:
raise web.HTTPBadRequest(reason=str(e))
except ValidationError as e:
raise web.HTTPBadRequest(reason=json.dumps(e.errors()))
except PresentationDefinitionValidationError as e:
Expand Down Expand Up @@ -864,14 +869,13 @@ async def handle_delete_verification_history(
logger=context.app_context.logger,
)

is_deleted = usecase.execute(
usecase.execute(
organisation_id=organisation_id,
verification_record_id=verification_record_id,
)
if is_deleted:
return web.json_response(status=204)
else:
return web.json_response(status=400)
return web.json_response(status=204)
except DeleteVerificationRequestUsecaseError as e:
raise web.HTTPBadRequest(reason=str(e))
except ValidationError as e:
raise web.HTTPBadRequest(reason=json.dumps(e.errors()))
except PresentationDefinitionValidationError as e:
Expand Down
4 changes: 3 additions & 1 deletion eudi_wallet/ebsi/entry_points/server/routes/v2/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async def handle_get_credential_record_by_reference(


@service_routes.get(
"/organisation/{organisationId}/service/verification-request/{verification_record_id}",
"/organisation/{organisationId}/service/verification/{verification_record_id}",
name="handle_get_verification_request_by_reference",
)
@v2_inject_request_context()
Expand Down Expand Up @@ -101,6 +101,7 @@ async def handle_get_verification_request_by_reference(

verification_record = usecase.execute(
verification_record_id=verification_record_id,
webhook_url=context.legal_entity_service.legal_entity_entity.webhook_url
)
return web.Response(
text=verification_record.vp_token_request, content_type="application/jwt"
Expand Down Expand Up @@ -288,6 +289,7 @@ async def handle_service_post_direct_post(request: Request, context: V2RequestCo
id_token_response_req.presentation_submission
)
},
webhook_url=context.legal_entity_service.legal_entity_entity.webhook_url
)
return web.json_response(verification_record.to_dict())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def execute(
if requestByReference:
encoded_params = urllib.parse.urlencode(
{
"request_uri": f"{domain}/organisation/{organisation_id}/service/verification-request/{verification_record_id}",
"request_uri": f"{domain}/organisation/{organisation_id}/service/verification/{verification_record_id}",
}
)
else:
Expand All @@ -113,7 +113,7 @@ def execute(
"response_type": response_type,
"scope": scope,
"redirect_uri": redirect_uri,
"request_uri": f"{domain}/organisation/{organisation_id}/service/verification-request/{verification_record_id}",
"request_uri": f"{domain}/organisation/{organisation_id}/service/verification/{verification_record_id}",
"response_mode": response_mode,
"state": state,
"nonce": nonce,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ def execute(
)
if not is_deleted:
raise DeleteVerificationRequestUsecaseError(
"Verification record is not deleted"
"Verification record is not found"
)
return is_deleted

0 comments on commit e133153

Please sign in to comment.