|
46 | 46 | import java.util.ArrayList;
|
47 | 47 | import java.util.Collections;
|
48 | 48 | import java.util.HashMap;
|
| 49 | +import java.util.LinkedList; |
49 | 50 | import java.util.List;
|
50 | 51 | import java.util.Map;
|
51 | 52 | import java.util.concurrent.ExecutionException;
|
@@ -168,7 +169,7 @@ void doGrants401Test() throws IOException, InterruptedException, TimeoutExceptio
|
168 | 169 | lines = waitFor(logReader, "Done refreshing grants");
|
169 | 170 | Assert.assertTrue("Failed to fetch", checkLogForRegex(lines, "Failed to fetch grants .* status 401"));
|
170 | 171 | Assert.assertTrue("Removed user from grants cache", checkLogForRegex(lines, "Removed user from grants cache: alice"));
|
171 |
| - Assert.assertTrue("Removed invalid sessions", checkLogForRegex(lines, "Removed invalid sessions from sessions map \\(userId: alice")); |
| 172 | + Assert.assertTrue("Removed invalid session", checkLogForRegex(lines, "Removed invalid session from sessions map \\(userId: alice")); |
172 | 173 |
|
173 | 174 | } finally {
|
174 | 175 | changeAuthServerMode("grants", "MODE_200");
|
@@ -518,6 +519,9 @@ void doConfigTests() throws IOException {
|
518 | 519 | void doGrantsGCTests() throws Exception {
|
519 | 520 | logStart("KeycloakAuthorizerTest :: Grants Garbage Collection Tests");
|
520 | 521 |
|
| 522 | + // Hold on to the created principals to prevent JVM gc() clearing the sessions |
| 523 | + List<OAuthKafkaPrincipal> principals = new LinkedList<>(); |
| 524 | + |
521 | 525 | // make sure the token endpoint works fine
|
522 | 526 | changeAuthServerMode("token", "MODE_200");
|
523 | 527 |
|
@@ -558,7 +562,7 @@ void doGrantsGCTests() throws Exception {
|
558 | 562 |
|
559 | 563 | LOG.info("Authenticate (validate) as gcUser1");
|
560 | 564 | OAuthKafkaPrincipal principal = authenticate(authHandler, tokenInfo);
|
561 |
| - |
| 565 | + principals.add(principal); |
562 | 566 |
|
563 | 567 | // authorization
|
564 | 568 |
|
@@ -590,6 +594,7 @@ void doGrantsGCTests() throws Exception {
|
590 | 594 |
|
591 | 595 | LOG.info("Authenticate (validate) gcUser2");
|
592 | 596 | principal = authenticate(authHandler, tokenInfo);
|
| 597 | + principals.add(principal); |
593 | 598 |
|
594 | 599 | LOG.info("Waiting for: active users count: 2, grantsCache size before: 1, grantsCache size after: 1"); // Make sure to not repeat the below condition in the string here
|
595 | 600 | // wait for cgGrants run on 2 users
|
|
0 commit comments