use of com.checkmarx.flow.cucumber.common.JsonLoggerTestUtils in project cx-flow by checkmarx-ltd.
the class ScanSteps method verifyJsonLoggerAndScanStatus.
@And("output json logger will have Scan request {string} and scan status will be {string}")
public void verifyJsonLoggerAndScanStatus(String repoUrl, String scanStatus) {
JsonLoggerTestUtils testUtils = new JsonLoggerTestUtils();
JsonNode node;
try {
// AnalyticsReport report = testUtils.getReportNode(ScanReport.OPERATION, ScanReport.class);
node = testUtils.getReportNode(ScanReport.OPERATION);
if (this.repoType.equals(ScanRequest.Repository.GITHUB)) {
assertEquals((ScanRequest.Repository.GITHUB.toString()), node.get("repoType").textValue());
assertEquals(this.branch, node.get("branch").textValue());
assertEquals(repoUrl, AesEncryptionUtils.decrypt(node.get("repoUrl").textValue().trim()));
} else {
assertEquals("NA", node.get("repoType").textValue());
if (!errorExpected) {
assertEquals(fileRepo.getPath(), AesEncryptionUtils.decrypt(node.get("repoUrl").textValue().trim()));
}
}
assertTrue(node.get("scanStatus").get("message").textValue().startsWith(scanStatus));
assertEquals(cxProperties.getIncremental() ? "Inc" : "Full", node.get("scanType").textValue());
if (!errorExpected) {
assertNotEquals("NA", node.get("scanId").textValue());
}
} catch (IOException | CheckmarxException e) {
fail(e.getMessage());
} finally {
try {
testUtils.clearLogContents();
errorExpected = false;
} catch (Exception e) {
fail(e.getMessage());
}
}
}
use of com.checkmarx.flow.cucumber.common.JsonLoggerTestUtils in project cx-flow by checkmarx-ltd.
the class SCARemoteRepoScanSteps method getReportObject.
private ScanReport getReportObject() throws CheckmarxException, JsonProcessingException {
JsonLoggerTestUtils utils = new JsonLoggerTestUtils();
String lastLine = utils.getLastLine();
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(lastLine).get(ScanReport.OPERATION);
if (jsonNode != null) {
return (ScanReport) utils.getAnalyticsReport(ScanReport.class, objectMapper, jsonNode);
} else {
return null;
}
}
Aggregations