use of org.keycloak.representations.idm.ComponentRepresentation in project keycloak by keycloak.
the class ClientRegistrationPoliciesTest method setTrustedHost.
private void setTrustedHost(String hostname) {
ComponentRepresentation trustedHostRep = findPolicyByProviderAndAuth(TrustedHostClientRegistrationPolicyFactory.PROVIDER_ID, getPolicyAnon());
trustedHostRep.getConfig().putSingle(TrustedHostClientRegistrationPolicyFactory.TRUSTED_HOSTS, hostname);
realmResource().components().component(trustedHostRep.getId()).update(trustedHostRep);
}
use of org.keycloak.representations.idm.ComponentRepresentation in project keycloak by keycloak.
the class UserStorageRestTest method testValidateAndCreateLdapProviderEditMode.
@Test
public void testValidateAndCreateLdapProviderEditMode() {
// Test provider without editMode should fail
ComponentRepresentation ldapRep = createBasicLDAPProviderRep();
ldapRep.getConfig().remove(LDAPConstants.EDIT_MODE);
Response resp = realm.components().add(ldapRep);
Assert.assertEquals(400, resp.getStatus());
resp.close();
// Test provider with READ_ONLY edit mode and validatePasswordPolicy will fail
ldapRep = createBasicLDAPProviderRep();
ldapRep.getConfig().putSingle(LDAPConstants.EDIT_MODE, UserStorageProvider.EditMode.READ_ONLY.name());
ldapRep.getConfig().putSingle(LDAPConstants.VALIDATE_PASSWORD_POLICY, "true");
resp = realm.components().add(ldapRep);
Assert.assertEquals(400, resp.getStatus());
resp.close();
// Test provider with UNSYNCED edit mode and validatePasswordPolicy will fail
ldapRep.getConfig().putSingle(LDAPConstants.EDIT_MODE, UserStorageProvider.EditMode.UNSYNCED.name());
ldapRep.getConfig().putSingle(LDAPConstants.VALIDATE_PASSWORD_POLICY, "true");
resp = realm.components().add(ldapRep);
Assert.assertEquals(400, resp.getStatus());
resp.close();
// Test provider with WRITABLE edit mode and validatePasswordPolicy will fail
ldapRep.getConfig().putSingle(LDAPConstants.EDIT_MODE, UserStorageProvider.EditMode.WRITABLE.name());
ldapRep.getConfig().putSingle(LDAPConstants.SYNC_REGISTRATIONS, "true");
String id1 = createComponent(ldapRep);
// Cleanup
removeComponent(id1);
}
use of org.keycloak.representations.idm.ComponentRepresentation in project keycloak by keycloak.
the class UserStorageRestTest method testLDAPMapperProviderConfigurationForVendorOther.
// KEYCLOAK-12934
@Test
public void testLDAPMapperProviderConfigurationForVendorOther() {
ComponentRepresentation ldapRep = createBasicLDAPProviderRep();
ldapRep.getConfig().putSingle(LDAPConstants.VENDOR, LDAPConstants.VENDOR_OTHER);
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);
Assert.assertFalse(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);
Assert.assertFalse(roleRetrieverConfigProperty.getHelpText().contains("LOAD_ROLES_BY_MEMBER_ATTRIBUTE_RECURSIVELY"));
// Cleanup including mappers
removeComponent(ldapModelId);
}
use of org.keycloak.representations.idm.ComponentRepresentation in project keycloak by keycloak.
the class AbstractKerberosTest method updateUserStorageProvider.
/**
* Update UserStorage provider (Kerberos provider or LDAP provider with Kerberos enabled) with specified updater and save it
*/
protected void updateUserStorageProvider(Consumer<ComponentRepresentation> updater) {
List<ComponentRepresentation> reps = testRealmResource().components().query("test", UserStorageProvider.class.getName());
Assert.assertEquals(1, reps.size());
ComponentRepresentation kerberosProvider = reps.get(0);
updater.accept(kerberosProvider);
testRealmResource().components().component(kerberosProvider.getId()).update(kerberosProvider);
}
use of org.keycloak.representations.idm.ComponentRepresentation in project keycloak by keycloak.
the class AbstractKerberosTest method getUserStorageConfiguration.
protected ComponentRepresentation getUserStorageConfiguration(String providerName, String providerId) {
Map<String, String> kerberosConfig = getKerberosRule().getConfig();
MultivaluedHashMap<String, String> config = toComponentConfig(kerberosConfig);
UserStorageProviderModel model = new UserStorageProviderModel();
model.setLastSync(0);
model.setChangedSyncPeriod(-1);
model.setFullSyncPeriod(-1);
model.setName(providerName);
model.setPriority(0);
model.setProviderId(providerId);
model.setConfig(config);
ComponentRepresentation rep = ModelToRepresentation.toRepresentationWithoutConfig(model);
return rep;
}
Aggregations