[KEYCLOAK-7872] Fix. Remove Identity Provider Mapper when remove identity provider
This commit is contained in:
parent
0844aa8d68
commit
771d7f1724
2 changed files with 42 additions and 1 deletions
|
@ -70,6 +70,7 @@ import java.util.HashMap;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @resource Identity Providers
|
||||
|
@ -128,7 +129,13 @@ public class IdentityProviderResource {
|
|||
throw new javax.ws.rs.NotFoundException();
|
||||
}
|
||||
|
||||
this.realm.removeIdentityProviderByAlias(this.identityProviderModel.getAlias());
|
||||
String alias = this.identityProviderModel.getAlias();
|
||||
this.realm.removeIdentityProviderByAlias(alias);
|
||||
|
||||
Set<IdentityProviderMapperModel> mappers = this.realm.getIdentityProviderMappersByAlias(alias);
|
||||
for (IdentityProviderMapperModel mapper : mappers) {
|
||||
this.realm.removeIdentityProviderMapper(mapper);
|
||||
}
|
||||
|
||||
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success();
|
||||
|
||||
|
|
|
@ -60,8 +60,10 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasEntry;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -485,6 +487,38 @@ public class IdentityProviderTest extends AbstractAdminTest {
|
|||
assertEquals("offline_access", mappers.get(0).getConfig().get("role"));
|
||||
}
|
||||
|
||||
// KEYCLOAK-7872
|
||||
@Test
|
||||
public void testDeleteProtocolMappersAfterDeleteIdentityProvider() {
|
||||
create(createRep("google3", "google"));
|
||||
|
||||
IdentityProviderResource provider = realm.identityProviders().get("google3");
|
||||
|
||||
IdentityProviderMapperRepresentation mapper = new IdentityProviderMapperRepresentation();
|
||||
mapper.setIdentityProviderAlias("google3");
|
||||
mapper.setName("my_mapper");
|
||||
mapper.setIdentityProviderMapper("oidc-hardcoded-role-idp-mapper");
|
||||
Map<String, String> config = new HashMap<>();
|
||||
config.put("role", "offline_access");
|
||||
mapper.setConfig(config);
|
||||
|
||||
Response response = provider.addMapper(mapper);
|
||||
|
||||
List<IdentityProviderMapperRepresentation> mappers = provider.getMappers();
|
||||
assertThat(mappers, hasSize(1));
|
||||
|
||||
assertAdminEvents.clear();
|
||||
|
||||
provider.remove();
|
||||
assertAdminEvents.assertEvent(realmId, OperationType.DELETE, AdminEventPaths.identityProviderPath("google3"), ResourceType.IDENTITY_PROVIDER);
|
||||
|
||||
create(createRep("google3", "google"));
|
||||
|
||||
IdentityProviderResource newProvider = realm.identityProviders().get("google3");
|
||||
|
||||
assertThat(newProvider.getMappers(), empty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInstalledIdentityProviders() {
|
||||
Response response = realm.identityProviders().getIdentityProviders("oidc");
|
||||
|
|
Loading…
Reference in a new issue