use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel in project hub-alert by blackducksoftware.
the class JobNotificationMapperTestIT method extractSingleJob.
@Test
public void extractSingleJob() {
DistributionJobRequestModel jobRequestModel = createJobRequestModel(FrequencyType.REAL_TIME, ProcessingType.DIGEST, List.of(), List.of(NotificationType.VULNERABILITY.name(), NotificationType.POLICY_OVERRIDE.name()), List.of(), List.of());
testSingleJob(jobRequestModel, 4);
}
use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel in project hub-alert by blackducksoftware.
the class JobNotificationMapperTestIT method createDistributionJobModels.
private List<DistributionJobRequestModel> createDistributionJobModels(List<String> vulnTypes, int numberOfJobs) {
List<DistributionJobRequestModel> jobModels = new ArrayList<>();
for (int i = 0; i < numberOfJobs; i++) {
DistributionJobRequestModel distributionJobRequestModel = createJobRequestModel(FrequencyType.REAL_TIME, ProcessingType.DIGEST, List.of(), List.of(NotificationType.VULNERABILITY.name()), vulnTypes, List.of());
jobModels.add(distributionJobRequestModel);
}
return jobModels;
}
use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel in project hub-alert by blackducksoftware.
the class JobNotificationMapperTestIT method extractJobsWithMatchingProjectVersionNamePatternFilter.
@Test
public void extractJobsWithMatchingProjectVersionNamePatternFilter() {
createJobs(List.of(new DistributionJobRequestModel(true, "name", FrequencyType.REAL_TIME, ProcessingType.DIGEST, ChannelKeys.SLACK.getUniversalKey(), UUID.randomUUID(), 0L, true, null, // Regex to verify we retrieve notifications without a number in the name (PROJECT_VERSION_NAME_1)
"^([^0-9]*)$", List.of(NotificationType.VULNERABILITY.name()), List.of(), List.of(), List.of(), new SlackJobDetailsModel(null, "webhook", "channelName", "username"))));
testProjectJob();
}
use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel in project hub-alert by blackducksoftware.
the class JobConfigControllerTestIT method testUpdateConfig.
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void testUpdateConfig() throws Exception {
ConfigurationModel providerGlobalConfig = addGlobalConfiguration(blackDuckProviderKey, Map.of(ProviderDescriptor.KEY_PROVIDER_CONFIG_NAME, List.of(DEFAULT_BLACK_DUCK_CONFIG), BlackDuckDescriptor.KEY_BLACKDUCK_URL, List.of(testProperties.getBlackDuckURL()), BlackDuckDescriptor.KEY_BLACKDUCK_API_KEY, List.of(testProperties.getBlackDuckAPIToken())));
JobFieldModel fieldModel = createTestJobFieldModel("1", "2", providerGlobalConfig);
Map<String, Collection<String>> fieldValueModels = new HashMap<>();
for (FieldModel newFieldModel : fieldModel.getFieldModels()) {
fieldValueModels.putAll(newFieldModel.getKeyToValues().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().getValues())));
}
DistributionJobRequestModel jobRequestModel = createDistributionJobRequestModel(providerGlobalConfig.getConfigurationId());
DistributionJobModel distributionJobModel = addDistributionJob(jobRequestModel);
String configId = String.valueOf(distributionJobModel.getJobId());
String urlPath = REQUEST_URL + "/" + configId;
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.put(urlPath).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
fieldModel.setJobId(configId);
request.content(gson.toJson(fieldModel));
request.contentType(MEDIA_TYPE);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isNoContent());
}
use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobRequestModel in project hub-alert by blackducksoftware.
the class JmsNotificationReceiverTestIT 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("https://www.synopsys.com");
ConfigurationFieldModel blackduckApiKey = ConfigurationFieldModel.createSensitive(BlackDuckDescriptor.KEY_BLACKDUCK_API_KEY);
blackduckApiKey.setFieldValue("someApiKey");
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();
List<AlertNotificationModel> notificationContent = new ArrayList<>();
for (Long i = 1L; i <= 1000; i++) {
notificationContent.add(createAlertNotificationModel(i, false));
}
savedModels = defaultNotificationAccessor.saveAllNotifications(notificationContent);
SlackJobDetailsModel slackJobDetailsModel = createSlackJobDetailsModel();
DistributionJobRequestModel distributionJobRequestModel = createDistributionJobRequestModel("jobName1", slackJobDetailsModel);
distributionJobModel = staticJobAccessor.createJob(distributionJobRequestModel);
}
Aggregations