use of com.blackducksoftware.integration.hub.alert.TestGlobalProperties in project hub-alert by blackducksoftware.
the class LoginActionsTestIT method testAuthenticateUserFailIT.
@Test
public void testAuthenticateUserFailIT() throws IntegrationException, IOException {
mockLoginRestModel.setHubUsername(properties.getProperty(TestPropertyKey.TEST_ACTIVE_USER));
final LoginActions loginActions = new LoginActions(new TestGlobalProperties());
final MockLoginRestModel badRestModel = new MockLoginRestModel();
badRestModel.setHubPassword("badpassword");
final boolean userAuthenticated = loginActions.authenticateUser(badRestModel.createRestModel(), new Slf4jIntLogger(logger));
assertFalse(userAuthenticated);
assertTrue(outputLogger.isLineContainingText("User not authenticated"));
}
use of com.blackducksoftware.integration.hub.alert.TestGlobalProperties in project hub-alert by blackducksoftware.
the class LoginActionsTestIT method testIsUserValidFailIT.
@Test
public void testIsUserValidFailIT() throws IntegrationException, IOException {
final LoginRestModel loginRestModel = mockLoginRestModel.createRestModel();
final GlobalProperties globalProperties = new TestGlobalProperties();
final HubServerConfigBuilder serverConfigBuilder = new HubServerConfigBuilder();
serverConfigBuilder.setLogger(new Slf4jIntLogger(logger));
serverConfigBuilder.setHubUrl(globalProperties.getHubUrl());
serverConfigBuilder.setAlwaysTrustServerCertificate(globalProperties.getHubTrustCertificate());
serverConfigBuilder.setTimeout(globalProperties.getHubTimeout());
serverConfigBuilder.setPassword(loginRestModel.getHubPassword());
serverConfigBuilder.setUsername(loginRestModel.getHubUsername());
final LoginActions loginActions = new LoginActions(globalProperties);
final RestConnection restConnection = loginActions.createRestConnection(serverConfigBuilder);
final boolean roleValid = loginActions.isUserRoleValid("broken", restConnection);
assertFalse(roleValid);
}
use of com.blackducksoftware.integration.hub.alert.TestGlobalProperties in project hub-alert by blackducksoftware.
the class NotificationItemProcessorTest method testProcessEvents.
@Test
public void testProcessEvents() throws HubIntegrationException {
final GlobalProperties globalProperties = new TestGlobalProperties();
final NotificationEvent event1 = new NotificationEvent("event 1", NotificationCategoryEnum.HIGH_VULNERABILITY, null);
final NotificationEvent event2 = new NotificationEvent("event 2", NotificationCategoryEnum.LOW_VULNERABILITY, null);
final List<NotificationEvent> eventList = Arrays.asList(event1, event2);
final NotificationItemProcessor notificationItemProcessor = new NotificationItemProcessor(globalProperties, new TestLogger());
final DBStoreEvent storeEvent = notificationItemProcessor.processEvents(eventList);
assertEquals("DB_STORE_EVENT", storeEvent.getTopic());
assertTrue(storeEvent.getNotificationList().size() == 2);
}
use of com.blackducksoftware.integration.hub.alert.TestGlobalProperties in project hub-alert by blackducksoftware.
the class GlobalHubConfigActionsTest method testChannelTestConfig.
@Test
@Override
public void testChannelTestConfig() throws Exception {
final MockGlobalHubRestModel mockUtils = new MockGlobalHubRestModel();
final RestConnection mockedRestConnection = Mockito.mock(RestConnection.class);
final GlobalHubRepositoryWrapper mockedGlobalRepository = Mockito.mock(GlobalHubRepositoryWrapper.class);
final TestGlobalProperties globalProperties = new TestGlobalProperties(mockedGlobalRepository);
GlobalHubConfigActions configActions = new GlobalHubConfigActions(mockedGlobalRepository, globalProperties, new ObjectTransformer());
configActions = Mockito.spy(configActions);
Mockito.doAnswer(new Answer<RestConnection>() {
@Override
public RestConnection answer(final InvocationOnMock invocation) throws Throwable {
return mockedRestConnection;
}
}).when(configActions).createRestConnection(Mockito.any(HubServerConfigBuilder.class));
Mockito.doNothing().when(configActions).validateHubConfiguration(Mockito.any(HubServerConfigBuilder.class));
configActions.testConfig(mockUtils.createGlobalRestModel());
Mockito.verify(mockedRestConnection, Mockito.times(1)).connect();
Mockito.reset(mockedRestConnection);
final GlobalHubConfigRestModel restModel = mockUtils.createGlobalRestModel();
final String result = configActions.channelTestConfig(restModel);
assertEquals("Successfully connected to the Hub.", result);
Mockito.verify(mockedRestConnection, Mockito.times(1)).connect();
}
Aggregations