Skip to content

Commit 5d63bf9

Browse files
committed
fix: add user_target_email to shell account audit event
1 parent 0e28cf6 commit 5d63bf9

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/apps/invitations/router.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
PrivateInvitationResponse,
2828
ShellAccountCreateRequest,
2929
)
30-
from apps.shared.domain.response import DEFAULT_OPENAPI_RESPONSE, Response, ResponseMulti
30+
from apps.shared.domain.response import (
31+
DEFAULT_OPENAPI_RESPONSE,
32+
Response,
33+
ResponseMulti,
34+
)
3135
from apps.shared.exception import BaseError
3236
from apps.subjects.api import create_subject
3337
from apps.subjects.domain import SubjectCreateRequest, SubjectCreateResponse
@@ -151,14 +155,17 @@ async def create_shell_account(
151155
result = await create_subject(
152156
user=user,
153157
session=session,
154-
schema=SubjectCreateRequest(applet_id=applet_id, **subject_schema.model_dump(by_alias=False)),
158+
schema=SubjectCreateRequest(
159+
applet_id=applet_id, **subject_schema.model_dump(by_alias=False)
160+
),
155161
)
156162
except BaseError as e:
157163
await log(
158164
AuditEvent(
159165
event_action=EventAction.APPLET_INVITE_INITIATE,
160166
user_id=user.id,
161167
curious_applet_id=[applet_id],
168+
user_target_email=subject_schema.email,
162169
user_target_roles=["shell-account"],
163170
**http_audit_fields(request, e),
164171
)
@@ -170,6 +177,7 @@ async def create_shell_account(
170177
event_action=EventAction.APPLET_INVITE_INITIATE,
171178
user_id=user.id,
172179
curious_applet_id=[applet_id],
180+
user_target_email=subject_schema.email,
173181
user_target_roles=["shell-account"],
174182
**http_audit_fields(request),
175183
)

src/apps/invitations/test_invite.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def shell_create_data():
155155
secretUserId="secretUserId",
156156
nickname="nickname",
157157
tag="tag",
158+
email="shell@example.com",
158159
)
159160

160161

@@ -1660,4 +1661,5 @@ async def test_shell_create_account_audit_event(
16601661
assert event.event_outcome == EventOutcome.SUCCESS
16611662
assert event.user_id == bob.id
16621663
assert event.curious_applet_id == [applet_four.id]
1664+
assert event.user_target_email == "shell@example.com"
16631665
assert event.user_target_roles == ["shell-account"]

0 commit comments

Comments
 (0)