use of com.epam.pipeline.manager.docker.scan.clair.ClairService 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);
}
Aggregations