Search in sources :

Example 6 with ComponentTypeRepresentation

use of org.keycloak.representations.idm.ComponentTypeRepresentation in project keycloak by keycloak.

the class UserStorageRestTest method findMapperTypeConfiguration.

private ComponentTypeRepresentation findMapperTypeConfiguration(String ldapModelId, String mapperProviderId) {
    ComponentResource ldapProvider = realm.components().component(ldapModelId);
    List<ComponentTypeRepresentation> componentTypes = ldapProvider.getSubcomponentConfig(LDAPStorageMapper.class.getName());
    return componentTypes.stream().filter(componentType -> mapperProviderId.equals(componentType.getId())).findFirst().orElseThrow(() -> new IllegalStateException("Not able to find mapper with provider id: " + mapperProviderId));
}
Also used : LDAPStorageMapper(org.keycloak.storage.ldap.mappers.LDAPStorageMapper) ComponentResource(org.keycloak.admin.client.resource.ComponentResource) ComponentTypeRepresentation(org.keycloak.representations.idm.ComponentTypeRepresentation)

Example 7 with ComponentTypeRepresentation

use of org.keycloak.representations.idm.ComponentTypeRepresentation in project keycloak by keycloak.

the class UserStorageRestTest method testLDAPMapperProviderConfigurationForVendorMSAD.

// KEYCLOAK-12934
@Test
public void testLDAPMapperProviderConfigurationForVendorMSAD() {
    ComponentRepresentation ldapRep = createBasicLDAPProviderRep();
    ldapRep.getConfig().putSingle(LDAPConstants.VENDOR, LDAPConstants.VENDOR_ACTIVE_DIRECTORY);
    String ldapModelId = createComponent(ldapRep);
    ComponentTypeRepresentation groupLDAPMapperType = findMapperTypeConfiguration(ldapModelId, GroupLDAPStorageMapperFactory.PROVIDER_ID);
    ConfigPropertyRepresentation groupRetrieverConfigProperty = getUserRolesRetrieveStrategyConfigProperty(groupLDAPMapperType, CommonLDAPGroupMapperConfig.USER_ROLES_RETRIEVE_STRATEGY);
    // LOAD_GROUPS_BY_MEMBER_ATTRIBUTE_RECURSIVELY is expected to be present just for the active directory
    List<String> options = groupRetrieverConfigProperty.getOptions();
    Assert.assertNames(options, GroupMapperConfig.LOAD_GROUPS_BY_MEMBER_ATTRIBUTE, GroupMapperConfig.GET_GROUPS_FROM_USER_MEMBEROF_ATTRIBUTE, GroupMapperConfig.LOAD_GROUPS_BY_MEMBER_ATTRIBUTE_RECURSIVELY);
    Assert.assertTrue(groupRetrieverConfigProperty.getHelpText().contains("LOAD_GROUPS_BY_MEMBER_ATTRIBUTE_RECURSIVELY"));
    ComponentTypeRepresentation roleLDAPMapperType = findMapperTypeConfiguration(ldapModelId, RoleLDAPStorageMapperFactory.PROVIDER_ID);
    ConfigPropertyRepresentation roleRetrieverConfigProperty = getUserRolesRetrieveStrategyConfigProperty(roleLDAPMapperType, CommonLDAPGroupMapperConfig.USER_ROLES_RETRIEVE_STRATEGY);
    // LOAD_ROLES_BY_MEMBER_ATTRIBUTE_RECURSIVELY is expected to be present just for the active directory
    options = roleRetrieverConfigProperty.getOptions();
    Assert.assertNames(options, RoleMapperConfig.LOAD_ROLES_BY_MEMBER_ATTRIBUTE, RoleMapperConfig.GET_ROLES_FROM_USER_MEMBEROF_ATTRIBUTE, RoleMapperConfig.LOAD_ROLES_BY_MEMBER_ATTRIBUTE_RECURSIVELY);
    Assert.assertTrue(roleRetrieverConfigProperty.getHelpText().contains("LOAD_ROLES_BY_MEMBER_ATTRIBUTE_RECURSIVELY"));
    // Cleanup including mappers
    removeComponent(ldapModelId);
}
Also used : ComponentRepresentation(org.keycloak.representations.idm.ComponentRepresentation) ComponentTypeRepresentation(org.keycloak.representations.idm.ComponentTypeRepresentation) ConfigPropertyRepresentation(org.keycloak.representations.idm.ConfigPropertyRepresentation) Test(org.junit.Test) AbstractAuthenticationTest(org.keycloak.testsuite.admin.authentication.AbstractAuthenticationTest)

Aggregations

ComponentTypeRepresentation (org.keycloak.representations.idm.ComponentTypeRepresentation)7 Test (org.junit.Test)3 ProviderConfigProperty (org.keycloak.provider.ProviderConfigProperty)3 ConfigPropertyRepresentation (org.keycloak.representations.idm.ConfigPropertyRepresentation)3 ComponentFactory (org.keycloak.component.ComponentFactory)2 ComponentRepresentation (org.keycloak.representations.idm.ComponentRepresentation)2 AbstractAuthenticationTest (org.keycloak.testsuite.admin.authentication.AbstractAuthenticationTest)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Response (javax.ws.rs.core.Response)1 NoCache (org.jboss.resteasy.annotations.cache.NoCache)1 ComponentResource (org.keycloak.admin.client.resource.ComponentResource)1 SubComponentFactory (org.keycloak.component.SubComponentFactory)1 ConfiguredProvider (org.keycloak.provider.ConfiguredProvider)1 ProviderFactory (org.keycloak.provider.ProviderFactory)1 Spi (org.keycloak.provider.Spi)1