Session cache affinity

Closes #42776

Signed-off-by: Pedro Ruivo <1492066+pruivo@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@gmx.net>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Co-authored-by: Pedro Ruivo <1492066+pruivo@users.noreply.github.com>
Co-authored-by: Alexander Schwartz <alexander.schwartz@gmx.net>
Co-authored-by: Steven Hawkins <shawkins@redhat.com>
Co-authored-by: Alexander Schwartz <alexander.schwartz@ibm.com>
This commit is contained in:
Pedro Ruivo
2025-10-30 21:01:09 +00:00
committed by GitHub
parent bd2a1c7c00
commit e40c5de050
29 changed files with 256 additions and 89 deletions

View File

@@ -2,9 +2,11 @@ package org.keycloak.testframework.events;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.hamcrest.TypeSafeMatcher;
import java.util.UUID;
import java.util.regex.Pattern;
public class EventMatchers {
@@ -12,6 +14,32 @@ public class EventMatchers {
return new UUIDMatcher();
}
public static Matcher<String> isCodeId() {
// Make the tests pass with the old and the new encoding of code IDs
return Matchers.anyOf(isBase64WithAtLeast128Bits(), isUUID());
}
public static Matcher<String> isSessionId() {
// Make the tests pass with the old and the new encoding of sessions
return Matchers.anyOf(isBase64WithAtLeast128Bits(), isUUID());
}
public static Matcher<String> isBase64WithAtLeast128Bits() {
return new TypeSafeMatcher<>() {
private static final Pattern BASE64 = Pattern.compile("[-A-Za-z0-9+/_]*");
@Override
protected boolean matchesSafely(String item) {
return item.length() >= 24 && item.matches(BASE64.pattern());
}
@Override
public void describeTo(Description description) {
description.appendText("not an base64 ID with at least 128bits");
}
};
}
private EventMatchers() {
}