Search in sources :

Example 16 with IdmScriptDto

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

the class DefaultIdmScriptServiceIntegrationTest method tryRedeployScript.

@Test
public void tryRedeployScript() {
    configurationService.setValue(Recoverable.BACKUP_FOLDER_CONFIG, TEST_BACKUP_FOLDER);
    IdmScriptDto script1 = scriptService.getByCode(TEST_SCRIPT_CODE_1);
    assertNotNull(script1);
    assertEquals(TEST_SCRIPT_NAME_1, script1.getName());
    String changeName = "test_change_" + System.currentTimeMillis();
    script1.setName(changeName);
    script1 = scriptService.save(script1);
    assertEquals(changeName, script1.getName());
    try {
        script1 = scriptService.redeploy(script1);
        assertEquals(TEST_SCRIPT_NAME_1, script1.getName());
    } catch (ResultCodeException e) {
        fail();
    }
}
Also used : IdmScriptDto(eu.bcvsolutions.idm.core.api.dto.IdmScriptDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 17 with IdmScriptDto

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

the class DefaultIdmScriptServiceIntegrationTest method initFromMultipleLocations.

@Test
public void initFromMultipleLocations() {
    IdmScriptDto script3 = scriptService.getByCode(TEST_SCRIPT_CODE_3);
    IdmScriptDto scriptOverride = scriptService.getByCode(TEST_SCRIPT_CODE_OVERRIDE);
    assertNotNull(script3);
    assertNotNull(scriptOverride);
    assertEquals(TEST_SCRIPT_CODE_3, script3.getCode());
    assertEquals(TEST_SCRIPT_CODE_OVERRIDE, scriptOverride.getCode());
    // 
    assertEquals("String overrideUpdate;", scriptOverride.getScript().trim());
}
Also used : IdmScriptDto(eu.bcvsolutions.idm.core.api.dto.IdmScriptDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 18 with IdmScriptDto

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

the class DefaultIdmScriptServiceIntegrationTest method tryRedeployMissingScript.

@Test
public void tryRedeployMissingScript() {
    IdmScriptDto script = new IdmScriptDto();
    script.setCategory(IdmScriptCategory.SYSTEM);
    script.setCode("test_" + System.currentTimeMillis());
    script.setName("test_" + System.currentTimeMillis());
    script = scriptService.save(script);
    assertNotNull(script);
    assertNotNull(script.getId());
    try {
        scriptService.redeploy(script);
        fail();
    } catch (ResultCodeException e) {
        ResultCodeException resultCode = (ResultCodeException) e;
        assertEquals(resultCode.getError().getError().getStatusEnum(), CoreResultCode.SCRIPT_XML_FILE_NOT_FOUND.name());
    }
}
Also used : IdmScriptDto(eu.bcvsolutions.idm.core.api.dto.IdmScriptDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 19 with IdmScriptDto

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

the class DefaultIdmScriptServiceIntegrationTest method backupMissingFolderNewEntity.

@Test
public void backupMissingFolderNewEntity() {
    configurationService.setValue(Recoverable.BACKUP_FOLDER_CONFIG, null);
    IdmScriptDto script = new IdmScriptDto();
    script.setCategory(IdmScriptCategory.SYSTEM);
    script.setCode("test_" + System.currentTimeMillis());
    script.setName("test_" + System.currentTimeMillis());
    script = scriptService.save(script);
    assertNotNull(script);
    assertNotNull(script.getId());
    try {
        scriptService.backup(script);
        fail();
    } catch (ResultCodeException e) {
        ResultCodeException resultCode = (ResultCodeException) e;
        assertEquals(resultCode.getError().getError().getStatusEnum(), CoreResultCode.BACKUP_FOLDER_NOT_FOUND.name());
    }
}
Also used : IdmScriptDto(eu.bcvsolutions.idm.core.api.dto.IdmScriptDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 20 with IdmScriptDto

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

the class DefaultIdmScriptServiceIntegrationTest method tryBackup.

@Test
public void tryBackup() {
    File directory = new File(TEST_BACKUP_FOLDER);
    if (directory.exists() && directory.isDirectory()) {
        try {
            FileUtils.deleteDirectory(directory);
        } catch (IOException e) {
            fail();
        }
    }
    // 
    IdmScriptDto script1 = scriptService.getByCode(TEST_SCRIPT_CODE_1);
    assertNotNull(script1);
    configurationService.setValue(Recoverable.BACKUP_FOLDER_CONFIG, TEST_BACKUP_FOLDER);
    // 
    try {
        IdmScriptDto newDto = scriptService.redeploy(script1);
        assertEquals(script1.getCode(), newDto.getCode());
        // 
        DateTime date = new DateTime();
        DecimalFormat decimalFormat = new DecimalFormat("00");
        directory = new File(TEST_BACKUP_FOLDER + "scripts/" + date.getYear() + decimalFormat.format(date.getMonthOfYear()) + decimalFormat.format(date.getDayOfMonth()) + "/");
        File[] files = directory.listFiles();
        assertEquals(1, files.length);
        File backup = files[0];
        assertTrue(backup.exists());
        assertTrue(backup.getName().contains("admin"));
        assertTrue(backup.getName().contains(script1.getCode()));
    } catch (Exception e) {
        fail();
    }
}
Also used : DecimalFormat(java.text.DecimalFormat) IdmScriptDto(eu.bcvsolutions.idm.core.api.dto.IdmScriptDto) IOException(java.io.IOException) File(java.io.File) DateTime(org.joda.time.DateTime) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IOException(java.io.IOException) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmScriptDto (eu.bcvsolutions.idm.core.api.dto.IdmScriptDto)39 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)34 Test (org.junit.Test)34 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)8 IdmScriptAuthorityDto (eu.bcvsolutions.idm.core.api.dto.IdmScriptAuthorityDto)5 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)5 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)3 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)3 IdmRole (eu.bcvsolutions.idm.core.model.entity.IdmRole)3 HashMap (java.util.HashMap)3 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)2 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)2 IdmScriptAuthorityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmScriptAuthorityFilter)2 ApiOperation (io.swagger.annotations.ApiOperation)2 ResponseEntity (org.springframework.http.ResponseEntity)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 SysSyncIdentityConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto)1 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)1