Skip to content

CRASM-3748 Removed users due to inactivity are not displayed in logs#1511

Draft
kirakaplinski wants to merge 5 commits into
developfrom
kk_crasm_3748_removed_by_inactivity
Draft

CRASM-3748 Removed users due to inactivity are not displayed in logs#1511
kirakaplinski wants to merge 5 commits into
developfrom
kk_crasm_3748_removed_by_inactivity

Conversation

@kirakaplinski

Copy link
Copy Markdown

🗣 Description

Fixes to show in the logs automatically removed users due to inactivity. The log table gets updated with the removed user info.
Backend:
backend/src/xfd_django/xfd_api/tasks/checkUserExpiration.py - added logic to update log table for removed users due to inactivity.
backend/src/xfd_django/xfd_api/tests/test_check_user_expiration.py - added test cases to test the new logic.
backend/worker/entrypoint.playwright.sh - added disable=SC2317,SC2329 to resolve pre-commit error
infrastructure/cloudtrail.tf - added the template to support macbook - ARM Apple Silicon.

💭 Motivation and context
Admin Tools → User Logs: automatically removed users do not appear in the filtered results.
This change solves this problem and updates the log table when user removed due inactivity.

🧪 Testing

The changes have been added to unit test component and tested.
Here's the screenshot:

📷 Screenshots

image

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • Changes are limited to a single goal - eschew scope creep!
  • All future TODOs are captured in issues, which are referenced in code comments.
  • All relevant type-of-change labels have been added.
  • I have read the CONTRIBUTING document.
  • These code changes follow cisagov code standards.
  • All relevant repo and/or project documentation has been updated to reflect the changes in this PR.
  • Tests have been added and/or modified to cover the changes in this PR.
  • All new and existing tests pass.
  • Bump major, minor, patch, pre-release, and/or build versions as appropriate via the bump_version script if this repository is versioned and the changes in this PR warrant a version bump.
  • Create a pre-release (necessary if and only if the pre-release version was bumped).

✅ Pre-merge checklist

  • Revert dependencies to default branches.
  • Finalize version.

✅ Post-merge checklist

  • Create a release (necessary if and only if the version was bumped).

@aloftus23 aloftus23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my small fix, I tested locally and it all worked great.

I tested by runnning this command while npm start was running:
docker compose -f docker-compose.yml -f docker-compose.override.local.yml exec backend python -c " from xfd_api.tasks.checkUserExpiration import handler import os os.environ['STAGE'] = 'staging' print(handler({'Test': True, 'email': 'local-expiry-test-$(date +%s)@example.com'}, {})) "

That command runs the test user flow (adds an expiring user, then initiates the lambda handler).

Resulted in the database object here:

Image

And in the application it looks like this:

Image Image

Comment thread backend/src/xfd_django/xfd_api/tasks/checkUserExpiration.py Outdated
@aloftus23

aloftus23 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Didn't notice at first, but the User Type and Organization fields in the table are N/A. It should be possible to query that and store in the Log table payload field.

You'd have to update the call to pull the User and organization with a prefetch_related('roles_organization')

Acted-on User Name should be able to be filled too. Acting USer Name can remain null as there's no specific Admin performing the action.

You may need to refer to the frontend table to see how it's pulling these fields from the payload:
https://github.com/cisagov/XFD/blob/develop/frontend/src/components/Logs/Logs.tsx

Specifically this line:
https://github.com/cisagov/XFD/blob/develop/frontend/src/components/Logs/Logs.tsx#L219

Co-authored-by: aloftus23 <79927030+aloftus23@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants