Merge pull request #3123 from patriot1burke/master

components import/export
This commit is contained in:
Bill Burke 2016-08-09 20:58:20 -04:00 committed by GitHub
commit 741bbf471f
17 changed files with 357 additions and 7 deletions

View file

@ -0,0 +1,72 @@
/*
* Copyright 2016 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.representations.idm;
import org.keycloak.common.util.MultivaluedHashMap;
/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/
public class ComponentExportRepresentation {
private String id;
private String name;
private String providerId;
private MultivaluedHashMap<String, ComponentExportRepresentation> subComponents = new MultivaluedHashMap<>();
private MultivaluedHashMap<String, String> config = new MultivaluedHashMap<>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getProviderId() {
return providerId;
}
public void setProviderId(String providerId) {
this.providerId = providerId;
}
public MultivaluedHashMap<String, String> getConfig() {
return config;
}
public void setConfig(MultivaluedHashMap<String, String> config) {
this.config = config;
}
public MultivaluedHashMap<String, ComponentExportRepresentation> getSubComponents() {
return subComponents;
}
public void setSubComponents(MultivaluedHashMap<String, ComponentExportRepresentation> subComponents) {
this.subComponents = subComponents;
}
}

View file

@ -18,6 +18,7 @@
package org.keycloak.representations.idm; package org.keycloak.representations.idm;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import org.keycloak.common.util.MultivaluedHashMap;
import java.util.*; import java.util.*;
@ -109,6 +110,7 @@ public class RealmRepresentation {
private List<IdentityProviderRepresentation> identityProviders; private List<IdentityProviderRepresentation> identityProviders;
private List<IdentityProviderMapperRepresentation> identityProviderMappers; private List<IdentityProviderMapperRepresentation> identityProviderMappers;
private List<ProtocolMapperRepresentation> protocolMappers; private List<ProtocolMapperRepresentation> protocolMappers;
private MultivaluedHashMap<String, ComponentExportRepresentation> components;
protected Boolean internationalizationEnabled; protected Boolean internationalizationEnabled;
protected Set<String> supportedLocales; protected Set<String> supportedLocales;
protected String defaultLocale; protected String defaultLocale;
@ -849,6 +851,14 @@ public class RealmRepresentation {
this.clientTemplates = clientTemplates; this.clientTemplates = clientTemplates;
} }
public MultivaluedHashMap<String, ComponentExportRepresentation> getComponents() {
return components;
}
public void setComponents(MultivaluedHashMap<String, ComponentExportRepresentation> components) {
this.components = components;
}
@JsonIgnore @JsonIgnore
public boolean isIdentityFederationEnabled() { public boolean isIdentityFederationEnabled() {
return identityProviders != null && !identityProviders.isEmpty(); return identityProviders != null && !identityProviders.isEmpty();

View file

@ -0,0 +1,44 @@
/*
* Copyright 2016 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.admin.client.resource;
import org.jboss.resteasy.spi.NotFoundException;
import org.keycloak.representations.idm.ComponentRepresentation;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public interface ComponentResource {
@GET
public ComponentRepresentation toRepresentation();
@PUT
@Consumes(MediaType.APPLICATION_JSON)
public void update(ComponentRepresentation rep);
@DELETE
public void remove();
}

View file

@ -0,0 +1,57 @@
/*
* Copyright 2016 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.admin.client.resource;
import org.keycloak.representations.idm.ComponentRepresentation;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List;
/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public interface ComponentsResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<ComponentRepresentation> query();
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<ComponentRepresentation> query(@QueryParam("parent") String parent);
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<ComponentRepresentation> query(@QueryParam("parent") String parent, @QueryParam("type") String type);
@POST
@Consumes(MediaType.APPLICATION_JSON)
Response add(ComponentRepresentation rep);
@Path("{id}")
ComponentResource component(@PathParam("id") String id);
}

View file

@ -38,7 +38,7 @@ public interface GroupsResource {
@GET @GET
@NoCache @NoCache
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public List<GroupRepresentation> groups(); List<GroupRepresentation> groups();
/** /**
* create or add a top level realm groupSet or create child. This will update the group and set the parent if it exists. Create it and set the parent * create or add a top level realm groupSet or create child. This will update the group and set the parent if it exists. Create it and set the parent
@ -48,9 +48,9 @@ public interface GroupsResource {
*/ */
@POST @POST
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Response add(GroupRepresentation rep); Response add(GroupRepresentation rep);
@Path("{id}") @Path("{id}")
public GroupResource group(@PathParam("id") String id); GroupResource group(@PathParam("id") String id);
} }

View file

@ -193,4 +193,7 @@ public interface RealmResource {
@DELETE @DELETE
void deleteSession(@PathParam("session") String sessionId); void deleteSession(@PathParam("session") String sessionId);
@Path("components")
ComponentsResource components();
} }

View file

@ -1438,7 +1438,15 @@ public class RealmAdapter implements RealmModel {
@Override @Override
public List<ComponentModel> getComponents(String parentId, String providerType) { public List<ComponentModel> getComponents(String parentId, String providerType) {
if (isUpdated()) return updated.getComponents(parentId, providerType); if (isUpdated()) return updated.getComponents(parentId, providerType);
List<ComponentModel> components = cached.getComponentsByParent().getList(parentId + providerType); List<ComponentModel> components = cached.getComponentsByParentAndType().getList(parentId + providerType);
if (components == null) return Collections.EMPTY_LIST;
return Collections.unmodifiableList(components);
}
@Override
public List<ComponentModel> getComponents(String parentId) {
if (isUpdated()) return updated.getComponents(parentId);
List<ComponentModel> components = cached.getComponentsByParent().getList(parentId);
if (components == null) return Collections.EMPTY_LIST; if (components == null) return Collections.EMPTY_LIST;
return Collections.unmodifiableList(components); return Collections.unmodifiableList(components);
} }

View file

@ -107,6 +107,7 @@ public class CachedRealm extends AbstractRevisioned {
protected List<RequiredCredentialModel> requiredCredentials; protected List<RequiredCredentialModel> requiredCredentials;
protected List<UserFederationProviderModel> userFederationProviders; protected List<UserFederationProviderModel> userFederationProviders;
protected MultivaluedHashMap<String, ComponentModel> componentsByParent = new MultivaluedHashMap<>(); protected MultivaluedHashMap<String, ComponentModel> componentsByParent = new MultivaluedHashMap<>();
protected MultivaluedHashMap<String, ComponentModel> componentsByParentAndType = new MultivaluedHashMap<>();
protected Map<String, ComponentModel> components = new HashMap<>(); protected Map<String, ComponentModel> components = new HashMap<>();
protected MultivaluedHashMap<String, UserFederationMapperModel> userFederationMappers = new MultivaluedHashMap<String, UserFederationMapperModel>(); protected MultivaluedHashMap<String, UserFederationMapperModel> userFederationMappers = new MultivaluedHashMap<String, UserFederationMapperModel>();
protected Set<UserFederationMapperModel> userFederationMapperSet; protected Set<UserFederationMapperModel> userFederationMapperSet;
@ -275,7 +276,10 @@ public class CachedRealm extends AbstractRevisioned {
clientAuthenticationFlow = model.getClientAuthenticationFlow(); clientAuthenticationFlow = model.getClientAuthenticationFlow();
for (ComponentModel component : model.getComponents()) { for (ComponentModel component : model.getComponents()) {
componentsByParent.add(component.getParentId() + component.getProviderType(), component); componentsByParentAndType.add(component.getParentId() + component.getProviderType(), component);
}
for (ComponentModel component : model.getComponents()) {
componentsByParent.add(component.getParentId(), component);
} }
for (ComponentModel component : model.getComponents()) { for (ComponentModel component : model.getComponents()) {
components.put(component.getId(), component); components.put(component.getId(), component);
@ -608,6 +612,10 @@ public class CachedRealm extends AbstractRevisioned {
return componentsByParent; return componentsByParent;
} }
public MultivaluedHashMap<String, ComponentModel> getComponentsByParentAndType() {
return componentsByParentAndType;
}
public Map<String, ComponentModel> getComponents() { public Map<String, ComponentModel> getComponents() {
return components; return components;
} }

View file

@ -2195,6 +2195,21 @@ public class RealmAdapter implements RealmModel, JpaModel<RealmEntity> {
return rtn; return rtn;
} }
@Override
public List<ComponentModel> getComponents(String parentId) {
TypedQuery<ComponentEntity> query = em.createNamedQuery("getComponentsByParent", ComponentEntity.class)
.setParameter("realm", realm)
.setParameter("parentId", parentId);
List<ComponentEntity> results = query.getResultList();
List<ComponentModel> rtn = new LinkedList<>();
for (ComponentEntity c : results) {
ComponentModel model = entityToModel(c);
rtn.add(model);
}
return rtn;
}
protected ComponentModel entityToModel(ComponentEntity c) { protected ComponentModel entityToModel(ComponentEntity c) {
ComponentModel model = new ComponentModel(); ComponentModel model = new ComponentModel();
model.setId(c.getId()); model.setId(c.getId());

View file

@ -44,6 +44,7 @@ import java.util.Map;
@NamedQueries({ @NamedQueries({
@NamedQuery(name="getComponents", query="select attr from ComponentEntity attr where attr.realm = :realm"), @NamedQuery(name="getComponents", query="select attr from ComponentEntity attr where attr.realm = :realm"),
@NamedQuery(name="getComponentsByParentAndType", query="select attr from ComponentEntity attr where attr.realm = :realm and attr.providerType = :providerType and attr.parentId = :parentId"), @NamedQuery(name="getComponentsByParentAndType", query="select attr from ComponentEntity attr where attr.realm = :realm and attr.providerType = :providerType and attr.parentId = :parentId"),
@NamedQuery(name="getComponentByParent", query="select attr from ComponentEntity attr where attr.realm = :realm and attr.parentId = :parentId"),
@NamedQuery(name="getComponentIdsByParent", query="select attr.id from ComponentEntity attr where attr.realm = :realm and attr.parentId = :parentId"), @NamedQuery(name="getComponentIdsByParent", query="select attr.id from ComponentEntity attr where attr.realm = :realm and attr.parentId = :parentId"),
@NamedQuery(name="deleteComponentByRealm", query="delete from ComponentEntity c where c.realm = :realm"), @NamedQuery(name="deleteComponentByRealm", query="delete from ComponentEntity c where c.realm = :realm"),
@NamedQuery(name="deleteComponentByParent", query="delete from ComponentEntity c where c.parentId = :parentId") @NamedQuery(name="deleteComponentByParent", query="delete from ComponentEntity c where c.parentId = :parentId")

View file

@ -2135,6 +2135,19 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
return results; return results;
} }
@Override
public List<ComponentModel> getComponents(String parentId) {
List<ComponentModel> results = new LinkedList<>();
for (ComponentEntity entity : realm.getComponentEntities()) {
if (entity.getParentId().equals(parentId)) {
ComponentModel model = entityToModel(entity);
results.add(model);
}
}
return results;
}
protected ComponentModel entityToModel(ComponentEntity entity) { protected ComponentModel entityToModel(ComponentEntity entity) {
ComponentModel model = new ComponentModel(); ComponentModel model = new ComponentModel();
model.setId(entity.getId()); model.setId(entity.getId());

View file

@ -291,6 +291,9 @@ public interface RealmModel extends RoleContainerModel {
void removeComponent(ComponentModel component); void removeComponent(ComponentModel component);
void removeComponents(String parentId); void removeComponents(String parentId);
List<ComponentModel> getComponents(String parentId, String providerType); List<ComponentModel> getComponents(String parentId, String providerType);
List<ComponentModel> getComponents(String parentId);
List<ComponentModel> getComponents(); List<ComponentModel> getComponents();
ComponentModel getComponent(String id); ComponentModel getComponent(String id);

View file

@ -763,6 +763,7 @@ public class ModelToRepresentation {
rep.setName(component.getName()); rep.setName(component.getName());
rep.setProviderId(component.getProviderId()); rep.setProviderId(component.getProviderId());
rep.setProviderType(component.getProviderType()); rep.setProviderType(component.getProviderType());
rep.setParentId(component.getParentId());
rep.setConfig(component.getConfig()); rep.setConfig(component.getConfig());
return rep; return rep;
} }

View file

@ -20,6 +20,7 @@ package org.keycloak.models.utils;
import org.keycloak.authorization.AuthorizationProvider; import org.keycloak.authorization.AuthorizationProvider;
import org.keycloak.authorization.model.ResourceServer; import org.keycloak.authorization.model.ResourceServer;
import org.keycloak.authorization.store.ResourceServerStore; import org.keycloak.authorization.store.ResourceServerStore;
import org.keycloak.common.util.MultivaluedHashMap;
import org.keycloak.component.ComponentModel; import org.keycloak.component.ComponentModel;
import org.keycloak.hash.Pbkdf2PasswordHashProvider; import org.keycloak.hash.Pbkdf2PasswordHashProvider;
import org.keycloak.migration.migrators.MigrationUtils; import org.keycloak.migration.migrators.MigrationUtils;
@ -63,6 +64,7 @@ import org.keycloak.representations.idm.AuthenticatorConfigRepresentation;
import org.keycloak.representations.idm.ClaimRepresentation; import org.keycloak.representations.idm.ClaimRepresentation;
import org.keycloak.representations.idm.ClientRepresentation; import org.keycloak.representations.idm.ClientRepresentation;
import org.keycloak.representations.idm.ClientTemplateRepresentation; import org.keycloak.representations.idm.ClientTemplateRepresentation;
import org.keycloak.representations.idm.ComponentExportRepresentation;
import org.keycloak.representations.idm.ComponentRepresentation; import org.keycloak.representations.idm.ComponentRepresentation;
import org.keycloak.representations.idm.CredentialRepresentation; import org.keycloak.representations.idm.CredentialRepresentation;
import org.keycloak.representations.idm.FederatedIdentityRepresentation; import org.keycloak.representations.idm.FederatedIdentityRepresentation;
@ -285,6 +287,12 @@ public class RepresentationToModel {
newRealm.setBrowserSecurityHeaders(BrowserSecurityHeaders.defaultHeaders); newRealm.setBrowserSecurityHeaders(BrowserSecurityHeaders.defaultHeaders);
} }
if (rep.getComponents() != null) {
MultivaluedHashMap<String, ComponentExportRepresentation> components = rep.getComponents();
String parentId = newRealm.getId();
importComponents(newRealm, components, parentId);
}
List<UserFederationProviderModel> providerModels = null; List<UserFederationProviderModel> providerModels = null;
if (rep.getUserFederationProviders() != null) { if (rep.getUserFederationProviders() != null) {
providerModels = convertFederationProviders(rep.getUserFederationProviders()); providerModels = convertFederationProviders(rep.getUserFederationProviders());
@ -346,6 +354,25 @@ public class RepresentationToModel {
} }
} }
protected static void importComponents(RealmModel newRealm, MultivaluedHashMap<String, ComponentExportRepresentation> components, String parentId) {
for (Map.Entry<String, List<ComponentExportRepresentation>> entry : components.entrySet()) {
String providerType = entry.getKey();
for (ComponentExportRepresentation compRep : entry.getValue()) {
ComponentModel component = new ComponentModel();
component.setId(compRep.getId());
component.setName(compRep.getName());
component.setConfig(compRep.getConfig());
component.setProviderType(providerType);
component.setProviderId(compRep.getProviderId());
component.setParentId(parentId);
component = newRealm.addComponentModel(component);
if (compRep.getSubComponents() != null) {
importComponents(newRealm, compRep.getSubComponents(), component.getId());
}
}
}
}
public static void importRoles(RolesRepresentation realmRoles, RealmModel realm) { public static void importRoles(RolesRepresentation realmRoles, RealmModel realm) {
if (realmRoles == null) return; if (realmRoles == null) return;

View file

@ -24,6 +24,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import org.keycloak.common.Version; import org.keycloak.common.Version;
import org.keycloak.common.util.Base64; import org.keycloak.common.util.Base64;
import org.keycloak.common.util.MultivaluedHashMap;
import org.keycloak.component.ComponentModel;
import org.keycloak.models.*; import org.keycloak.models.*;
import org.keycloak.models.utils.ModelToRepresentation; import org.keycloak.models.utils.ModelToRepresentation;
import org.keycloak.representations.idm.*; import org.keycloak.representations.idm.*;
@ -178,9 +180,28 @@ public class ExportUtils {
} }
} }
// components
MultivaluedHashMap<String, ComponentExportRepresentation> components = exportComponents(realm, realm.getId());
rep.setComponents(components);
return rep; return rep;
} }
public static MultivaluedHashMap<String, ComponentExportRepresentation> exportComponents(RealmModel realm, String parentId) {
List<ComponentModel> componentList = realm.getComponents(parentId);
MultivaluedHashMap<String, ComponentExportRepresentation> components = new MultivaluedHashMap<>();
for (ComponentModel component : componentList) {
ComponentExportRepresentation compRep = new ComponentExportRepresentation();
compRep.setId(component.getId());
compRep.setProviderId(component.getProviderId());
compRep.setConfig(component.getConfig());
compRep.setName(component.getName());
compRep.setSubComponents(exportComponents(realm, component.getId()));
components.add(component.getProviderType(), compRep);
}
return components;
}
/** /**
* Full export of application including claims and secret * Full export of application including claims and secret
* @param client * @param client

View file

@ -42,6 +42,7 @@ import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo; import javax.ws.rs.core.UriInfo;
import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -82,8 +83,15 @@ public class ComponentResource {
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public List<ComponentRepresentation> getComponents(@QueryParam("parent") String parent, @QueryParam("type") String type) { public List<ComponentRepresentation> getComponents(@QueryParam("parent") String parent, @QueryParam("type") String type) {
auth.requireManage(); auth.requireManage();
if (parent == null) parent = realm.getId(); List<ComponentModel> components = Collections.EMPTY_LIST;
List<ComponentModel> components = realm.getComponents(parent, type); if (parent == null) {
components = realm.getComponents();
} else if (type == null) {
components = realm.getComponents(parent);
} else {
components = realm.getComponents(parent, type);
}
List<ComponentRepresentation> reps = new LinkedList<>(); List<ComponentRepresentation> reps = new LinkedList<>();
for (ComponentModel component : components) { for (ComponentModel component : components) {
ComponentRepresentation rep = ModelToRepresentation.toRepresentation(component); ComponentRepresentation rep = ModelToRepresentation.toRepresentation(component);

View file

@ -19,10 +19,12 @@ package org.keycloak.testsuite.exportimport;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.keycloak.common.util.MultivaluedHashMap;
import org.keycloak.exportimport.ExportImportConfig; import org.keycloak.exportimport.ExportImportConfig;
import org.keycloak.exportimport.dir.DirExportProvider; import org.keycloak.exportimport.dir.DirExportProvider;
import org.keycloak.exportimport.dir.DirExportProviderFactory; 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.RealmRepresentation; import org.keycloak.representations.idm.RealmRepresentation;
import java.io.File; import java.io.File;
@ -138,6 +140,63 @@ public class ExportImportTest extends AbstractExportImportTest {
ExportImportUtil.assertDataImportedInRealm(adminClient, testingClient, testRealmRealm.toRepresentation()); ExportImportUtil.assertDataImportedInRealm(adminClient, testingClient, testRealmRealm.toRepresentation());
} }
@Test
public void testComponentExportImport() throws Throwable {
RealmRepresentation realmRep = new RealmRepresentation();
realmRep.setRealm("component-realm");
adminClient.realms().create(realmRep);
Assert.assertEquals(4, adminClient.realms().findAll().size());
RealmResource realm = adminClient.realm("component-realm");
realmRep = realm.toRepresentation();
ComponentRepresentation component = new ComponentRepresentation();
component.setProviderId("dummy");
component.setProviderType("dummyType");
component.setName("dummy-name");
component.setParentId(realmRep.getId());
component.setConfig(new MultivaluedHashMap<>());
component.getConfig().add("name", "value");
realm.components().add(component);
ExportImportConfig.setProvider(SingleFileExportProviderFactory.PROVIDER_ID);
String targetFilePath = getExportImportTestDirectory() + File.separator + "singleFile-realm.json";
ExportImportConfig.setFile(targetFilePath);
ExportImportConfig.setAction(ExportImportConfig.ACTION_EXPORT);
ExportImportConfig.setRealmName("component-realm");
testingClient.testing().runExport();
// Delete some realm (and some data in admin realm)
adminClient.realm("component-realm").remove();
Assert.assertEquals(3, adminClient.realms().findAll().size());
// Configure import
ExportImportConfig.setAction(ExportImportConfig.ACTION_IMPORT);
testingClient.testing().runImport();
realmRep = realm.toRepresentation();
List<ComponentRepresentation> components = realm.components().query();
Assert.assertEquals(1, components.size());
component = components.get(0);
Assert.assertEquals("dummy-name", component.getName());
Assert.assertEquals("dummyType", component.getProviderType());
Assert.assertEquals("dummy", component.getProviderId());
Assert.assertEquals(realmRep.getId(), component.getParentId());
Assert.assertEquals(1, component.getConfig().size());
Assert.assertEquals("value", component.getConfig().getFirst("name"));
adminClient.realm("component-realm").remove();
}
private void removeRealm(String realmName) { private void removeRealm(String realmName) {
adminClient.realm(realmName).remove(); adminClient.realm(realmName).remove();