Search in sources :

Example 11 with GlobalHubConfigEntity

use of com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity in project hub-alert by blackducksoftware.

the class ObjectTransformerTest method testTransformGlobalModels.

@Test
public void testTransformGlobalModels() throws Exception {
    final ObjectTransformer objectTransformer = new ObjectTransformer();
    final MockGlobalHubRestModel globalHubMockUtils = new MockGlobalHubRestModel();
    final MockGlobalHubEntity mockGlobalHubEntity = new MockGlobalHubEntity();
    final GlobalHubConfigRestModel restModel = globalHubMockUtils.createGlobalRestModel();
    final GlobalHubConfigEntity configEntity = mockGlobalHubEntity.createGlobalEntity();
    final GlobalHubConfigEntity transformedConfigEntity = objectTransformer.configRestModelToDatabaseEntity(restModel, GlobalHubConfigEntity.class);
    final GlobalHubConfigRestModel transformedConfigRestModel = objectTransformer.databaseEntityToConfigRestModel(configEntity, GlobalHubConfigRestModel.class);
    assertNull(transformedConfigRestModel.getHubAlwaysTrustCertificate());
    assertEquals(restModel.getHubApiKey(), transformedConfigRestModel.getHubApiKey());
    assertNull(transformedConfigRestModel.getHubProxyHost());
    assertNull(transformedConfigRestModel.getHubProxyPassword());
    assertNull(transformedConfigRestModel.getHubProxyPort());
    assertNull(transformedConfigRestModel.getHubProxyUsername());
    assertEquals(restModel.getHubTimeout(), transformedConfigRestModel.getHubTimeout());
    assertNull(transformedConfigRestModel.getHubUrl());
    assertEquals(restModel.getId(), transformedConfigRestModel.getId());
    assertEquals(configEntity.getHubApiKey(), transformedConfigEntity.getHubApiKey());
    assertEquals(configEntity.getHubTimeout(), transformedConfigEntity.getHubTimeout());
    assertEquals(configEntity.getId(), transformedConfigEntity.getId());
}
Also used : GlobalHubConfigRestModel(com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigRestModel) MockGlobalHubRestModel(com.blackducksoftware.integration.hub.alert.hub.mock.MockGlobalHubRestModel) MockGlobalHubEntity(com.blackducksoftware.integration.hub.alert.hub.mock.MockGlobalHubEntity) GlobalHubConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity) Test(org.junit.Test)

Example 12 with GlobalHubConfigEntity

use of com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity in project hub-alert by blackducksoftware.

the class StartupManager method logConfiguration.

public void logConfiguration() {
    final GlobalHubConfigEntity globalHubConfig = globalProperties.getHubConfig();
    final boolean authenticatedProxy = StringUtils.isNotBlank(globalProperties.getHubProxyPassword());
    logger.info("----------------------------------------");
    logger.info("Alert Configuration: ");
    logger.info("Logging level:           {}", loggingLevel);
    logger.info("Hub URL:                 {}", globalProperties.getHubUrl());
    logger.info("Hub Proxy Host:          {}", globalProperties.getHubProxyHost());
    logger.info("Hub Proxy Port:          {}", globalProperties.getHubProxyPort());
    logger.info("Hub Proxy Authenticated: {}", authenticatedProxy);
    logger.info("Hub Proxy User:          {}", globalProperties.getHubProxyUsername());
    if (globalHubConfig != null) {
        logger.info("Hub API Token:           **********");
        logger.info("Hub Timeout:             {}", globalHubConfig.getHubTimeout());
    }
    logger.info("----------------------------------------");
}
Also used : GlobalHubConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity)

Example 13 with GlobalHubConfigEntity

use of com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity in project hub-alert by blackducksoftware.

the class GlobalHubRepositoryWrapper method encryptSensitiveData.

@Override
public GlobalHubConfigEntity encryptSensitiveData(final GlobalHubConfigEntity entity) throws EncryptionException {
    String hubApiKey = entity.getHubApiKey();
    if (StringUtils.isBlank(hubApiKey)) {
        return entity;
    } else {
        final Integer hubTimeout = entity.getHubTimeout();
        hubApiKey = PasswordEncrypter.encrypt(hubApiKey);
        final GlobalHubConfigEntity newEntity = new GlobalHubConfigEntity(hubTimeout, hubApiKey);
        newEntity.setId(entity.getId());
        return newEntity;
    }
}
Also used : GlobalHubConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity)

Aggregations

GlobalHubConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity)13 Test (org.junit.Test)7 GlobalHubRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper)5 GlobalHubConfigRestModel (com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigRestModel)5 GlobalHubConfigActions (com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigActions)4 TestGlobalProperties (com.blackducksoftware.integration.hub.alert.TestGlobalProperties)3 ObjectTransformer (com.blackducksoftware.integration.hub.alert.web.ObjectTransformer)2 GlobalActionsTest (com.blackducksoftware.integration.hub.alert.web.actions.global.GlobalActionsTest)2 HubServerConfigBuilder (com.blackducksoftware.integration.hub.configuration.HubServerConfigBuilder)2 RestConnection (com.blackducksoftware.integration.hub.rest.RestConnection)2 AuditEntryRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper)1 ChannelTest (com.blackducksoftware.integration.hub.alert.channel.ChannelTest)1 MockEmailEntity (com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailEntity)1 GlobalEmailConfigEntity (com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity)1 ProjectData (com.blackducksoftware.integration.hub.alert.digest.model.ProjectData)1 MockGlobalHubEntity (com.blackducksoftware.integration.hub.alert.hub.mock.MockGlobalHubEntity)1 MockGlobalHubRestModel (com.blackducksoftware.integration.hub.alert.hub.mock.MockGlobalHubRestModel)1 Slf4jIntLogger (com.blackducksoftware.integration.log.Slf4jIntLogger)1 DatabaseConnectionTest (com.blackducksoftware.integration.test.annotation.DatabaseConnectionTest)1 ExternalConnectionTest (com.blackducksoftware.integration.test.annotation.ExternalConnectionTest)1