Search in sources :

Example 16 with SysSystemFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter in project CzechIdMng by bcvsolutions.

the class SystemUniversalSearchType method createFilter.

protected SysSystemFilter createFilter(String text) {
    SysSystemFilter filter = new SysSystemFilter();
    filter.setText(text);
    return filter;
}
Also used : SysSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter)

Example 17 with SysSystemFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter in project CzechIdMng by bcvsolutions.

the class AccInitRemoteServerProcessorIntegrationTest method testInit.

@Test
public void testInit() {
    String host = getHelper().createName();
    String password = getHelper().createName();
    String description = getHelper().createName();
    // 
    SysConnectorServerDto remoteServer = new SysConnectorServerDto();
    remoteServer.setHost(host);
    remoteServer.setPassword(new GuardedString(password));
    remoteServer.setPort(2);
    remoteServer.setTimeout(2);
    remoteServer.setUseSsl(true);
    remoteServerService.save(remoteServer);
    // 
    SysRemoteServerFilter filter = new SysRemoteServerFilter();
    filter.setText(host);
    List<SysConnectorServerDto> results = remoteServerService.find(filter, null).getContent();
    Assert.assertEquals(1, results.size());
    SysConnectorServerDto existRemoteServer = results.get(0);
    // 
    // wee need to save system old way => repository is used
    SysSystem system = new SysSystem();
    system.setRemote(true);
    system.setName(getHelper().createName());
    system.setDescription(description);
    system.setConnectorServer(new SysConnectorServer());
    system.getConnectorServer().setHost(host);
    system.getConnectorServer().setPassword(new GuardedString(password));
    system.getConnectorServer().setPort(1);
    system.getConnectorServer().setTimeout(2);
    system.getConnectorServer().setUseSsl(true);
    system.setBlockedOperation(new SysBlockedOperation());
    SysSystemDto systemOne = systemService.get(systemRepository.save(system).getId());
    confidentialStorage.saveGuardedString(systemOne.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD, new GuardedString(password));
    // 
    system = new SysSystem();
    system.setRemote(true);
    system.setName(getHelper().createName());
    system.setDescription(description);
    system.setConnectorServer(new SysConnectorServer());
    system.getConnectorServer().setHost(host);
    system.getConnectorServer().setPassword(new GuardedString(password));
    system.getConnectorServer().setPort(1);
    system.getConnectorServer().setTimeout(2);
    system.getConnectorServer().setUseSsl(true);
    system.setBlockedOperation(new SysBlockedOperation());
    SysSystemDto systemTwo = systemService.get(systemRepository.save(system).getId());
    confidentialStorage.saveGuardedString(systemTwo.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD, new GuardedString(password));
    // 
    system = new SysSystem();
    system.setRemote(true);
    system.setName(getHelper().createName());
    system.setDescription(description);
    system.setConnectorServer(new SysConnectorServer());
    system.getConnectorServer().setHost(host);
    String differentPassword = getHelper().createName();
    // different password
    system.getConnectorServer().setPassword(new GuardedString(differentPassword));
    system.getConnectorServer().setPort(1);
    system.getConnectorServer().setTimeout(2);
    system.getConnectorServer().setUseSsl(true);
    system.setBlockedOperation(new SysBlockedOperation());
    SysSystemDto systemThree = systemService.get(systemRepository.save(system).getId());
    confidentialStorage.saveGuardedString(systemThree.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD, new GuardedString(differentPassword));
    // 
    system = new SysSystem();
    system.setRemote(true);
    system.setName(getHelper().createName());
    system.setDescription(description);
    system.setConnectorServer(new SysConnectorServer());
    system.getConnectorServer().setHost(host);
    system.getConnectorServer().setPassword(new GuardedString(password));
    system.getConnectorServer().setPort(1);
    system.getConnectorServer().setTimeout(2);
    // useSsl - different
    system.getConnectorServer().setUseSsl(false);
    system.setBlockedOperation(new SysBlockedOperation());
    SysSystemDto systemFour = systemService.get(systemRepository.save(system).getId());
    confidentialStorage.saveGuardedString(systemFour.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD, new GuardedString(password));
    // 
    system = new SysSystem();
    system.setRemote(true);
    system.setName(getHelper().createName());
    system.setDescription(description);
    system.setConnectorServer(new SysConnectorServer());
    system.getConnectorServer().setHost(host);
    system.getConnectorServer().setPassword(new GuardedString(password));
    system.getConnectorServer().setPort(2);
    system.getConnectorServer().setTimeout(2);
    // useSsl - different
    system.getConnectorServer().setUseSsl(true);
    system.setBlockedOperation(new SysBlockedOperation());
    SysSystemDto systemFive = systemService.get(systemRepository.save(system).getId());
    confidentialStorage.saveGuardedString(systemFive.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD, new GuardedString(password));
    // 
    SysSystemFilter systemFilter = new SysSystemFilter();
    systemFilter.setText(description);
    List<SysSystemDto> systems = systemService.find(systemFilter, null).getContent();
    Assert.assertEquals(5, systems.size());
    Assert.assertTrue(systems.stream().allMatch(s -> s.isRemote()));
    Assert.assertTrue(systems.stream().allMatch(s -> s.getRemoteServer() == null));
    // 
    // process migration
    initProcessor.process(new ModuleDescriptorEvent(ModuleDescriptorEventType.INIT, new ModuleDescriptorDto(AccModuleDescriptor.MODULE_ID)));
    // 
    systems = systemService.find(systemFilter, null).getContent();
    Assert.assertTrue(systems.stream().allMatch(s -> s.isRemote()));
    Assert.assertTrue(systems.stream().allMatch(s -> s.getRemoteServer() != null));
    results = remoteServerService.find(filter, null).getContent();
    Assert.assertEquals(4, results.size());
    // 
    // one - two => same
    systemOne = systemService.get(systemOne);
    systemTwo = systemService.get(systemTwo);
    Assert.assertEquals(systemOne.getRemoteServer(), systemTwo.getRemoteServer());
    Assert.assertEquals(password, confidentialStorage.getGuardedString(systemOne.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD).asString());
    Assert.assertEquals(password, confidentialStorage.getGuardedString(systemTwo.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD).asString());
    Assert.assertEquals(password, remoteServerService.getPassword(systemTwo.getRemoteServer()).asString());
    // 
    // three - different password
    systemThree = systemService.get(systemThree);
    Assert.assertEquals(differentPassword, confidentialStorage.getGuardedString(systemThree.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD).asString());
    Assert.assertEquals(differentPassword, remoteServerService.getPassword(systemThree.getRemoteServer()).asString());
    Assert.assertNotEquals(systemOne.getRemoteServer(), systemThree.getRemoteServer());
    // 
    // four - different ssl
    systemFour = systemService.get(systemFour);
    Assert.assertEquals(password, confidentialStorage.getGuardedString(systemOne.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD).asString());
    Assert.assertEquals(password, remoteServerService.getPassword(systemFour.getRemoteServer()).asString());
    Assert.assertNotEquals(systemOne.getRemoteServer(), systemFour.getRemoteServer());
    Assert.assertNotEquals(systemThree.getRemoteServer(), systemFour.getRemoteServer());
    // 
    // five - exists
    systemFive = systemService.get(systemFive);
    Assert.assertEquals(existRemoteServer.getId(), systemFive.getRemoteServer());
}
Also used : AccModuleDescriptor(eu.bcvsolutions.idm.acc.AccModuleDescriptor) SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) SysConnectorServer(eu.bcvsolutions.idm.acc.entity.SysConnectorServer) SysSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSystemRepository(eu.bcvsolutions.idm.acc.repository.SysSystemRepository) ModuleDescriptorEvent(eu.bcvsolutions.idm.core.api.event.ModuleDescriptorEvent) SysConnectorServerDto(eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto) ModuleDescriptorEventType(eu.bcvsolutions.idm.core.api.event.ModuleDescriptorEvent.ModuleDescriptorEventType) List(java.util.List) ConfidentialStorage(eu.bcvsolutions.idm.core.api.service.ConfidentialStorage) SysRemoteServerFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRemoteServerFilter) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) SysRemoteServerService(eu.bcvsolutions.idm.acc.service.api.SysRemoteServerService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Assert(org.junit.Assert) SysBlockedOperation(eu.bcvsolutions.idm.acc.entity.SysBlockedOperation) ModuleDescriptorDto(eu.bcvsolutions.idm.core.api.dto.ModuleDescriptorDto) SysSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter) SysRemoteServerFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRemoteServerFilter) SysConnectorServer(eu.bcvsolutions.idm.acc.entity.SysConnectorServer) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) ModuleDescriptorDto(eu.bcvsolutions.idm.core.api.dto.ModuleDescriptorDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) SysBlockedOperation(eu.bcvsolutions.idm.acc.entity.SysBlockedOperation) ModuleDescriptorEvent(eu.bcvsolutions.idm.core.api.event.ModuleDescriptorEvent) SysConnectorServerDto(eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 18 with SysSystemFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter in project CzechIdMng by bcvsolutions.

the class SysSystemControllerRestTest method testFindByVirtual.

@Test
public void testFindByVirtual() {
    SysSystemDto system = prepareDto();
    system.setVirtual(true);
    system.setDescription(getHelper().createName());
    SysSystemDto systemOne = createDto(system);
    system = prepareDto();
    system.setVirtual(false);
    system.setDescription(systemOne.getDescription());
    SysSystemDto systemTwo = createDto(system);
    // 
    SysSystemFilter filter = new SysSystemFilter();
    filter.setVirtual(Boolean.TRUE);
    filter.setText(system.getDescription());
    List<SysSystemDto> results = find(filter);
    Assert.assertEquals(1, results.size());
    Assert.assertTrue(results.stream().allMatch(r -> r.getId().equals(systemOne.getId())));
    // 
    filter.setVirtual(Boolean.FALSE);
    results = find(filter);
    Assert.assertEquals(1, results.size());
    Assert.assertTrue(results.stream().allMatch(r -> r.getId().equals(systemTwo.getId())));
    // 
    filter.setVirtual(null);
    results = find(filter);
    Assert.assertEquals(2, results.size());
    Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(systemOne.getId())));
    Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(systemTwo.getId())));
}
Also used : IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) SysSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter) Autowired(org.springframework.beans.factory.annotation.Autowired) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) MockMvcResultMatchers.content(org.springframework.test.web.servlet.result.MockMvcResultMatchers.content) SysConnectorServerDto(eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) IdmPasswordPolicyGenerateType(eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyGenerateType) ConfidentialStorage(eu.bcvsolutions.idm.core.api.service.ConfidentialStorage) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) SecurityMockMvcRequestPostProcessors.authentication(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) SysRemoteServerService(eu.bcvsolutions.idm.acc.service.api.SysRemoteServerService) SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) IdmPasswordPolicyType(eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyType) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) UUID(java.util.UUID) List(java.util.List) MockMvcRequestBuilders.get(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Assert(org.junit.Assert) IdmPasswordPolicyService(eu.bcvsolutions.idm.core.api.service.IdmPasswordPolicyService) SysSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) Test(org.junit.Test)

Aggregations

SysSystemFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter)18 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)11 Test (org.junit.Test)10 SysConnectorServerDto (eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto)8 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)7 UUID (java.util.UUID)7 IdmPasswordPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto)6 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)6 SysSystem (eu.bcvsolutions.idm.acc.entity.SysSystem)5 SysRemoteServerService (eu.bcvsolutions.idm.acc.service.api.SysRemoteServerService)5 SysSystemService (eu.bcvsolutions.idm.acc.service.api.SysSystemService)5 ConfidentialStorage (eu.bcvsolutions.idm.core.api.service.ConfidentialStorage)5 List (java.util.List)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)4 Assert (org.junit.Assert)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 IdmPasswordPolicyGenerateType (eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyGenerateType)3 IdmPasswordPolicyType (eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyType)3 AbstractReadWriteDtoController (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController)3