Search in sources :

Example 1 with MockSSCRestClient

use of com.hp.octane.integrations.services.vulnerabilities.mocks.MockSSCRestClient 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 MockSSCRestClient

use of com.hp.octane.integrations.services.vulnerabilities.mocks.MockSSCRestClient 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 MockSSCRestClient

use of com.hp.octane.integrations.services.vulnerabilities.mocks.MockSSCRestClient 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 MockSSCRestClient

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

the class SSCProjectConnectorPagingTest method pagingOfIssues.

@Test
public void pagingOfIssues() {
    SSCProjectConfiguration configMock = createNiceMock(SSCProjectConfiguration.class);
    expect(configMock.getSSCUrl()).andReturn("DummyURL").anyTimes();
    replay(configMock);
    SSCProjectConnector sscProjectConnector = new SSCProjectConnector(configMock, new MockSSCRestClient(Arrays.asList(DummyContents.issuesPart1, DummyContents.issuesPart2, DummyContents.issuesPart3)));
    Issues issues = sscProjectConnector.readIssues(1);
    Assert.assertEquals(3, issues.getCount());
    Assert.assertEquals("Issue 1", issues.getData().get(0).issueName);
    Assert.assertEquals("Issue 2", issues.getData().get(1).issueName);
    Assert.assertEquals("Issue 3", issues.getData().get(2).issueName);
}
Also used : MockSSCRestClient(com.hp.octane.integrations.services.vulnerabilities.mocks.MockSSCRestClient) Issues(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues) SSCProjectConnector(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCProjectConnector) SSCProjectConfiguration(com.hp.octane.integrations.dto.securityscans.SSCProjectConfiguration) Test(org.junit.Test)

Example 5 with MockSSCRestClient

use of com.hp.octane.integrations.services.vulnerabilities.mocks.MockSSCRestClient 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)

Aggregations

MockSSCRestClient (com.hp.octane.integrations.services.vulnerabilities.mocks.MockSSCRestClient)5 Test (org.junit.Test)5 SSCHandler (com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler)4 Issues (com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues)3 SSCProjectConfiguration (com.hp.octane.integrations.dto.securityscans.SSCProjectConfiguration)1 SSCProjectConnector (com.hp.octane.integrations.services.vulnerabilities.ssc.SSCProjectConnector)1