Search in sources :

Example 21 with TestGlobalProperties

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"));
}
Also used : MockLoginRestModel(com.blackducksoftware.integration.hub.alert.mock.model.MockLoginRestModel) Slf4jIntLogger(com.blackducksoftware.integration.log.Slf4jIntLogger) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) Test(org.junit.Test) HubConnectionTest(com.blackducksoftware.integration.test.annotation.HubConnectionTest)

Example 22 with TestGlobalProperties

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);
}
Also used : RestConnection(com.blackducksoftware.integration.hub.rest.RestConnection) LoginRestModel(com.blackducksoftware.integration.hub.alert.web.model.LoginRestModel) MockLoginRestModel(com.blackducksoftware.integration.hub.alert.mock.model.MockLoginRestModel) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) GlobalProperties(com.blackducksoftware.integration.hub.alert.config.GlobalProperties) Slf4jIntLogger(com.blackducksoftware.integration.log.Slf4jIntLogger) HubServerConfigBuilder(com.blackducksoftware.integration.hub.configuration.HubServerConfigBuilder) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) Test(org.junit.Test) HubConnectionTest(com.blackducksoftware.integration.test.annotation.HubConnectionTest)

Example 23 with TestGlobalProperties

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);
}
Also used : TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) GlobalProperties(com.blackducksoftware.integration.hub.alert.config.GlobalProperties) NotificationEvent(com.blackducksoftware.integration.hub.notification.NotificationEvent) DBStoreEvent(com.blackducksoftware.integration.hub.alert.event.DBStoreEvent) TestLogger(com.blackducksoftware.integration.test.TestLogger) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) Test(org.junit.Test)

Example 24 with TestGlobalProperties

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();
}
Also used : GlobalHubConfigActions(com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigActions) GlobalHubConfigRestModel(com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigRestModel) RestConnection(com.blackducksoftware.integration.hub.rest.RestConnection) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ObjectTransformer(com.blackducksoftware.integration.hub.alert.web.ObjectTransformer) HubServerConfigBuilder(com.blackducksoftware.integration.hub.configuration.HubServerConfigBuilder) MockGlobalHubRestModel(com.blackducksoftware.integration.hub.alert.hub.mock.MockGlobalHubRestModel) GlobalHubRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) Test(org.junit.Test) GlobalActionsTest(com.blackducksoftware.integration.hub.alert.web.actions.global.GlobalActionsTest)

Aggregations

TestGlobalProperties (com.blackducksoftware.integration.hub.alert.TestGlobalProperties)24 Test (org.junit.Test)20 GlobalProperties (com.blackducksoftware.integration.hub.alert.config.GlobalProperties)8 GlobalHubRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper)8 ChannelTest (com.blackducksoftware.integration.hub.alert.channel.ChannelTest)6 ChannelRestConnectionFactory (com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRestConnectionFactory)6 GlobalHubConfigActions (com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigActions)5 RestConnection (com.blackducksoftware.integration.hub.rest.RestConnection)5 Slf4jIntLogger (com.blackducksoftware.integration.log.Slf4jIntLogger)5 ExternalConnectionTest (com.blackducksoftware.integration.test.annotation.ExternalConnectionTest)5 HubConnectionTest (com.blackducksoftware.integration.test.annotation.HubConnectionTest)5 AuditEntryRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper)4 ProjectData (com.blackducksoftware.integration.hub.alert.digest.model.ProjectData)4 ObjectTransformer (com.blackducksoftware.integration.hub.alert.web.ObjectTransformer)4 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)3 GlobalHipChatConfigEntity (com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.global.GlobalHipChatConfigEntity)3 GlobalHubConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity)3 GlobalHubConfigRestModel (com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigRestModel)3 GlobalActionsTest (com.blackducksoftware.integration.hub.alert.web.actions.global.GlobalActionsTest)3 HubServerConfigBuilder (com.blackducksoftware.integration.hub.configuration.HubServerConfigBuilder)3