From a8a5c9651039929264d754e2abdfd8d46aff38d1 Mon Sep 17 00:00:00 2001 From: Martin Kanis Date: Fri, 11 Oct 2024 14:36:26 +0200 Subject: [PATCH] Fix unstable testPostBrokerLoginFlowWithOTP_bruteForceEnabled test Closes #33549 Signed-off-by: Martin Kanis --- .../java/org/keycloak/testsuite/AssertEvents.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AssertEvents.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AssertEvents.java index 60080c8d33..fc2936021a 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AssertEvents.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AssertEvents.java @@ -199,7 +199,7 @@ public class AssertEvents implements TestRule { public ExpectedEvent expectRegister(String username, String email) { return expectRegister(username, email, DEFAULT_CLIENT_ID); } - + public ExpectedEvent expectRegister(String username, String email, String clientId) { UserRepresentation user = username != null ? getUser(username) : null; return expect(EventType.REGISTER) @@ -399,13 +399,12 @@ public class AssertEvents implements TestRule { List presentedEventTypes = new LinkedList<>(); for (int i = 0 ; i < 25 ; i++) { EventRepresentation event = fetchNextEvent(seconds); - if (event == null) { - Assert.fail("Did not find the event of expected type " + expected.getType() +". Events present: " + presentedEventTypes); - } - if (expected.getType().equals(event.getType())) { - return assertEvent(event); - } else { - presentedEventTypes.add(event.getType()); + if (event != null) { + if (expected.getType().equals(event.getType())) { + return assertEvent(event); + } else { + presentedEventTypes.add(event.getType()); + } } } Assert.fail("Did not find the event of expected type " + expected.getType() +". Events present: " + presentedEventTypes);