Skip to content

Commit eb6da13

Browse files
authored
Fix flaky test in SpringSecurityPasswordValidationCallbackHandlerTest and SpringDigestPasswordValidationCallbackHandlerTest
1 parent 14b02c8 commit eb6da13

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/callback/SpringSecurityPasswordValidationCallbackHandlerTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public class SpringSecurityPasswordValidationCallbackHandlerTest {
5151

5252
@BeforeEach
5353
public void setUp() {
54-
54+
// add clearContext() at the beginning of each method in case {@code SecurityContextHolder} isn't clean
55+
SecurityContextHolder.clearContext();
56+
5557
callbackHandler = new SpringSecurityPasswordValidationCallbackHandler();
5658

5759
grantedAuthority = new SimpleGrantedAuthority("ROLE_1");

spring-ws-security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandlerTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ public class SpringDigestPasswordValidationCallbackHandlerTest {
4646
private String password;
4747

4848
private PasswordValidationCallback callback;
49-
49+
5050
@BeforeEach
5151
public void setUp() {
52+
// add clearContext() at the beginning of each method in case {@code SecurityContextHolder} isn't clean
53+
SecurityContextHolder.clearContext();
5254

5355
callbackHandler = new SpringDigestPasswordValidationCallbackHandler();
5456
userDetailsService = createMock(UserDetailsService.class);

0 commit comments

Comments
 (0)