Skip to content

fix: clear SecurityContextHolder in unit tests to prevent context leak#53

Merged
Washingtonwei merged 1 commit into
mainfrom
bugfix/security-context-leak-in-unit-tests
May 25, 2026
Merged

fix: clear SecurityContextHolder in unit tests to prevent context leak#53
Washingtonwei merged 1 commit into
mainfrom
bugfix/security-context-leak-in-unit-tests

Conversation

@Washingtonwei

@Washingtonwei Washingtonwei commented May 25, 2026

Copy link
Copy Markdown
Owner

@

Summary

  • Add @AfterEach tearDown to EvaluationServiceTest, StudentServiceTest, and InstructorServiceTest to clear SecurityContextHolder after each test, preventing stale authentication from leaking into integration tests via thread-local storage
  • Remove the reuseForks/forkCount Surefire workaround from pom.xml now that the root cause is fixed, restoring faster test execution

Closes #52

Test plan

  • Run full backend test suite (mvnw.cmd test) — all tests pass
  • Verify CI pipeline passes without the Surefire workaround
    @

@
fix: clear SecurityContextHolder in unit tests to prevent context leak

Add @AfterEach tearDown to EvaluationServiceTest, StudentServiceTest,
and InstructorServiceTest to clear the security context after each test,
preventing stale authentication from leaking into integration tests via
thread-local storage. Remove the reuseForks/forkCount Surefire workaround
from pom.xml now that the root cause is fixed.

Closes #52
@
@Washingtonwei
Washingtonwei merged commit 5c3703d into main May 25, 2026
2 checks passed
@Washingtonwei
Washingtonwei deleted the bugfix/security-context-leak-in-unit-tests branch May 25, 2026 02:04
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.

Fix SecurityContextHolder leakage causing intermittent integration test failures

1 participant