Revert changes related to map store in test classes in base testsuite
Closes #24567 Signed-off-by: VR <vramik@redhat.com>
This commit is contained in:
parent
e6095f901a
commit
1545b32a64
33 changed files with 61 additions and 347 deletions
|
@ -49,23 +49,18 @@ public class ModelTestExecutor extends LocalTestExecuter {
|
|||
super.execute(event);
|
||||
} else {
|
||||
TestResult result = new TestResult();
|
||||
if (annotation.skipForMapStorage()) {
|
||||
result = TestResult.skipped();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
// Model test - wrap the call inside the
|
||||
TestContext ctx = testContext.get();
|
||||
KeycloakTestingClient testingClient = ctx.getTestingClient();
|
||||
testingClient.server().runModelTest(testMethod.getDeclaringClass().getName(), testMethod.getName());
|
||||
try {
|
||||
// Model test - wrap the call inside the
|
||||
TestContext ctx = testContext.get();
|
||||
KeycloakTestingClient testingClient = ctx.getTestingClient();
|
||||
testingClient.server().runModelTest(testMethod.getDeclaringClass().getName(), testMethod.getName());
|
||||
|
||||
result.setStatus(TestResult.Status.PASSED);
|
||||
} catch (Throwable e) {
|
||||
result.setStatus(TestResult.Status.FAILED);
|
||||
result.setThrowable(e);
|
||||
} finally {
|
||||
result.setEnd(System.currentTimeMillis());
|
||||
}
|
||||
result.setStatus(TestResult.Status.PASSED);
|
||||
} catch (Throwable e) {
|
||||
result.setStatus(TestResult.Status.FAILED);
|
||||
result.setThrowable(e);
|
||||
} finally {
|
||||
result.setEnd(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
// Need to use reflection this way...
|
||||
|
|
|
@ -33,6 +33,4 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|||
@Retention(RUNTIME)
|
||||
@Target({ElementType.METHOD}) // TODO: Maybe ElementClass.TYPE too? That way it will be possible to add the annotation on the the test class and not need to add on all the test methods inside the class
|
||||
public @interface ModelTest {
|
||||
|
||||
boolean skipForMapStorage() default false;
|
||||
}
|
||||
|
|
|
@ -194,12 +194,10 @@ public abstract class AbstractQuarkusDeployableContainer implements DeployableCo
|
|||
commands.removeIf("--optimized"::equals);
|
||||
commands.add("--http-relative-path=/auth");
|
||||
|
||||
if (!storeProvider.isMapStore()) {
|
||||
if ("local".equals(cacheMode)) {
|
||||
commands.add("--cache=local");
|
||||
} else {
|
||||
commands.add("--cache-config-file=cluster-" + cacheMode + ".xml");
|
||||
}
|
||||
if ("local".equals(cacheMode)) {
|
||||
commands.add("--cache=local");
|
||||
} else {
|
||||
commands.add("--cache-config-file=cluster-" + cacheMode + ".xml");
|
||||
}
|
||||
|
||||
if (configuration.getFipsMode() != FipsMode.DISABLED) {
|
||||
|
|
|
@ -52,7 +52,6 @@ import org.wildfly.extras.creaper.core.online.OnlineOptions;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.jboss.shrinkwrap.api.Archive;
|
||||
|
||||
|
@ -139,10 +138,6 @@ public class KeycloakContainerEventsController extends ContainerEventController
|
|||
if (restartContainer.withoutKeycloakAddUserFile()) {
|
||||
removeKeycloakAddUserFile();
|
||||
}
|
||||
|
||||
if (restartContainer.initializeDatabase()) {
|
||||
clearMapStorageFiles();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -202,17 +197,6 @@ public class KeycloakContainerEventsController extends ContainerEventController
|
|||
|
||||
}
|
||||
|
||||
private void clearMapStorageFiles() {
|
||||
String filePath = System.getProperty("project.build.directory", "target/map");
|
||||
|
||||
File f = new File(filePath);
|
||||
if (!f.exists()) return;
|
||||
|
||||
Arrays.stream(f.listFiles())
|
||||
.filter(file -> file.getName().startsWith("map-") && file.getName().endsWith(".json"))
|
||||
.forEach(File::delete);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy keycloak-add-user.json only if it is jboss container (has jbossHome property).
|
||||
*/
|
||||
|
|
|
@ -147,10 +147,7 @@ public class KeycloakQuarkusServerDeployableContainer extends AbstractQuarkusDep
|
|||
builder.environment().put("JAVA_OPTS", javaOpts);
|
||||
}
|
||||
|
||||
final StoreProvider storeProvider = StoreProvider.getCurrentProvider();
|
||||
final boolean isJpaStore = storeProvider.equals(StoreProvider.JPA) || storeProvider.equals(StoreProvider.LEGACY);
|
||||
|
||||
if (!isJpaStore) {
|
||||
if (!StoreProvider.JPA.equals(StoreProvider.getCurrentProvider())) {
|
||||
builder.environment().put("KEYCLOAK_ADMIN", "admin");
|
||||
builder.environment().put("KEYCLOAK_ADMIN_PASSWORD", "admin");
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.keycloak.testsuite.model;
|
|||
import org.keycloak.utils.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -29,38 +28,7 @@ import java.util.Optional;
|
|||
* @author <a href="mailto:mabartos@redhat.com">Martin Bartos</a>
|
||||
*/
|
||||
public enum StoreProvider {
|
||||
CHM("chm") {
|
||||
@Override
|
||||
public void addStoreOptions(List<String> commands) {
|
||||
commands.add("--storage=" + getAlias());
|
||||
}
|
||||
},
|
||||
FILE("file") {
|
||||
@Override
|
||||
public void addStoreOptions(List<String> commands) {
|
||||
commands.add("--storage=" + getAlias());
|
||||
}
|
||||
},
|
||||
JPA("jpa") {
|
||||
@Override
|
||||
public void addStoreOptions(List<String> commands) {
|
||||
commands.add("--storage=" + getAlias());
|
||||
getDbVendor().ifPresent(vendor -> commands.add("--storage-jpa-db=" + vendor));
|
||||
commands.add("--db-url=" + System.getProperty("keycloak.map.storage.connectionsJpa.url"));
|
||||
commands.add("--db-username=" + System.getProperty("keycloak.map.storage.connectionsJpa.user"));
|
||||
commands.add("--db-password=" + System.getProperty("keycloak.map.storage.connectionsJpa.password"));
|
||||
}
|
||||
},
|
||||
HOTROD("hotrod") {
|
||||
@Override
|
||||
public void addStoreOptions(List<String> commands) {
|
||||
commands.add("--storage=" + getAlias());
|
||||
commands.add("--storage-hotrod-host=" + System.getProperty("keycloak.connectionsHotRod.host"));
|
||||
commands.add("--storage-hotrod-username=" + System.getProperty("keycloak.connectionsHotRod.username", "admin"));
|
||||
commands.add("--storage-hotrod-password=" + System.getProperty("keycloak.connectionsHotRod.password", "admin"));
|
||||
}
|
||||
},
|
||||
LEGACY("legacy") {
|
||||
@Override
|
||||
public void addStoreOptions(List<String> commands) {
|
||||
getDbVendor().ifPresent(vendor -> commands.add("--db=" + vendor));
|
||||
|
@ -92,7 +60,6 @@ public enum StoreProvider {
|
|||
}
|
||||
};
|
||||
|
||||
public static final String AUTH_SERVER_QUARKUS_MAP_STORAGE_PROFILE = "auth.server.quarkus.mapStorage.profile.config";
|
||||
public static final String DB_VENDOR_PROPERTY = "keycloak.storage.connections.vendor";
|
||||
|
||||
private final String alias;
|
||||
|
@ -116,32 +83,11 @@ public enum StoreProvider {
|
|||
return alias;
|
||||
}
|
||||
|
||||
public boolean isLegacyStore() {
|
||||
return this.equals(LEGACY);
|
||||
}
|
||||
|
||||
public boolean isMapStore() {
|
||||
return !isLegacyStore() && !this.equals(DEFAULT);
|
||||
}
|
||||
|
||||
public static Optional<String> getDbVendor() {
|
||||
return Optional.ofNullable(System.getProperty(DB_VENDOR_PROPERTY)).filter(StringUtil::isNotBlank);
|
||||
}
|
||||
|
||||
public static StoreProvider getCurrentProvider() {
|
||||
return getProviderByAlias(System.getProperty(AUTH_SERVER_QUARKUS_MAP_STORAGE_PROFILE, ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Store Provider by alias
|
||||
*
|
||||
* @param alias alias
|
||||
* @return store provider, LEGACY when vendor is specified, otherwise DEFAULT
|
||||
*/
|
||||
public static StoreProvider getProviderByAlias(String alias) {
|
||||
return Arrays.stream(StoreProvider.values())
|
||||
.filter(f -> f.getAlias().equals(alias))
|
||||
.findFirst()
|
||||
.orElseGet(() -> getDbVendor().isEmpty() ? DEFAULT : LEGACY);
|
||||
return getDbVendor().isEmpty() ? DEFAULT : JPA;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,12 +37,9 @@ import org.keycloak.admin.client.resource.UserResource;
|
|||
import org.keycloak.admin.client.resource.UsersResource;
|
||||
import org.keycloak.common.util.KeycloakUriBuilder;
|
||||
import org.keycloak.common.util.Time;
|
||||
import org.keycloak.models.RealmProvider;
|
||||
import org.keycloak.models.cache.CacheRealmProvider;
|
||||
import org.keycloak.models.cache.UserCache;
|
||||
import org.keycloak.models.utils.TimeBasedOTP;
|
||||
import org.keycloak.protocol.oidc.OIDCAdvancedConfigWrapper;
|
||||
import org.keycloak.provider.Provider;
|
||||
import org.keycloak.representations.idm.ClientRepresentation;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
import org.keycloak.representations.idm.RequiredActionProviderRepresentation;
|
||||
|
@ -743,39 +740,4 @@ public abstract class AbstractKeycloakTest {
|
|||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
/**
|
||||
* MapRealmProvider uses session.invalidate() instead of calling e.g.
|
||||
* session.clients().removeClients(realm); for clients (where clients are being removed one by one)
|
||||
*
|
||||
* Therefore it doesn't call session.users().preRemove(realm, client) for each client.
|
||||
* Due to that JpaUserFederatedStorageProvider.preRemove(realm, client) is not called.
|
||||
* So there remains objects in the database in user federation related tables after realm removal.
|
||||
*
|
||||
* Same for roles etc.
|
||||
*
|
||||
* Legacy federated storage is NOT supposed to work with map storage, so this method
|
||||
* returns true if realm provider is "jpa" to be able to skip particular tests.
|
||||
*/
|
||||
protected boolean isJpaRealmProvider() {
|
||||
return keycloakUsingProviderWithId(RealmProvider.class, "jpa");
|
||||
}
|
||||
|
||||
protected boolean keycloakUsingProviderWithId(Class<? extends Provider> providerClass, String requiredId) {
|
||||
String providerId = testingClient.server()
|
||||
.fetchString(s -> s.getKeycloakSessionFactory().getProviderFactory(providerClass).getId());
|
||||
return Objects.equals(providerId, "\"" + requiredId + "\"");
|
||||
}
|
||||
|
||||
protected boolean isRealmCacheEnabled() {
|
||||
String realmCache = testingClient.server()
|
||||
.fetchString(s -> s.getKeycloakSessionFactory().getProviderFactory(CacheRealmProvider.class));
|
||||
return Objects.nonNull(realmCache);
|
||||
}
|
||||
|
||||
protected boolean isUserCacheEnabled() {
|
||||
String userCache = testingClient.server()
|
||||
.fetchString(s -> s.getKeycloakSessionFactory().getProviderFactory(UserCache.class));
|
||||
return Objects.nonNull(userCache);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -392,20 +392,9 @@ public class PermissionsTest extends AbstractKeycloakTest {
|
|||
}
|
||||
}, Resource.REALM, true);
|
||||
|
||||
if (isJpaRealmProvider()) {
|
||||
// Caching is disabled with the new store, we need to skip these invocations
|
||||
invoke(new Invocation() {
|
||||
public void invoke(RealmResource realm) {
|
||||
realm.clearRealmCache();
|
||||
}
|
||||
}, Resource.REALM, true);
|
||||
invoke(new Invocation() {
|
||||
public void invoke(RealmResource realm) {
|
||||
realm.clearUserCache();
|
||||
}
|
||||
}, Resource.REALM, true);
|
||||
invoke(RealmResource::clearRealmCache, Resource.REALM, true);
|
||||
invoke(RealmResource::clearUserCache, Resource.REALM, true);
|
||||
|
||||
}
|
||||
// Delete realm
|
||||
invoke(new Invocation() {
|
||||
public void invoke(RealmResource realm) {
|
||||
|
|
|
@ -88,11 +88,9 @@ public class ServerInfoTest extends AbstractKeycloakTest {
|
|||
assertNotNull(info.getSystemInfo().getServerTime());
|
||||
assertNotNull(info.getSystemInfo().getUptime());
|
||||
|
||||
if (isJpaRealmProvider()) {
|
||||
Map<String, ProviderRepresentation> jpaProviders = info.getProviders().get("connectionsJpa").getProviders();
|
||||
ProviderRepresentation jpaProvider = jpaProviders.values().iterator().next();
|
||||
log.infof("JPA Connections provider info: %s", jpaProvider.getOperationalInfo());
|
||||
}
|
||||
Map<String, ProviderRepresentation> jpaProviders = info.getProviders().get("connectionsJpa").getProviders();
|
||||
ProviderRepresentation jpaProvider = jpaProviders.values().iterator().next();
|
||||
log.infof("JPA Connections provider info: %s", jpaProvider.getOperationalInfo());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -99,50 +99,6 @@ public class UsersTest extends AbstractAdminTest {
|
|||
assertThat(users.get(0).getUsername(), is("john.doe"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void searchUserCaseSensitiveFirst() throws Exception {
|
||||
Assume.assumeFalse(isJpaRealmProvider());
|
||||
Map<String, String> attributes = new HashMap<>();
|
||||
attributes.put(Constants.REALM_ATTR_USERNAME_CASE_SENSITIVE, "true");
|
||||
try (AutoCloseable c = new RealmAttributeUpdater(adminClient.realm(REALM_NAME))
|
||||
.updateWith(r -> r.setAttributes(attributes))
|
||||
.update()) {
|
||||
|
||||
createUser(REALM_NAME, "User", "password", "firstName", "lastName", "user@example.com");
|
||||
|
||||
assertCaseSensitiveSearch();
|
||||
|
||||
RealmRepresentation realmRep = adminClient.realm(REALM_NAME).toRepresentation();
|
||||
RealmBuilder.edit(realmRep)
|
||||
.attribute(Constants.REALM_ATTR_USERNAME_CASE_SENSITIVE, "false");
|
||||
realm.update(realmRep);
|
||||
|
||||
assertCaseInsensitiveSearch();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void searchUserCaseInSensitiveFirst() throws Exception {
|
||||
Assume.assumeFalse(isJpaRealmProvider());
|
||||
Map<String, String> attributes = new HashMap<>();
|
||||
attributes.put(Constants.REALM_ATTR_USERNAME_CASE_SENSITIVE, "false");
|
||||
try (AutoCloseable c = new RealmAttributeUpdater(adminClient.realm(REALM_NAME))
|
||||
.updateWith(r -> r.setAttributes(attributes))
|
||||
.update()) {
|
||||
|
||||
createUser(REALM_NAME, "User", "password", "firstName", "lastName", "user@example.com");
|
||||
|
||||
assertCaseInsensitiveSearch();
|
||||
|
||||
RealmRepresentation realmRep = adminClient.realm(REALM_NAME).toRepresentation();
|
||||
RealmBuilder.edit(realmRep)
|
||||
.attribute(Constants.REALM_ATTR_USERNAME_CASE_SENSITIVE, "true");
|
||||
realm.update(realmRep);
|
||||
|
||||
assertCaseSensitiveSearch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* https://issues.redhat.com/browse/KEYCLOAK-15146
|
||||
*/
|
||||
|
@ -487,18 +443,4 @@ public class UsersTest extends AbstractAdminTest {
|
|||
assertThat(realm.users().search("USER", true), hasSize(1));
|
||||
assertThat(realm.users().search("Use", true), hasSize(0));
|
||||
}
|
||||
|
||||
private void assertCaseSensitiveSearch() {
|
||||
// not-exact case-sensitive search
|
||||
assertThat(realm.users().search("user"), hasSize(0));
|
||||
assertThat(realm.users().search("User"), hasSize(1));
|
||||
assertThat(realm.users().search("USER"), hasSize(0));
|
||||
assertThat(realm.users().search("Use"), hasSize(1));
|
||||
|
||||
// exact case-sensitive search
|
||||
assertThat(realm.users().search("user", true), hasSize(0));
|
||||
assertThat(realm.users().search("User", true), hasSize(1));
|
||||
assertThat(realm.users().search("USER", true), hasSize(0));
|
||||
assertThat(realm.users().search("Use", true), hasSize(0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,8 +118,7 @@ public class GroupSearchTest extends AbstractGroupTest {
|
|||
search(buildSearchQuery(ATTR_QUOTES_NAME_ESCAPED, ATTR_QUOTES_VAL_ESCAPED), GROUP3);
|
||||
|
||||
// "filtered" attribute won't take effect when JPA is used
|
||||
String[] expectedRes = isLegacyJpaStore() ? new String[]{GROUP1, GROUP2} : new String[]{GROUP2};
|
||||
search(buildSearchQuery(ATTR_URL_NAME, ATTR_URL_VAL, ATTR_FILTERED_NAME, ATTR_FILTERED_VAL), expectedRes);
|
||||
search(buildSearchQuery(ATTR_URL_NAME, ATTR_URL_VAL, ATTR_FILTERED_NAME, ATTR_FILTERED_VAL), new String[]{GROUP1, GROUP2});
|
||||
} finally {
|
||||
resetSearchableAttributes();
|
||||
}
|
||||
|
@ -287,10 +286,6 @@ public class GroupSearchTest extends AbstractGroupTest {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
private boolean isLegacyJpaStore() {
|
||||
return keycloakUsingProviderWithId(GroupProvider.class, "jpa");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTestRealms(List<RealmRepresentation> testRealms) {
|
||||
loadTestRealm(testRealmReps);
|
||||
|
|
|
@ -21,7 +21,6 @@ import com.google.common.collect.Sets;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
@ -251,10 +250,8 @@ public class RealmTest extends AbstractAdminTest {
|
|||
);
|
||||
|
||||
// This attribute is represented in Legacy store as attribute and for Map store as a field
|
||||
if (!StoreProvider.getCurrentProvider().isMapStore()) {
|
||||
expectedAttributes.add(OTPPolicy.REALM_REUSABLE_CODE_ATTRIBUTE);
|
||||
expectedAttributesCount++;
|
||||
}
|
||||
expectedAttributes.add(OTPPolicy.REALM_REUSABLE_CODE_ATTRIBUTE);
|
||||
expectedAttributesCount++;
|
||||
|
||||
assertThat(attributesKeys.size(), CoreMatchers.is(expectedAttributesCount));
|
||||
assertThat(attributesKeys, CoreMatchers.is(expectedAttributes));
|
||||
|
@ -738,7 +735,6 @@ public class RealmTest extends AbstractAdminTest {
|
|||
|
||||
@Test
|
||||
public void clearRealmCache() {
|
||||
Assume.assumeTrue("Realm cache disabled.", isRealmCacheEnabled());
|
||||
RealmRepresentation realmRep = realm.toRepresentation();
|
||||
assertTrue(testingClient.testing().cache("realms").contains(realmRep.getId()));
|
||||
|
||||
|
@ -750,7 +746,6 @@ public class RealmTest extends AbstractAdminTest {
|
|||
|
||||
@Test
|
||||
public void clearUserCache() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
UserRepresentation user = new UserRepresentation();
|
||||
user.setUsername("clearcacheuser");
|
||||
Response response = realm.users().create(user);
|
||||
|
|
|
@ -19,14 +19,12 @@ package org.keycloak.testsuite.broker;
|
|||
import java.util.Collections;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.admin.client.resource.RealmResource;
|
||||
import org.keycloak.admin.client.resource.UserResource;
|
||||
import org.keycloak.admin.client.resource.UsersResource;
|
||||
import org.keycloak.common.Profile;
|
||||
import org.keycloak.common.util.MultivaluedHashMap;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.RealmModel;
|
||||
|
@ -39,7 +37,6 @@ import org.keycloak.storage.StorageId;
|
|||
import org.keycloak.storage.UserStorageProvider;
|
||||
import org.keycloak.testsuite.AbstractKeycloakTest;
|
||||
import org.keycloak.testsuite.Assert;
|
||||
import org.keycloak.testsuite.ProfileAssume;
|
||||
import org.keycloak.testsuite.admin.ApiUtil;
|
||||
import org.keycloak.testsuite.federation.PassThroughFederatedUserStorageProvider;
|
||||
import org.keycloak.testsuite.federation.PassThroughFederatedUserStorageProviderFactory;
|
||||
|
@ -183,7 +180,6 @@ public class AccountLinkTest extends AbstractKeycloakTest {
|
|||
BrokerTestTools.createKcOidcBroker(adminClient, CHILD_IDP, testIdpToDelete);
|
||||
|
||||
// Create user federation
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
|
||||
ComponentRepresentation memProvider = new ComponentRepresentation();
|
||||
memProvider.setName("memory");
|
||||
|
|
|
@ -224,7 +224,6 @@ public class AdminEventStoreProviderTest extends AbstractEventsTest {
|
|||
|
||||
@Test
|
||||
public void expireOld() {
|
||||
Assume.assumeTrue("Map storage event store provider does not support changing expiration of existing events", keycloakUsingProviderWithId(EventStoreProvider.class, "jpa"));
|
||||
testing().onAdminEvent(create(System.currentTimeMillis() - 30000, realmId, OperationType.CREATE, realmId, "clientId", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
|
||||
testing().onAdminEvent(create(System.currentTimeMillis() - 20000, realmId, OperationType.CREATE, realmId, "clientId", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
|
||||
testing().onAdminEvent(create(System.currentTimeMillis(), realmId, OperationType.CREATE, realmId, "clientId", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
|
||||
|
|
|
@ -260,7 +260,6 @@ public class EventStoreProviderTest extends AbstractEventsTest {
|
|||
|
||||
@Test
|
||||
public void clearOld() {
|
||||
Assume.assumeTrue("Map storage event store provider does not support changing expiration of existing events", keycloakUsingProviderWithId(EventStoreProvider.class, "jpa"));
|
||||
testing().onEvent(create(System.currentTimeMillis() - 300000, EventType.LOGIN, realmId, "clientId", "userId", "127.0.0.1", "error"));
|
||||
testing().onEvent(create(System.currentTimeMillis() - 200000, EventType.LOGIN, realmId, "clientId", "userId", "127.0.0.1", "error"));
|
||||
testing().onEvent(create(System.currentTimeMillis(), EventType.LOGIN, realmId, "clientId", "userId", "127.0.0.1", "error"));
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package org.keycloak.testsuite.federation.ldap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
|
@ -106,7 +105,6 @@ public class LDAPMultipleAttributesTest extends AbstractLDAPTest {
|
|||
|
||||
@Test
|
||||
public void testUserImport() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
testingClient.server().run(session -> {
|
||||
LDAPTestContext ctx = LDAPTestContext.init(session);
|
||||
UserStorageUtil.userCache(session).clear();
|
||||
|
@ -122,7 +120,6 @@ public class LDAPMultipleAttributesTest extends AbstractLDAPTest {
|
|||
|
||||
@Test
|
||||
public void testModel() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
testingClient.server().run(session -> {
|
||||
LDAPTestContext ctx = LDAPTestContext.init(session);
|
||||
UserStorageUtil.userCache(session).clear();
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package org.keycloak.testsuite.federation.ldap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
|
@ -755,7 +754,6 @@ public class LDAPProvidersIntegrationTest extends AbstractLDAPTest {
|
|||
|
||||
@Test
|
||||
public void testHardcodedAttributeMapperTest() throws Exception {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
// Create hardcoded mapper for "description"
|
||||
testingClient.server().run(session -> {
|
||||
LDAPTestContext ctx = LDAPTestContext.init(session);
|
||||
|
@ -1043,7 +1041,6 @@ public class LDAPProvidersIntegrationTest extends AbstractLDAPTest {
|
|||
|
||||
@Test
|
||||
public void testSearchWithCustomLDAPFilter() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
// Add custom filter for searching users
|
||||
testingClient.server().run(session -> {
|
||||
LDAPTestContext ctx = LDAPTestContext.init(session);
|
||||
|
@ -1242,7 +1239,6 @@ public class LDAPProvidersIntegrationTest extends AbstractLDAPTest {
|
|||
// KEYCLOAK-9002
|
||||
@Test
|
||||
public void testSearchWithPartiallyCachedUser() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
testingClient.server().run(session -> {
|
||||
UserStorageUtil.userCache(session).clear();
|
||||
});
|
||||
|
@ -1269,7 +1265,6 @@ public class LDAPProvidersIntegrationTest extends AbstractLDAPTest {
|
|||
|
||||
@Test
|
||||
public void testLDAPUserRefreshCache() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
testingClient.server().run(session -> {
|
||||
UserStorageUtil.userCache(session).clear();
|
||||
});
|
||||
|
@ -1313,7 +1308,6 @@ public class LDAPProvidersIntegrationTest extends AbstractLDAPTest {
|
|||
|
||||
@Test
|
||||
public void testCacheUser() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
String userId = testingClient.server().fetch(session -> {
|
||||
LDAPTestContext ctx = LDAPTestContext.init(session);
|
||||
ctx.getLdapModel().setCachePolicy(UserStorageProviderModel.CachePolicy.NO_CACHE);
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package org.keycloak.testsuite.federation.ldap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
|
@ -334,7 +333,6 @@ public class LDAPRoleMappingsTest extends AbstractLDAPTest {
|
|||
*/
|
||||
@Test
|
||||
public void test04_syncRoleMappings() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
testingClient.server().run(session -> {
|
||||
LDAPTestContext ctx = LDAPTestContext.init(session);
|
||||
RealmModel appRealm = ctx.getRealm();
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package org.keycloak.testsuite.federation.ldap.noimport;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.MethodSorters;
|
||||
|
@ -45,7 +44,6 @@ public class LDAPMultipleAttributesNoImportTest extends LDAPMultipleAttributesTe
|
|||
|
||||
@Test
|
||||
public void testUserImport() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
testingClient.server().run(session -> {
|
||||
LDAPTestContext ctx = LDAPTestContext.init(session);
|
||||
UserStorageUtil.userCache(session).clear();
|
||||
|
|
|
@ -26,7 +26,6 @@ import jakarta.ws.rs.core.Response;
|
|||
import java.util.Map;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
@ -212,9 +211,6 @@ public class LDAPProvidersIntegrationNoImportTest extends LDAPProvidersIntegrati
|
|||
|
||||
@Test
|
||||
public void testFullNameMapperWriteOnly() {
|
||||
Assume.assumeTrue("User cache disabled. UserModel behaves differently when it's cached adapter and when not. See https://github.com/keycloak/keycloak/discussions/10004",
|
||||
isUserCacheEnabled());
|
||||
|
||||
ComponentRepresentation firstNameMapperRep = testingClient.server().fetch(session -> {
|
||||
LDAPTestContext ctx = LDAPTestContext.init(session);
|
||||
RealmModel appRealm = ctx.getRealm();
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
package org.keycloak.testsuite.federation.ldap.noimport;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
|
@ -62,11 +60,6 @@ public class LDAPRoleMappingsNoImportTest extends AbstractLDAPTest {
|
|||
return ldapRule;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void enabled() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isImportEnabled() {
|
||||
return false;
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.keycloak.testsuite.federation.storage;
|
|||
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
@ -325,8 +324,6 @@ public class ClientStorageTest extends AbstractTestRealmKeycloakTest {
|
|||
|
||||
@Test
|
||||
public void testDailyEviction() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
|
||||
testIsCached();
|
||||
|
||||
testingClient.server().run(session -> {
|
||||
|
@ -348,10 +345,9 @@ public class ClientStorageTest extends AbstractTestRealmKeycloakTest {
|
|||
testIsCached();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWeeklyEviction() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
|
||||
testIsCached();
|
||||
|
||||
testingClient.server().run(session -> {
|
||||
|
@ -376,10 +372,9 @@ public class ClientStorageTest extends AbstractTestRealmKeycloakTest {
|
|||
testIsCached();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxLifespan() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
|
||||
testIsCached();
|
||||
|
||||
testingClient.server().run(session -> {
|
||||
|
@ -417,8 +412,6 @@ public class ClientStorageTest extends AbstractTestRealmKeycloakTest {
|
|||
|
||||
@Test
|
||||
public void testIsCached() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
|
||||
testingClient.server().run(session -> {
|
||||
RealmModel realm = session.realms().getRealmByName("test");
|
||||
ClientModel hardcoded = realm.getClientByClientId("hardcoded-client");
|
||||
|
@ -430,8 +423,6 @@ public class ClientStorageTest extends AbstractTestRealmKeycloakTest {
|
|||
|
||||
@Test
|
||||
public void testNoCache() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
|
||||
testIsCached();
|
||||
|
||||
testingClient.server().run(session -> {
|
||||
|
|
|
@ -59,8 +59,6 @@ public class FederatedStorageExportImportTest extends AbstractAuthTest {
|
|||
|
||||
@Before
|
||||
public void setDirs() {
|
||||
Assume.assumeTrue("RealmProvider is not 'jpa'", isJpaRealmProvider());
|
||||
|
||||
File baseDir = new File(System.getProperty("auth.server.config.dir", "target"));
|
||||
|
||||
exportFileAbsolutePath = new File (baseDir, "singleFile-full.json").getAbsolutePath();
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.jboss.arquillian.container.test.api.ContainerController;
|
|||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.jboss.arquillian.test.api.ArquillianResource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
@ -92,8 +91,6 @@ public class UserStorageFailureTest extends AbstractTestRealmKeycloakTest {
|
|||
|
||||
@Before
|
||||
public void addProvidersBeforeTest() {
|
||||
Assume.assumeTrue("RealmProvider is not 'jpa'", isJpaRealmProvider());
|
||||
|
||||
ComponentRepresentation memProvider = new ComponentRepresentation();
|
||||
memProvider.setName("failure");
|
||||
memProvider.setProviderId(FailableHardcodedStorageProviderFactory.PROVIDER_ID);
|
||||
|
@ -152,8 +149,6 @@ public class UserStorageFailureTest extends AbstractTestRealmKeycloakTest {
|
|||
*/
|
||||
@Test
|
||||
public void testKeycloak5350() throws Exception {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
|
||||
oauth.scope(OAuth2Constants.OFFLINE_ACCESS);
|
||||
oauth.clientId("offline-client");
|
||||
oauth.redirectUri(OAuthClient.AUTH_SERVER_ROOT + "/offline-client");
|
||||
|
@ -254,8 +249,6 @@ public class UserStorageFailureTest extends AbstractTestRealmKeycloakTest {
|
|||
|
||||
@Test
|
||||
public void testKeycloak5926() {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
|
||||
oauth.clientId("test-app");
|
||||
oauth.redirectUri(OAuthClient.APP_AUTH_ROOT);
|
||||
|
||||
|
|
|
@ -91,8 +91,6 @@ public class UserStorageOTPTest extends AbstractTestRealmKeycloakTest {
|
|||
|
||||
@Before
|
||||
public void addProvidersBeforeTest() throws URISyntaxException, IOException {
|
||||
Assume.assumeTrue("RealmProvider is not 'jpa'", isJpaRealmProvider());
|
||||
|
||||
ComponentRepresentation dummyProvider = new ComponentRepresentation();
|
||||
dummyProvider.setName("dummy");
|
||||
dummyProvider.setId(componentId);
|
||||
|
|
|
@ -6,7 +6,6 @@ import org.hamcrest.Matchers;
|
|||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
|
@ -126,8 +125,6 @@ public class UserStorageTest extends AbstractAuthTest {
|
|||
|
||||
@Before
|
||||
public void addProvidersBeforeTest() throws URISyntaxException, IOException {
|
||||
Assume.assumeTrue("User cache disabled.", isUserCacheEnabled());
|
||||
|
||||
ComponentRepresentation memProvider = new ComponentRepresentation();
|
||||
memProvider.setName("memory");
|
||||
memProvider.setProviderId(UserMapStorageFactory.PROVIDER_ID);
|
||||
|
|
|
@ -38,8 +38,6 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
|
||||
/**
|
||||
* Test with Dummy providers
|
||||
|
@ -51,11 +49,6 @@ public class SyncFederationTest extends AbstractAuthTest {
|
|||
|
||||
private static final Logger log = Logger.getLogger(SyncFederationTest.class);
|
||||
|
||||
@Before
|
||||
public void enabled() {
|
||||
Assume.assumeTrue("RealmProvider is not 'jpa'", isJpaRealmProvider());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that period sync is triggered when creating a synchronized User Storage Provider
|
||||
*
|
||||
|
|
|
@ -188,8 +188,6 @@ public class RegisterTest extends AbstractTestRealmKeycloakTest {
|
|||
|
||||
@Test
|
||||
public void registerUpperCaseEmailWithChangedEmailAsUsername() throws IOException {
|
||||
Assume.assumeTrue("See https://github.com/keycloak/keycloak/issues/10245", isUserCacheEnabled());
|
||||
|
||||
String userId = registerUpperCaseAndGetUserId(false);
|
||||
assertThat(userId, notNullValue());
|
||||
oauth.openLogout();
|
||||
|
|
|
@ -31,7 +31,7 @@ public class BadRealmTest extends AbstractKeycloakTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@ModelTest(skipForMapStorage = true) // when map storage is enabled, the id is always converted into a valid UUID.
|
||||
@ModelTest
|
||||
public void testBadRealmId(KeycloakSession session) {
|
||||
RealmManager manager = new RealmManager(session);
|
||||
try {
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.keycloak.testsuite.model;
|
||||
|
||||
import org.junit.Assume;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.models.ClientModel;
|
||||
import org.keycloak.models.RealmModel;
|
||||
|
@ -44,62 +43,44 @@ import org.keycloak.representations.idm.RealmRepresentation;
|
|||
*/
|
||||
public class CacheTest extends AbstractTestRealmKeycloakTest {
|
||||
|
||||
private ClientModel testApp = null;
|
||||
private int grantedRolesCount=0;
|
||||
private RealmModel realm = null;
|
||||
private UserModel user = null;
|
||||
|
||||
@Override
|
||||
public void configureTestRealm(RealmRepresentation testRealm) {
|
||||
}
|
||||
@Override
|
||||
public void configureTestRealm(RealmRepresentation testRealm) {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaleCache() throws Exception {
|
||||
Assume.assumeTrue("Realm cache disabled.", isRealmCacheEnabled());
|
||||
testingClient.server().run(session -> {
|
||||
String appId = null;
|
||||
{
|
||||
// load up cache
|
||||
@Test
|
||||
public void testStaleCache() throws Exception {
|
||||
testingClient.server().run(session -> {
|
||||
// load up cache
|
||||
RealmModel realm = session.realms().getRealmByName("test");
|
||||
assertTrue(realm instanceof RealmAdapter);
|
||||
ClientModel testApp = realm.getClientByClientId("test-app");
|
||||
assertTrue(testApp instanceof ClientAdapter);
|
||||
assertNotNull(testApp);
|
||||
String appId = testApp.getId();
|
||||
assertTrue(testApp.isEnabled());
|
||||
|
||||
RealmModel realm = session.realms().getRealmByName("test");
|
||||
assertTrue(realm instanceof RealmAdapter);
|
||||
ClientModel testApp = realm.getClientByClientId("test-app");
|
||||
assertTrue(testApp instanceof ClientAdapter);
|
||||
assertNotNull(testApp);
|
||||
appId = testApp.getId();
|
||||
assertTrue(testApp.isEnabled());
|
||||
|
||||
|
||||
|
||||
// update realm, then get an AppModel and change it. The AppModel would not be a cache adapter
|
||||
// update realm, then get an AppModel and change it. The AppModel would not be a cache adapter
|
||||
realm = session.realms().getRealmsStream().filter(r -> {
|
||||
assertTrue(r instanceof RealmAdapter);
|
||||
return "test".equals(r.getName());
|
||||
}).findFirst().orElse(null);
|
||||
|
||||
realm = session.realms().getRealmsStream().filter(r -> {
|
||||
assertTrue(r instanceof RealmAdapter);
|
||||
if ("test".equals(r.getName()))
|
||||
return true;
|
||||
return false;
|
||||
}).findFirst().orElse(null);
|
||||
assertNotNull(realm);
|
||||
|
||||
assertNotNull(realm);
|
||||
realm.setAccessCodeLifespanLogin(200);
|
||||
testApp = realm.getClientByClientId("test-app");
|
||||
|
||||
realm.setAccessCodeLifespanLogin(200);
|
||||
testApp = realm.getClientByClientId("test-app");
|
||||
assertNotNull(testApp);
|
||||
testApp.setEnabled(false);
|
||||
|
||||
// make sure that app cache was flushed and enabled changed
|
||||
realm = session.realms().getRealmByName("test");
|
||||
Assert.assertEquals(200, realm.getAccessCodeLifespanLogin());
|
||||
testApp = session.clients().getClientById(realm, appId);
|
||||
Assert.assertFalse(testApp.isEnabled());
|
||||
});
|
||||
}
|
||||
|
||||
assertNotNull(testApp);
|
||||
testApp.setEnabled(false);
|
||||
|
||||
|
||||
// make sure that app cache was flushed and enabled changed
|
||||
|
||||
|
||||
realm = session.realms().getRealmByName("test");
|
||||
Assert.assertEquals(200, realm.getAccessCodeLifespanLogin());
|
||||
testApp = session.clients().getClientById(realm, appId);
|
||||
Assert.assertFalse(testApp.isEnabled());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@Test
|
||||
public void testAddUserNotAddedToCache() {
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ public class ConcurrentTransactionsTest extends AbstractTestRealmKeycloakTest {
|
|||
|
||||
// KEYCLOAK-3296 , KEYCLOAK-3494
|
||||
@Test
|
||||
@ModelTest(skipForMapStorage = true) // skipped for map storage - to be revisited (GHI #12910)
|
||||
@ModelTest
|
||||
public void removeUserAttribute(KeycloakSession session) throws Exception {
|
||||
|
||||
try {
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.keycloak.testsuite.model;
|
|||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.component.ComponentModel;
|
||||
|
@ -58,7 +57,6 @@ public class UserConsentWithUserStorageModelTest extends AbstractTestRealmKeyclo
|
|||
|
||||
@Before
|
||||
public void before() {
|
||||
Assume.assumeTrue("RealmProvider is not 'jpa'", isJpaRealmProvider());
|
||||
testingClient.server().run(UserConsentWithUserStorageModelTest::setupEnv);
|
||||
}
|
||||
|
||||
|
|
|
@ -267,8 +267,6 @@ public class X509DirectGrantTest extends AbstractX509AuthenticationTest {
|
|||
|
||||
@Test
|
||||
public void loginCertificateExpired() throws Exception {
|
||||
Assume.assumeFalse("Time offset is causing integer overflow. With the old store it works, because root authentication session has also timestamp overflown, this is not true for the new store so the test is failing.", keycloakUsingProviderWithId(AuthenticationSessionProvider.class, "map"));
|
||||
|
||||
X509AuthenticatorConfigModel config =
|
||||
new X509AuthenticatorConfigModel()
|
||||
.setCertValidationEnabled(true)
|
||||
|
|
Loading…
Reference in a new issue