Search in sources :

Example 6 with IssueCreationModel

use of com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel in project hub-alert by blackducksoftware.

the class ProjectIssueModelConverterTest method toIssueCreationModelVulnerabilityTest.

@Test
public void toIssueCreationModelVulnerabilityTest() {
    IssueVulnerabilityModel vuln1 = createIssueVulnerability(ComponentConcernSeverity.MAJOR_HIGH, "CVE-13579", "https://a-url");
    IssueVulnerabilityModel vuln2 = createIssueVulnerability(ComponentConcernSeverity.MAJOR_HIGH, "CVE-24680", "https://a-url");
    IssueVulnerabilityModel vuln3 = createIssueVulnerability(ComponentConcernSeverity.MAJOR_HIGH, "CVE-235711", "https://a-url");
    IssueVulnerabilityModel vuln4 = createIssueVulnerability(ComponentConcernSeverity.MAJOR_HIGH, "CVE-112358", "https://a-url");
    IssueVulnerabilityDetails vulnerabilityDetails = new IssueVulnerabilityDetails(false, List.of(), List.of(vuln1), List.of(vuln2, vuln3, vuln4));
    ProjectIssueModel projectIssueModel = ProjectIssueModel.vulnerability(PROVIDER_DETAILS, PROJECT_ITEM, PROJECT_VERSION_ITEM, ISSUE_BOM_COMPONENT_DETAILS, vulnerabilityDetails);
    IssueCreationModel issueCreationModel = basicIssueCreationModelTest(projectIssueModel);
    assertTrue(issueCreationModel.getTitle().contains(vuln1.getVulnerability().getLabel()), "Expected vulnerability label to be present in the title");
}
Also used : IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) IssueVulnerabilityDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails) IssueVulnerabilityModel(com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityModel) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) Test(org.junit.jupiter.api.Test)

Example 7 with IssueCreationModel

use of com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel in project hub-alert by blackducksoftware.

the class ProjectIssueModelConverterTest method toIssueCreationModelWithVulnerabilitySeverityTest.

@Test
public void toIssueCreationModelWithVulnerabilitySeverityTest() {
    MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
    ProjectIssueModelConverter converter = new ProjectIssueModelConverter(formatter);
    IssueVulnerabilityModel vuln = createIssueVulnerability(ComponentConcernSeverity.MAJOR_HIGH, "CVE-13579", "https://a-url");
    IssueVulnerabilityDetails vulnerabilityDetails = new IssueVulnerabilityDetails(false, List.of(), List.of(vuln), List.of());
    ComponentVulnerabilities componentVulnerabilities = new ComponentVulnerabilities(List.of(new LinkableItem("VulnerabilityCritical", "CVE-004")), List.of(new LinkableItem("VulnerabilityHigh", "CVE-005")), List.of(new LinkableItem("VulnerabilityMedium", "CVE-006")), List.of(new LinkableItem("VulnerabilityLow", "CVE-007")));
    AbstractBomComponentDetails vulnerableBomComponentDetails = createBomComponentDetailsWithComponentVulnerabilities(componentVulnerabilities);
    IssueBomComponentDetails issueBomComponentDetails = IssueBomComponentDetails.fromBomComponentDetails(vulnerableBomComponentDetails);
    ProjectIssueModel projectIssueModel = ProjectIssueModel.vulnerability(PROVIDER_DETAILS, PROJECT_ITEM, PROJECT_VERSION_ITEM, issueBomComponentDetails, vulnerabilityDetails);
    IssueCreationModel issueCreationModel = converter.toIssueCreationModel(projectIssueModel, "jobName");
    assertTrue(issueCreationModel.getDescription().contains(ComponentConcernSeverity.CRITICAL.getVulnerabilityLabel()), "Expected highest vulnerability severity in the description to be CRITICAL");
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) IssueVulnerabilityDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails) IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails) AbstractBomComponentDetails(com.synopsys.integration.alert.processor.api.extract.model.project.AbstractBomComponentDetails) IssueVulnerabilityModel(com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityModel) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) MockIssueTrackerMessageFormatter(com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter) ComponentVulnerabilities(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities) Test(org.junit.jupiter.api.Test)

Example 8 with IssueCreationModel

use of com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel in project hub-alert by blackducksoftware.

the class ProjectIssueModelConverterTest method basicIssueCreationModelTest.

private IssueCreationModel basicIssueCreationModelTest(ProjectIssueModel projectIssueModel) {
    MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
    ProjectIssueModelConverter converter = new ProjectIssueModelConverter(formatter);
    IssueCreationModel issueCreationModel = converter.toIssueCreationModel(projectIssueModel, "jobName");
    assertEquals(projectIssueModel, issueCreationModel.getSource().orElse(null));
    String issueCreationModelTitle = issueCreationModel.getTitle();
    assertTrue(issueCreationModelTitle.contains(PROVIDER_DETAILS.getProvider().getValue()), "Expected provider value to be present in the title");
    assertTrue(issueCreationModelTitle.contains(PROJECT_ITEM.getValue()), "Expected project value to be present in the title");
    assertTrue(issueCreationModelTitle.contains(PROJECT_VERSION_ITEM.getValue()), "Expected project-version value to be present in the title");
    assertTrue(issueCreationModelTitle.contains(COMPONENT_ITEM.getValue()), "Expected component value to be present in the title");
    assertTrue(issueCreationModelTitle.contains(COMPONENT_VERSION_ITEM.getValue()), "Expected component-version value to be present in the title");
    return issueCreationModel;
}
Also used : IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) MockIssueTrackerMessageFormatter(com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)

Example 9 with IssueCreationModel

use of com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel in project hub-alert by blackducksoftware.

the class JiraCloudIssueCreatorTest method verifySummaryReplacingValues.

@Test
public void verifySummaryReplacingValues() throws IntegrationException {
    String projectNameOrKey = "FakeProject";
    JiraCloudJobDetailsModel jiraCloudJobDetailsModel = new JiraCloudJobDetailsModel(UUID.randomUUID(), false, "my@email.com", projectNameOrKey, "Task", null, null, List.of(), "testSummary {{providerName}}");
    TestJiraCloudIssueCreator jiraCloudIssueCreator = createTestJiraCloudIssueCreator(projectNameOrKey, jiraCloudJobDetailsModel);
    IssueCreationModel issueCreationModel = createIssueCreationModel();
    String testProviderName = "providerName";
    MessageReplacementValues messageReplacementValues = new MessageReplacementValues.Builder(testProviderName, "projectName").projectVersionName("projectVersionName").componentName("componentName").componentVersionName("componentVersionName").severity("severity").policyCategory("UNCATEGORIZED").build();
    IssueCreationRequestModel issueCreationRequest = jiraCloudIssueCreator.createIssueCreationRequest(issueCreationModel, messageReplacementValues);
    String summaryText = getSummary(issueCreationRequest);
    assertEquals("testSummary " + testProviderName, summaryText);
}
Also used : MessageReplacementValues(com.synopsys.integration.alert.api.channel.jira.distribution.custom.MessageReplacementValues) IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) IssueCreationRequestModel(com.synopsys.integration.jira.common.cloud.model.IssueCreationRequestModel) IssueRequestModelFieldsBuilder(com.synopsys.integration.jira.common.cloud.builder.IssueRequestModelFieldsBuilder) JiraCloudJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.JiraCloudJobDetailsModel) Test(org.junit.jupiter.api.Test)

Example 10 with IssueCreationModel

use of com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel in project hub-alert by blackducksoftware.

the class JiraCloudIssueCreatorTest method verifyIssueSummaryReplacement.

@Test
public void verifyIssueSummaryReplacement() throws IntegrationException {
    String testSummary = "testSummary";
    String projectNameOrKey = "FakeProject";
    JiraCloudJobDetailsModel jiraCloudJobDetailsModel = new JiraCloudJobDetailsModel(UUID.randomUUID(), false, "my@email.com", projectNameOrKey, "Task", null, null, List.of(), testSummary);
    TestJiraCloudIssueCreator jiraCloudIssueCreator = createTestJiraCloudIssueCreator(projectNameOrKey, jiraCloudJobDetailsModel);
    IssueCreationModel issueCreationModel = createIssueCreationModel();
    MessageReplacementValues messageReplacementValues = new MessageReplacementValues.Builder("providerName", "projectName").projectVersionName("projectVersionName").componentName("componentName").componentVersionName("componentVersionName").severity("severity").policyCategory("UNCATEGORIZED").build();
    IssueCreationRequestModel issueCreationRequest = jiraCloudIssueCreator.createIssueCreationRequest(issueCreationModel, messageReplacementValues);
    String summaryText = getSummary(issueCreationRequest);
    assertEquals(testSummary, summaryText);
}
Also used : MessageReplacementValues(com.synopsys.integration.alert.api.channel.jira.distribution.custom.MessageReplacementValues) IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) IssueCreationRequestModel(com.synopsys.integration.jira.common.cloud.model.IssueCreationRequestModel) IssueRequestModelFieldsBuilder(com.synopsys.integration.jira.common.cloud.builder.IssueRequestModelFieldsBuilder) JiraCloudJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.JiraCloudJobDetailsModel) Test(org.junit.jupiter.api.Test)

Aggregations

IssueCreationModel (com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel)21 Test (org.junit.jupiter.api.Test)15 IssueTrackerModelHolder (com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerModelHolder)8 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)8 MockIssueTrackerMessageFormatter (com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)6 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)5 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)4 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)3 IssueVulnerabilityDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails)3 ExistingIssueDetails (com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails)3 IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)2 IssueVulnerabilityModel (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityModel)2 MessageReplacementValues (com.synopsys.integration.alert.api.channel.jira.distribution.custom.MessageReplacementValues)2 JiraCloudJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.JiraCloudJobDetailsModel)2 SimpleMessage (com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage)2 ComponentVulnerabilities (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities)2 IssueRequestModelFieldsBuilder (com.synopsys.integration.jira.common.cloud.builder.IssueRequestModelFieldsBuilder)2 IssueCreationRequestModel (com.synopsys.integration.jira.common.cloud.model.IssueCreationRequestModel)2 BomComponentDetailConverter (com.synopsys.integration.alert.api.channel.convert.BomComponentDetailConverter)1 LinkableItemConverter (com.synopsys.integration.alert.api.channel.convert.LinkableItemConverter)1