Skip to content

nsc-events-fullstack_32_163_logging_sanitizer#166

Open
NahomAlemu wants to merge 1 commit intomainfrom
chore-163-logging-sanitizer
Open

nsc-events-fullstack_32_163_logging_sanitizer#166
NahomAlemu wants to merge 1 commit intomainfrom
chore-163-logging-sanitizer

Conversation

@NahomAlemu
Copy link
Copy Markdown
Contributor

Summary & Changes 📃

  • Resolves: Issue: Add Unit Tests for PII Logging Sanitizer #163

  • Summary: Add comprehensive unit tests for the logging sanitizer utility

    • Ensures the logging sanitizer correctly masks PII (emails, names, UUIDs, tokens, SSNs, phone
      numbers) to prevent sensitive data leakage in logs
    • All sanitization functions properly mask/remove sensitive fields while preserving
      non-sensitive data
    • Tests cover 16 exported functions with 100+ test cases including edge cases for
      null/undefined inputs
  • Changes:

    • ✅ Added unit tests for maskEmail, maskName, maskUUID masking utilities
    • ✅ Added tests for sanitizeString covering Bearer tokens, JWTs, API keys, SSNs, and phone
      numbers
    • ✅ Added tests for sanitizeUrl to verify UUID masking in URL paths
    • ✅ Added tests for entity sanitizers: sanitizeUserForLogging, sanitizeActivityForLogging,
      sanitizeEventForLogging
    • ✅ Added tests for removeSensitiveFields and sanitizeRequestBody functions
    • ✅ Added tests for sanitizeForLogging generic sanitizer with user/activity/event detection
    • ✅ Added tests for secureLogger wrapper (log, error, warn, debug, verbose methods)
    • ✅ Added tests for initializeConsoleSanitization and restoreConsole functions
    • 🛠️ No breaking changes
    • 📝 Tests validate idempotent console initialization and proper restoration

Screenshots / Visual Aids 🔎

Expand ⬇️ 1

How to Test 🧪

  1. Steps to Reproduce:
    - Step 1: Navigate to nsc-events-nestjs/
    - Step 2: Run npm run test -- --coverage logging-sanitizer.spec.ts
  2. Expected Behavior: All 100+ test cases pass, confirming PII is properly sanitized across all
    logging utility functions
  3. Actual Behavior (if bug): N/A - New test files instead)

Checklist ✅

  • I have tested this PR locally and it works as expected.
  • This PR resolves an issue (Resolves #issue-number).
  • Reviewers, assignees(self), tags, and labels are correctly assigned.
  • Squash commits and enable auto-merge if approved.

@github-actions
Copy link
Copy Markdown

🚀 E2E Smoke Test Results

Running smoke tests only (non-critical files changed)

Status Count
✅ Passed 5
❌ Failed 0
📊 Total 5

View detailed report

💡 To run full E2E suite, add [e2e-full] to your commit message or trigger manually.

@NahomAlemu NahomAlemu linked an issue Mar 7, 2026 that may be closed by this pull request
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unit-test Small-scope logic validation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue: Add Unit Tests for PII Logging Sanitizer

1 participant