mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-06 06:49:53 -06:00
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:
@@ -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() {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user