Merge pull request #4140 from mstruk/RHSSO-978
RHSSO-978 Cannot migrate event types using export/import
This commit is contained in:
commit
ff2d6941d0
2 files changed
+24
No files matched your search
@@ -151,6 +151,8 @@ public class RepresentationToModel {
|
|||||||
if (rep.getMaxDeltaTimeSeconds() != null) newRealm.setMaxDeltaTimeSeconds(rep.getMaxDeltaTimeSeconds());
|
if (rep.getMaxDeltaTimeSeconds() != null) newRealm.setMaxDeltaTimeSeconds(rep.getMaxDeltaTimeSeconds());
|
||||||
if (rep.getFailureFactor() != null) newRealm.setFailureFactor(rep.getFailureFactor());
|
if (rep.getFailureFactor() != null) newRealm.setFailureFactor(rep.getFailureFactor());
|
||||||
if (rep.isEventsEnabled() != null) newRealm.setEventsEnabled(rep.isEventsEnabled());
|
if (rep.isEventsEnabled() != null) newRealm.setEventsEnabled(rep.isEventsEnabled());
|
||||||
|
if (rep.getEnabledEventTypes() != null)
|
||||||
|
newRealm.setEnabledEventTypes(new HashSet<>(rep.getEnabledEventTypes()));
|
||||||
if (rep.getEventsExpiration() != null) newRealm.setEventsExpiration(rep.getEventsExpiration());
|
if (rep.getEventsExpiration() != null) newRealm.setEventsExpiration(rep.getEventsExpiration());
|
||||||
if (rep.getEventsListeners() != null) newRealm.setEventsListeners(new HashSet<>(rep.getEventsListeners()));
|
if (rep.getEventsListeners() != null) newRealm.setEventsListeners(new HashSet<>(rep.getEventsListeners()));
|
||||||
if (rep.isAdminEventsEnabled() != null) newRealm.setAdminEventsEnabled(rep.isAdminEventsEnabled());
|
if (rep.isAdminEventsEnabled() != null) newRealm.setAdminEventsEnabled(rep.isAdminEventsEnabled());
|
||||||
|
|||||||
+22
@@ -27,6 +27,7 @@ import org.keycloak.exportimport.dir.DirExportProviderFactory;
|
|||||||
import org.keycloak.exportimport.singlefile.SingleFileExportProviderFactory;
|
import org.keycloak.exportimport.singlefile.SingleFileExportProviderFactory;
|
||||||
import org.keycloak.representations.idm.ComponentRepresentation;
|
import org.keycloak.representations.idm.ComponentRepresentation;
|
||||||
import org.keycloak.representations.idm.KeysMetadataRepresentation;
|
import org.keycloak.representations.idm.KeysMetadataRepresentation;
|
||||||
|
import org.keycloak.representations.idm.RealmEventsConfigRepresentation;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
import org.keycloak.representations.idm.UserRepresentation;
|
import org.keycloak.representations.idm.UserRepresentation;
|
||||||
import org.keycloak.testsuite.AbstractKeycloakTest;
|
import org.keycloak.testsuite.AbstractKeycloakTest;
|
||||||
@@ -35,6 +36,7 @@ import org.keycloak.testsuite.util.UserBuilder;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -58,6 +60,8 @@ public class ExportImportTest extends AbstractKeycloakTest {
|
|||||||
testRealm1.getUsers().add(makeUser("user1"));
|
testRealm1.getUsers().add(makeUser("user1"));
|
||||||
testRealm1.getUsers().add(makeUser("user2"));
|
testRealm1.getUsers().add(makeUser("user2"));
|
||||||
testRealm1.getUsers().add(makeUser("user3"));
|
testRealm1.getUsers().add(makeUser("user3"));
|
||||||
|
|
||||||
|
setEventsConfig(testRealm1);
|
||||||
testRealms.add(testRealm1);
|
testRealms.add(testRealm1);
|
||||||
|
|
||||||
RealmRepresentation testRealm2 = loadJson(getClass().getResourceAsStream("/model/testrealm.json"), RealmRepresentation.class);
|
RealmRepresentation testRealm2 = loadJson(getClass().getResourceAsStream("/model/testrealm.json"), RealmRepresentation.class);
|
||||||
@@ -65,6 +69,22 @@ public class ExportImportTest extends AbstractKeycloakTest {
|
|||||||
testRealms.add(testRealm2);
|
testRealms.add(testRealm2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setEventsConfig(RealmRepresentation realm) {
|
||||||
|
realm.setEventsEnabled(true);
|
||||||
|
realm.setAdminEventsEnabled(true);
|
||||||
|
realm.setAdminEventsDetailsEnabled(true);
|
||||||
|
realm.setEventsExpiration(600);
|
||||||
|
realm.setEnabledEventTypes(Arrays.asList("REGISTER", "REGISTER_ERROR", "LOGIN", "LOGIN_ERROR", "LOGOUT_ERROR"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkEventsConfig(RealmEventsConfigRepresentation config) {
|
||||||
|
Assert.assertTrue(config.isEventsEnabled());
|
||||||
|
Assert.assertTrue(config.isAdminEventsEnabled());
|
||||||
|
Assert.assertTrue(config.isAdminEventsDetailsEnabled());
|
||||||
|
Assert.assertEquals((Long) 600L, config.getEventsExpiration());
|
||||||
|
Assert.assertNames(new HashSet(config.getEnabledEventTypes()),"REGISTER", "REGISTER_ERROR", "LOGIN", "LOGIN_ERROR", "LOGOUT_ERROR");
|
||||||
|
}
|
||||||
|
|
||||||
private UserRepresentation makeUser(String userName) {
|
private UserRepresentation makeUser(String userName) {
|
||||||
return UserBuilder.create()
|
return UserBuilder.create()
|
||||||
.username(userName)
|
.username(userName)
|
||||||
@@ -222,6 +242,8 @@ public class ExportImportTest extends AbstractKeycloakTest {
|
|||||||
|
|
||||||
String importedSampleClientRoleId = adminClient.realm("test").clients().get(testAppId).roles().get("sample-client-role").toRepresentation().getId();
|
String importedSampleClientRoleId = adminClient.realm("test").clients().get(testAppId).roles().get("sample-client-role").toRepresentation().getId();
|
||||||
assertEquals(sampleClientRoleId, importedSampleClientRoleId);
|
assertEquals(sampleClientRoleId, importedSampleClientRoleId);
|
||||||
|
|
||||||
|
checkEventsConfig(adminClient.realm("test").getRealmEventsConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertAuthenticated(String realmName, String username, String password) {
|
private void assertAuthenticated(String realmName, String username, String password) {
|
||||||
|
|||||||
Reference in new issue
Block a user