Search in sources :

Example 16 with Preference

use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.

the class InstanceOfferManagerTest method testUpdateAllowedInstanceTypes.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testUpdateAllowedInstanceTypes() {
    Preference allowedTypesPreference = SystemPreferences.CLUSTER_ALLOWED_INSTANCE_TYPES.toPreference();
    allowedTypesPreference.setValue(M5_PATTERN);
    preferenceManager.update(Collections.singletonList(allowedTypesPreference));
    Assert.assertTrue(instanceOfferManager.isInstanceAllowed(M5_INSTANCE_TYPE));
    Assert.assertFalse(instanceOfferManager.isInstanceAllowed(X5_INSTANCE_TYPE));
    allowedTypesPreference.setValue(M5_X5_PATTERN);
    preferenceManager.update(Collections.singletonList(allowedTypesPreference));
    Assert.assertTrue(instanceOfferManager.isInstanceAllowed(M5_INSTANCE_TYPE));
    Assert.assertTrue(instanceOfferManager.isInstanceAllowed(X5_INSTANCE_TYPE));
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) Test(org.junit.Test) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 17 with Preference

use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.

the class DataStorageManagerTest method testFailCreateOfStorageWithForbiddenMountPointWildCard.

@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testFailCreateOfStorageWithForbiddenMountPointWildCard() {
    Preference preference = SystemPreferences.DATA_STORAGE_NFS_MOUNT_BLACK_LIST.toPreference();
    preference.setValue(SystemPreferences.DATA_STORAGE_NFS_MOUNT_BLACK_LIST.getDefaultValue() + makeSysIndependentPath(",/runs/*"));
    preferenceManager.update(Collections.singletonList(preference));
    DataStorageVO storageVO = ObjectCreatorUtils.constructDataStorageVO(NAME, DESCRIPTION, DataStorageType.NFS, PATH, WITHOUT_PARENT_ID, FORBIDDEN_MOUNT_POINT_2, TEST_MOUNT_OPTIONS);
    storageManager.create(storageVO, false, false, false);
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with Preference

use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.

the class DataStorageManagerTest method testFailCreateOfStorageWithForbiddenMountPointWildCard2.

@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testFailCreateOfStorageWithForbiddenMountPointWildCard2() {
    Preference preference = SystemPreferences.DATA_STORAGE_NFS_MOUNT_BLACK_LIST.toPreference();
    preference.setValue(SystemPreferences.DATA_STORAGE_NFS_MOUNT_BLACK_LIST.getDefaultValue() + makeSysIndependentPath(",/runs/**/dir"));
    preferenceManager.update(Collections.singletonList(preference));
    DataStorageVO storageVO = ObjectCreatorUtils.constructDataStorageVO(NAME, DESCRIPTION, DataStorageType.NFS, PATH, WITHOUT_PARENT_ID, FORBIDDEN_MOUNT_POINT_3, TEST_MOUNT_OPTIONS);
    storageManager.create(storageVO, false, false, false);
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 19 with Preference

use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.

the class AggregatingToolScanManagerTest method testInit.

@Test
public void testInit() {
    AggregatingToolScanManager toolScanManager = new AggregatingToolScanManager();
    PreferenceManager preferenceManager = new PreferenceManager();
    PreferenceDao preferenceDao = Mockito.mock(PreferenceDao.class);
    SystemPreferences systemPreferences = Mockito.mock(SystemPreferences.class);
    Whitebox.setInternalState(preferenceManager, "preferenceDao", preferenceDao);
    Whitebox.setInternalState(preferenceManager, "messageHelper", messageHelper);
    Whitebox.setInternalState(preferenceManager, "systemPreferences", systemPreferences);
    Whitebox.setInternalState(toolScanManager, "preferenceManager", preferenceManager);
    toolScanManager.init();
    ClairService service = (ClairService) Whitebox.getInternalState(toolScanManager, "clairService");
    Assert.assertNull(service);
    Preference toolScanEnabled = SystemPreferences.DOCKER_SECURITY_TOOL_SCAN_ENABLED.toPreference();
    toolScanEnabled.setValue("true");
    when(preferenceDao.loadPreferenceByName(toolScanEnabled.getName())).thenReturn(toolScanEnabled);
    Preference clairRootUrl = SystemPreferences.DOCKER_SECURITY_TOOL_SCAN_CLAIR_ROOT_URL.toPreference();
    clairRootUrl.setValue("http://localhost:9000/");
    when(preferenceDao.loadPreferenceByName(clairRootUrl.getName())).thenReturn(clairRootUrl);
    preferenceManager.update(Arrays.asList(toolScanEnabled, clairRootUrl));
    service = (ClairService) Whitebox.getInternalState(toolScanManager, "clairService");
    Assert.assertNotNull(service);
}
Also used : ClairService(com.epam.pipeline.manager.docker.scan.clair.ClairService) Preference(com.epam.pipeline.entity.preference.Preference) SystemPreferences(com.epam.pipeline.manager.preference.SystemPreferences) PreferenceDao(com.epam.pipeline.dao.preference.PreferenceDao) PreferenceManager(com.epam.pipeline.manager.preference.PreferenceManager) Test(org.junit.Test)

Example 20 with Preference

use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.

the class IssueManagerTest method setUp.

@Before
public void setUp() throws Exception {
    Folder folder = new Folder();
    folder.setName(FOLDER_NAME);
    folder.setOwner(AUTHOR);
    folderDao.createFolder(folder);
    folderDao.loadFolder(folder.getId());
    entityVO = new EntityVO(folder.getId(), AclClass.FOLDER);
    testAttachment = new Attachment();
    testAttachment.setName("test");
    testAttachment.setPath("///");
    testAttachment.setCreatedDate(new Date());
    testAttachment.setOwner(AUTHOR);
    attachmentDao.createAttachment(testAttachment);
    Preference systemDataStorage = SystemPreferences.DATA_STORAGE_SYSTEM_DATA_STORAGE_NAME.toPreference();
    systemDataStorage.setName(TEST_SYSTEM_DATA_STORAGE);
    when(preferenceManager.getPreference(SystemPreferences.DATA_STORAGE_SYSTEM_DATA_STORAGE_NAME)).thenReturn(TEST_SYSTEM_DATA_STORAGE);
    when(dataStorageManager.loadByNameOrId(TEST_SYSTEM_DATA_STORAGE)).thenReturn(testSystemDataStorage);
    when(dataStorageManager.deleteDataStorageItems(any(), any(), any())).thenReturn(1);
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) Preference(com.epam.pipeline.entity.preference.Preference) Attachment(com.epam.pipeline.entity.issue.Attachment) Folder(com.epam.pipeline.entity.pipeline.Folder) Date(java.util.Date) Before(org.junit.Before)

Aggregations

Preference (com.epam.pipeline.entity.preference.Preference)27 Test (org.junit.Test)20 Transactional (org.springframework.transaction.annotation.Transactional)17 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)11 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)5 Before (org.junit.Before)5 DataStorageVO (com.epam.pipeline.controller.vo.DataStorageVO)3 AwsRegionVO (com.epam.pipeline.controller.vo.AwsRegionVO)2 Attachment (com.epam.pipeline.entity.issue.Attachment)2 AwsRegion (com.epam.pipeline.entity.region.AwsRegion)2 ObjectPreference (com.epam.pipeline.manager.preference.AbstractSystemPreference.ObjectPreference)2 PreferenceManager (com.epam.pipeline.manager.preference.PreferenceManager)2 SystemPreferences (com.epam.pipeline.manager.preference.SystemPreferences)2 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)2 MessageHelper (com.epam.pipeline.common.MessageHelper)1 EntityVO (com.epam.pipeline.controller.vo.EntityVO)1 PreferenceDao (com.epam.pipeline.dao.preference.PreferenceDao)1 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)1 DataStorageFile (com.epam.pipeline.entity.datastorage.DataStorageFile)1 DataStorageStreamingContent (com.epam.pipeline.entity.datastorage.DataStorageStreamingContent)1