Search in sources :

Example 6 with DataFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.DataFilter in project CzechIdMng by bcvsolutions.

the class DefaultConfigurationService method publish.

@Override
@Transactional
public EventContext<IdmConfigurationDto> publish(EntityEvent<IdmConfigurationDto> event, EntityEvent<?> parentEvent, BasePermission... permission) {
    Assert.notNull(event, "Event must be not null!");
    IdmConfigurationDto content = event.getContent();
    Assert.notNull(content, "Content (dto) in event must be not null!");
    // load original source without confidential proxy string to support audit changes
    if (!isNew(content)) {
        DataFilter context = new DataFilter(getDtoClass());
        context.setAddSecredProxyString(false);
        event.setOriginalSource(get(content.getId(), context));
    }
    return super.publish(event, parentEvent, permission);
}
Also used : DataFilter(eu.bcvsolutions.idm.core.api.dto.filter.DataFilter) IdmConfigurationDto(eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with DataFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.DataFilter in project CzechIdMng by bcvsolutions.

the class IdmIdentityControllerRestTest method testFindByIds.

/**
 * Test search by ids - supported by default, id DataFilter is used (see #toPedicates in services - has to call super implementation)
 *
 * @throws Exception
 */
@Test
public void testFindByIds() {
    IdmIdentityDto createdDto = createDto();
    IdmIdentityDto createdDtoTwo = createDto();
    // mock dto
    createDto(prepareDto());
    // 
    MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
    parameters.put(DataFilter.PARAMETER_ID, Lists.newArrayList(createdDto.getId().toString(), createdDtoTwo.getId().toString()));
    // 
    List<IdmIdentityDto> results = find(parameters);
    // 
    Assert.assertEquals(2, results.size());
    Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(createdDto.getId())));
    Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(createdDtoTwo.getId())));
    // 
    // find quick alias
    results = findQuick(parameters);
    // 
    Assert.assertEquals(2, results.size());
    Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(createdDto.getId())));
    Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(createdDtoTwo.getId())));
    // 
    results = autocomplete(parameters);
    // 
    Assert.assertEquals(2, results.size());
    Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(createdDto.getId())));
    Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(createdDtoTwo.getId())));
    // 
    Assert.assertEquals(2, count(parameters));
}
Also used : MockMvcResultMatchers.jsonPath(org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath) ZonedDateTime(java.time.ZonedDateTime) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) StringUtils(org.apache.commons.lang3.StringUtils) IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) SecurityMockMvcRequestPostProcessors.authentication(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication) IdmIdentityFormValue(eu.bcvsolutions.idm.core.model.entity.eav.IdmIdentityFormValue) TypeReference(com.fasterxml.jackson.core.type.TypeReference) IdmProfileService(eu.bcvsolutions.idm.core.api.service.IdmProfileService) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) IdmIdentityContractService(eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService) Set(java.util.Set) IdmFormProjectionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormProjectionDto) UUID(java.util.UUID) IdmFormAttributeFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter) Collectors(java.util.stream.Collectors) IdentityState(eu.bcvsolutions.idm.core.api.domain.IdentityState) MockMultipartFile(org.springframework.mock.web.MockMultipartFile) MockMvcRequestBuilders.patch(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Matchers.equalTo(org.hamcrest.Matchers.equalTo) PanelDto(eu.bcvsolutions.idm.core.api.dto.PanelDto) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IdmAttachmentDto(eu.bcvsolutions.idm.core.ecm.api.dto.IdmAttachmentDto) MockMvcResultMatchers.content(org.springframework.test.web.servlet.result.MockMvcResultMatchers.content) FilterManager(eu.bcvsolutions.idm.core.api.repository.filter.FilterManager) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) IdmPasswordService(eu.bcvsolutions.idm.core.api.service.IdmPasswordService) IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) DataFilter(eu.bcvsolutions.idm.core.api.dto.filter.DataFilter) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) Lists(com.google.common.collect.Lists) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) LookupService(eu.bcvsolutions.idm.core.api.service.LookupService) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmFormProjectionService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormProjectionService) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdentityFormValueEvaluator(eu.bcvsolutions.idm.core.security.evaluator.eav.IdentityFormValueEvaluator) AttachmentManager(eu.bcvsolutions.idm.core.ecm.api.service.AttachmentManager) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmProfileDto(eu.bcvsolutions.idm.core.api.dto.IdmProfileDto) Matchers(org.hamcrest.Matchers) MultiValueMap(org.springframework.util.MultiValueMap) IOException(java.io.IOException) Test(org.junit.Test) MockMvcRequestBuilders(org.springframework.test.web.servlet.request.MockMvcRequestBuilders) ConfigurationMap(eu.bcvsolutions.idm.core.api.domain.ConfigurationMap) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) URLEncoder(java.net.URLEncoder) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SelfIdentityEvaluator(eu.bcvsolutions.idm.core.security.evaluator.identity.SelfIdentityEvaluator) Ignore(org.junit.Ignore) PrivateIdentityConfiguration(eu.bcvsolutions.idm.core.api.config.domain.PrivateIdentityConfiguration) ResolvedIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.ResolvedIncompatibleRoleDto) IdentityDisableBulkAction(eu.bcvsolutions.idm.core.bulk.action.impl.IdentityDisableBulkAction) MockMvcRequestBuilders.get(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get) Assert(org.junit.Assert) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) InputStream(java.io.InputStream) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) Test(org.junit.Test)

Example 8 with DataFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.DataFilter in project CzechIdMng by bcvsolutions.

the class CodeableFilterBuilderIntegrationTest method testFindIdentityByUsername.

@Test
public void testFindIdentityByUsername() {
    // prepare data
    IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
    IdmRoleDto roleOne = getHelper().createRole();
    // 
    DataFilter dataFilter = new DataFilter(IdmIdentityDto.class);
    dataFilter.setCodeableIdentifier(identityOne.getUsername());
    List<IdmIdentity> identities = identityFilter.find(dataFilter, null).getContent();
    // 
    assertEquals(1, identities.size());
    assertEquals(identityOne.getId(), identities.get(0).getId());
    // 
    dataFilter.setCodeableIdentifier(identityTwo.getUsername());
    identities = identityFilter.find(dataFilter, null).getContent();
    assertEquals(1, identities.size());
    assertEquals(identityTwo.getId(), identities.get(0).getId());
    // 
    dataFilter.setCodeableIdentifier(roleOne.getId().toString());
    assertEquals(0, identityFilter.find(dataFilter, null).getTotalElements());
}
Also used : DataFilter(eu.bcvsolutions.idm.core.api.dto.filter.DataFilter) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 9 with DataFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.DataFilter in project CzechIdMng by bcvsolutions.

the class CodeableFilterBuilderIntegrationTest method testFindIdentityByUuid.

@Test
public void testFindIdentityByUuid() {
    // prepare data
    IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
    IdmRoleDto roleOne = getHelper().createRole();
    // 
    DataFilter dataFilter = new DataFilter(IdmIdentityDto.class);
    dataFilter.setCodeableIdentifier(identityOne.getId().toString());
    List<IdmIdentity> identities = identityFilter.find(dataFilter, null).getContent();
    // 
    assertEquals(1, identities.size());
    assertEquals(identityOne.getId(), identities.get(0).getId());
    // 
    dataFilter.setCodeableIdentifier(identityTwo.getId().toString());
    identities = identityFilter.find(dataFilter, null).getContent();
    assertEquals(1, identities.size());
    assertEquals(identityTwo.getId(), identities.get(0).getId());
    // 
    dataFilter.setCodeableIdentifier(roleOne.getId().toString());
    assertEquals(0, identityFilter.find(dataFilter, null).getTotalElements());
}
Also used : DataFilter(eu.bcvsolutions.idm.core.api.dto.filter.DataFilter) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 10 with DataFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.DataFilter in project CzechIdMng by bcvsolutions.

the class DefaultFilterManagerIntegrationTest method testFilterNotSupportedWithoutValue.

@Test
public void testFilterNotSupportedWithoutValue() {
    DataFilter filter = new DataFilter(IdmConfigurationDto.class);
    filter.set("wrong", null);
    // 
    Page<IdmConfigurationDto> configurations = configurationService.find(filter, PageRequest.of(0, 1));
    // 
    Assert.assertNotNull(configurations);
}
Also used : DataFilter(eu.bcvsolutions.idm.core.api.dto.filter.DataFilter) IdmConfigurationDto(eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Aggregations

DataFilter (eu.bcvsolutions.idm.core.api.dto.filter.DataFilter)22 Test (org.junit.Test)17 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)12 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)7 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)7 IdmConfigurationDto (eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto)6 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)6 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)4 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)3 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)3 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)3 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)3 IdmBulkActionDto (eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto)2 ExternalCodeable (eu.bcvsolutions.idm.core.api.domain.ExternalCodeable)2 FilterBuilder (eu.bcvsolutions.idm.core.api.repository.filter.FilterBuilder)2 IdmIdentityService (eu.bcvsolutions.idm.core.api.service.IdmIdentityService)2 AbstractRestTest (eu.bcvsolutions.idm.test.api.AbstractRestTest)2 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 Lists (com.google.common.collect.Lists)1