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));
}
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);
}
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);
}
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);
}
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);
}
Aggregations