use of com.synopsys.integration.alert.test.common.TestProperties in project hub-alert by blackducksoftware.
the class AlertIntegrationTestConfiguration method initBlackDuckData.
// FIXME delete
@Deprecated(forRemoval = true)
public void initBlackDuckData() throws AlertException {
TestProperties testProperties = new TestProperties();
ConfigurationFieldModel blackDuckURLField = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_URL);
blackDuckURLField.setFieldValue(testProperties.getBlackDuckURL());
ConfigurationFieldModel blackDuckAPITokenField = ConfigurationFieldModel.createSensitive(BlackDuckDescriptor.KEY_BLACKDUCK_API_KEY);
blackDuckAPITokenField.setFieldValue(testProperties.getBlackDuckAPIToken());
ConfigurationFieldModel blackDuckTimeoutField = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_TIMEOUT);
blackDuckTimeoutField.setFieldValue(testProperties.getProperty(TestPropertyKey.TEST_BLACKDUCK_PROVIDER_TIMEOUT));
BlackDuckProviderKey blackDuckProviderKey = new BlackDuckProviderKey();
ConfigurationModel blackDuckConfiguration = configurationModelConfigurationAccessor.getConfigurationsByDescriptorKeyAndContext(blackDuckProviderKey, ConfigContextEnum.GLOBAL).stream().findFirst().orElse(configurationModelConfigurationAccessor.createConfiguration(blackDuckProviderKey, ConfigContextEnum.GLOBAL, List.of(blackDuckURLField, blackDuckAPITokenField, blackDuckTimeoutField)));
configurationModelConfigurationAccessor.updateConfiguration(blackDuckConfiguration.getConfigurationId(), List.of(blackDuckURLField, blackDuckAPITokenField, blackDuckTimeoutField));
}
use of com.synopsys.integration.alert.test.common.TestProperties in project hub-alert by blackducksoftware.
the class NotificationReceivedEventHandlerTestIT method init.
@BeforeEach
public void init() {
properties = new TestProperties();
ConfigurationFieldModel providerConfigEnabled = ConfigurationFieldModel.create(ProviderDescriptor.KEY_PROVIDER_CONFIG_ENABLED);
providerConfigEnabled.setFieldValue("TRUE");
ConfigurationFieldModel providerConfigName = ConfigurationFieldModel.create(ProviderDescriptor.KEY_PROVIDER_CONFIG_NAME);
providerConfigName.setFieldValue("blackduck-config");
ConfigurationFieldModel blackduckUrl = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_URL);
blackduckUrl.setFieldValue(properties.getBlackDuckURL());
ConfigurationFieldModel blackduckApiKey = ConfigurationFieldModel.createSensitive(BlackDuckDescriptor.KEY_BLACKDUCK_API_KEY);
blackduckApiKey.setFieldValue(properties.getBlackDuckAPIToken());
ConfigurationFieldModel blackduckTimeout = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_TIMEOUT);
blackduckTimeout.setFieldValue(String.valueOf(BlackDuckProperties.DEFAULT_TIMEOUT));
ConfigurationModel blackduckConfigurationModel = defaultConfigurationAccessor.createConfiguration(blackDuckProviderKey, ConfigContextEnum.GLOBAL, List.of(providerConfigEnabled, providerConfigName, blackduckUrl, blackduckApiKey, blackduckTimeout));
blackDuckGlobalConfigId = blackduckConfigurationModel.getConfigurationId();
}
use of com.synopsys.integration.alert.test.common.TestProperties in project hub-alert by blackducksoftware.
the class JiraCloudSummaryFieldLengthTestIT method createJiraCloudMessageSender.
private static IssueTrackerMessageSender<String> createJiraCloudMessageSender() throws AlertException {
TestProperties testProperties = new TestProperties();
Gson gson = new GsonBuilder().create();
IssueCategoryRetriever issueCategoryRetriever = new IssueCategoryRetriever();
JiraCloudMessageSenderFactory jiraCloudMessageSenderFactory = new JiraCloudMessageSenderFactory(gson, ChannelKeys.JIRA_CLOUD, createJiraCloudPropertiesFactory(testProperties), new IssueTrackerCallbackInfoCreator(), issueCategoryRetriever);
JiraCloudJobDetailsModel jiraCloudJobDetails = createJiraCloudJobDetails(testProperties);
return jiraCloudMessageSenderFactory.createMessageSender(jiraCloudJobDetails);
}
use of com.synopsys.integration.alert.test.common.TestProperties in project hub-alert by blackducksoftware.
the class AuthenticationActionsTestIT method userLoginWithBadCredentialsTest.
@Test
public void userLoginWithBadCredentialsTest() {
AlertAuthenticationProvider authenticationProvider = Mockito.mock(AlertAuthenticationProvider.class);
Mockito.when(authenticationProvider.authenticate(Mockito.any())).thenThrow(new BadCredentialsException("Bad credentials test"));
AuthenticationActions authenticationActions = new AuthenticationActions(authenticationProvider, csrfTokenRepository);
HttpServletRequest servletRequest = new MockHttpServletRequest();
HttpServletResponse servletResponse = new MockHttpServletResponse();
TestProperties testProperties = new TestProperties();
MockLoginRestModel mockLoginRestModel = new MockLoginRestModel();
mockLoginRestModel.setAlertUsername(testProperties.getProperty(TestPropertyKey.TEST_BLACKDUCK_PROVIDER_USERNAME));
mockLoginRestModel.setAlertPassword(testProperties.getProperty(TestPropertyKey.TEST_BLACKDUCK_PROVIDER_PASSWORD));
ActionResponse<Void> response = authenticationActions.authenticateUser(servletRequest, servletResponse, mockLoginRestModel.createRestModel());
assertTrue(response.isError());
assertEquals(HttpStatus.UNAUTHORIZED, response.getHttpStatus());
}
use of com.synopsys.integration.alert.test.common.TestProperties in project hub-alert by blackducksoftware.
the class AuthenticationControllerTestIT method testLogin.
@Test
public void testLogin() throws Exception {
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(loginUrl);
TestProperties testProperties = new TestProperties();
MockLoginRestModel mockLoginRestModel = new MockLoginRestModel();
mockLoginRestModel.setAlertUsername(testProperties.getProperty(TestPropertyKey.TEST_BLACKDUCK_PROVIDER_USERNAME));
mockLoginRestModel.setAlertPassword(testProperties.getProperty(TestPropertyKey.TEST_BLACKDUCK_PROVIDER_PASSWORD));
ReflectionTestUtils.setField(alertProperties, "alertTrustCertificate", Boolean.valueOf(testProperties.getProperty(TestPropertyKey.TEST_BLACKDUCK_PROVIDER_TRUST_HTTPS_CERT)));
String restModel = mockLoginRestModel.getRestModelJson();
request.content(restModel);
request.contentType(contentType);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isNoContent());
}
Aggregations