Search in sources :

Example 1 with SSCHandler

use of com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler in project octane-ci-java-sdk by MicroFocus.

the class SSCHandlerTest method scanIsOverButNoIssueTest.

@Test
public void scanIsOverButNoIssueTest() throws IOException {
    String projectResponse = getDummyProjectResponse();
    String projectVersionsResponse = getProjectVersionResponse();
    String artifactResponse = getArtificatResponse("PROCESS_COMPLETE");
    MockSSCRestClient mockSSCRestClient = new MockSSCRestClient(Arrays.asList(projectResponse, projectVersionsResponse, artifactResponse, "{\"data\":[]}"));
    SSCHandler sscHandler = new SSCHandler(queueItem, configMock, mockSSCRestClient);
    Optional<Issues> issuesIfScanCompleted = sscHandler.getIssuesIfScanCompleted();
    Assert.assertTrue(issuesIfScanCompleted.isPresent());
    Assert.assertEquals(0, issuesIfScanCompleted.get().getData().size());
}
Also used : MockSSCRestClient(com.hp.octane.integrations.services.vulnerabilities.mocks.MockSSCRestClient) SSCHandler(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler) Issues(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues) Test(org.junit.Test)

Example 2 with SSCHandler

use of com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler in project octane-ci-java-sdk by MicroFocus.

the class SSCHandlerTest method errorInScanTest.

@Test(expected = PermanentException.class)
public void errorInScanTest() throws IOException {
    String projectResponse = getDummyProjectResponse();
    String projectVersionsResponse = getProjectVersionResponse();
    String artifactResponse = getArtificatResponse("ERROR_PROCESSING");
    MockSSCRestClient mockSSCRestClient = new MockSSCRestClient(Arrays.asList(projectResponse, projectVersionsResponse, artifactResponse));
    SSCHandler sscHandler = new SSCHandler(queueItem, configMock, mockSSCRestClient);
    sscHandler.isScanProcessFinished();
}
Also used : MockSSCRestClient(com.hp.octane.integrations.services.vulnerabilities.mocks.MockSSCRestClient) SSCHandler(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler) Test(org.junit.Test)

Example 3 with SSCHandler

use of com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler in project octane-ci-java-sdk by MicroFocus.

the class SSCHandlerTest method scanIsNotOverTest.

@Test
public void scanIsNotOverTest() throws IOException {
    String projectResponse = getDummyProjectResponse();
    String projectVersionsResponse = getProjectVersionResponse();
    String artifactResponse = getArtificatResponse("PROCESSING");
    MockSSCRestClient mockSSCRestClient = new MockSSCRestClient(Arrays.asList(projectResponse, projectVersionsResponse, artifactResponse));
    SSCHandler sscHandler = new SSCHandler(queueItem, configMock, mockSSCRestClient);
    Assert.assertFalse(sscHandler.isScanProcessFinished());
}
Also used : MockSSCRestClient(com.hp.octane.integrations.services.vulnerabilities.mocks.MockSSCRestClient) SSCHandler(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler) Test(org.junit.Test)

Example 4 with SSCHandler

use of com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler in project octane-ci-java-sdk by MicroFocus.

the class SSCHandlerTest method scanIsOverAndThereAreIssuesTest.

@Test
public void scanIsOverAndThereAreIssuesTest() throws IOException {
    String projectResponse = getDummyProjectResponse();
    String projectVersionsResponse = getProjectVersionResponse();
    String artifactResponse = getArtificatResponse("PROCESS_COMPLETE");
    MockSSCRestClient mockSSCRestClient = new MockSSCRestClient(Arrays.asList(projectResponse, projectVersionsResponse, artifactResponse, DummyContents.issuesPart1, DummyContents.issuesPart2, DummyContents.issuesPart3));
    SSCHandler sscHandler = new SSCHandler(queueItem, configMock, mockSSCRestClient);
    Optional<Issues> issuesIfScanCompleted = sscHandler.getIssuesIfScanCompleted();
    Assert.assertTrue(issuesIfScanCompleted.isPresent());
    Assert.assertEquals(3, issuesIfScanCompleted.get().getData().size());
}
Also used : MockSSCRestClient(com.hp.octane.integrations.services.vulnerabilities.mocks.MockSSCRestClient) SSCHandler(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler) Issues(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues) Test(org.junit.Test)

Example 5 with SSCHandler

use of com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler in project octane-ci-java-sdk by MicroFocus.

the class VulnerabilitiesTests method simpleFields.

@Test
public void simpleFields() {
    Issues.Issue issue = new Issues.Issue();
    issue.fullFileName = "fullFileName";
    issue.lineNumber = 100;
    issue.issueInstanceId = "ID_ID_ID";
    issue.foundDate = "2018-09-12T14:01:20.590+0000";
    issue.hRef = "hRef";
    Issues sscIssues = new Issues();
    sscIssues.setData(Arrays.asList(issue));
    SSCHandler sscHandler = new SSCHandler();
    List<OctaneIssue> octaneIssues = createOctaneIssues(sscIssues.getData(), "Tag", new HashMap<>());
    Assert.assertEquals(octaneIssues.get(0).getPrimaryLocationFull(), "fullFileName");
    Assert.assertEquals(String.valueOf(octaneIssues.get(0).getLine()), String.valueOf(100));
    Assert.assertEquals(octaneIssues.get(0).getRemoteId(), "ID_ID_ID");
    Assert.assertNotNull(octaneIssues.get(0).getIntroducedDate());
    Assert.assertEquals(octaneIssues.get(0).getExternalLink(), "hRef");
}
Also used : OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) SSCHandler(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler) SSCToOctaneIssueUtil.createOctaneIssues(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCToOctaneIssueUtil.createOctaneIssues) Issues(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues) OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) Test(org.junit.Test)

Aggregations

SSCHandler (com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler)8 Test (org.junit.Test)8 Issues (com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues)6 OctaneIssue (com.hp.octane.integrations.dto.securityscans.OctaneIssue)4 MockSSCRestClient (com.hp.octane.integrations.services.vulnerabilities.mocks.MockSSCRestClient)4 SSCToOctaneIssueUtil.createOctaneIssues (com.hp.octane.integrations.services.vulnerabilities.ssc.SSCToOctaneIssueUtil.createOctaneIssues)4