use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class AuditEntryControllerTestIT method testResendJobConfig.
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void testResendJobConfig() throws Exception {
List<ConfigurationFieldModel> slackFields = new ArrayList<>(MockConfigurationModelFactory.createSlackDistributionFields());
ConfigurationFieldModel providerConfigName = providerConfigModel.getField(ProviderDescriptor.KEY_PROVIDER_CONFIG_NAME).orElse(null);
slackFields.add(providerConfigName);
DistributionJobRequestModel jobRequestModel = createJobRequestModel();
DistributionJobModel jobModel = jobAccessor.createJob(jobRequestModel);
NotificationEntity notificationEntity = mockNotificationContent.createEntity();
notificationEntity = notificationRepository.save(notificationEntity);
mockAuditEntryEntity.setCommonConfigId(jobModel.getJobId());
AuditEntryEntity auditEntity = mockAuditEntryEntity.createEntity();
auditEntity = auditEntryRepository.save(auditEntity);
auditNotificationRepository.save(new AuditNotificationRelation(auditEntity.getId(), notificationEntity.getId()));
String resendUrl = auditUrl + "/resend/" + notificationEntity.getId() + "/job/" + auditEntity.getCommonConfigId();
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(resendUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class AuditEntryHandlerTestIT method init.
@BeforeEach
public void init() {
auditEntryRepository.flush();
notificationContentRepository.flush();
descriptorConfigRepository.flush();
fieldValueRepository.flush();
auditEntryRepository.deleteAllInBatch();
notificationContentRepository.deleteAllInBatch();
descriptorConfigRepository.deleteAllInBatch();
fieldValueRepository.deleteAllInBatch();
ConfigurationFieldModel providerConfigEnabled = ConfigurationFieldModel.create(ProviderDescriptor.KEY_PROVIDER_CONFIG_ENABLED);
providerConfigEnabled.setFieldValue("true");
ConfigurationFieldModel providerConfigName = ConfigurationFieldModel.create(ProviderDescriptor.KEY_PROVIDER_CONFIG_NAME);
providerConfigName.setFieldValue("My Black Duck Config");
ConfigurationFieldModel blackduckUrl = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_URL);
blackduckUrl.setFieldValue("https://a-blackduck-server");
ConfigurationFieldModel blackduckApiKey = ConfigurationFieldModel.createSensitive(BlackDuckDescriptor.KEY_BLACKDUCK_API_KEY);
blackduckApiKey.setFieldValue("123456789012345678901234567890123456789012345678901234567890");
ConfigurationFieldModel blackduckTimeout = ConfigurationFieldModel.create(BlackDuckDescriptor.KEY_BLACKDUCK_TIMEOUT);
blackduckTimeout.setFieldValue("300");
List<ConfigurationFieldModel> providerConfigFields = List.of(providerConfigEnabled, providerConfigName, blackduckUrl, blackduckApiKey, blackduckTimeout);
providerConfigModel = configurationModelConfigurationAccessor.createConfiguration(new BlackDuckProviderKey(), ConfigContextEnum.GLOBAL, providerConfigFields);
mockNotification.setProviderConfigId(providerConfigModel.getConfigurationId());
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class ConfigurationFieldModelConverter method convertToFieldModel.
public FieldModel convertToFieldModel(ConfigurationModel configurationModel) {
Long configId = configurationModel.getConfigurationId();
String descriptorName = getDescriptorName(configurationModel);
Map<String, FieldValueModel> fields = new HashMap<>();
for (ConfigurationFieldModel fieldModel : configurationModel.getCopyOfFieldList()) {
populateAndSecureFields(fieldModel, fields);
}
return new FieldModel(configId.toString(), descriptorName, configurationModel.getDescriptorContext().name(), configurationModel.getCreatedAt(), configurationModel.getLastUpdated(), fields);
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class FieldModelProcessor method populateTestFieldModel.
private FieldModel populateTestFieldModel(Long id, FieldModel fieldModel) throws AlertException {
Collection<ConfigurationFieldModel> configurationFieldModels = fillFieldModelWithExistingData(id, fieldModel);
Map<String, FieldValueModel> fields = new HashMap<>();
for (ConfigurationFieldModel configurationFieldModel : configurationFieldModels) {
FieldValueModel fieldValueModel = new FieldValueModel(configurationFieldModel.getFieldValues(), configurationFieldModel.isSet());
fields.put(configurationFieldModel.getFieldKey(), fieldValueModel);
}
FieldModel newFieldModel = new FieldModel("", "", fieldModel.getCreatedAt(), fieldModel.getLastUpdated(), fields);
return fieldModel.fill(newFieldModel);
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class DefaultDescriptorGlobalConfigUtility method updateSensitiveFields.
// TODO build a new utility to perform this action or try to refactor FieldModelProcessor into the alert-common sub-project
private Map<String, ConfigurationFieldModel> updateSensitiveFields(Map<String, ConfigurationFieldModel> values, ConfigurationModel existingConfig) {
Collection<ConfigurationFieldModel> sensitiveFields = existingConfig.getCopyOfFieldList().stream().filter(ConfigurationFieldModel::isSensitive).collect(Collectors.toSet());
for (ConfigurationFieldModel sensitiveConfigurationFieldModel : sensitiveFields) {
String fieldKey = sensitiveConfigurationFieldModel.getFieldKey();
if (values.containsKey(fieldKey)) {
ConfigurationFieldModel sensitiveFieldModel = values.get(fieldKey);
if (!sensitiveFieldModel.isSet()) {
ConfigurationFieldModel newFieldModel = values.get(fieldKey);
newFieldModel.setFieldValues(sensitiveConfigurationFieldModel.getFieldValues());
}
}
}
return values;
}
Aggregations