Skip to content

Commit

Permalink
fix: removing parsing of the json for the html report
Browse files Browse the repository at this point in the history
Signed-off-by: Olga Lavtar <olavtar@redhat.com>
  • Loading branch information
olavtar committed Jul 2, 2024
1 parent 34abec0 commit 3e2240b
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions src/test/java/com/redhat/exhort/impl/ExhortApiIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,35 +301,12 @@ private static void handleJsonResponse(
private void handleHtmlResponse(String analysisReportHtml) throws JsonProcessingException {
ObjectMapper om = new ObjectMapper();
assertTrue(analysisReportHtml.contains("svg") && analysisReportHtml.contains("html"));
int jsonStart = analysisReportHtml.indexOf("\"report\":");
int jsonEnd = analysisReportHtml.indexOf("}}}}}");
if (jsonEnd == -1) {
jsonEnd = analysisReportHtml.indexOf("}}}}");
}
String embeddedJson = analysisReportHtml.substring(jsonStart + 9, jsonEnd + 5);
JsonNode jsonInHtml = om.readTree(embeddedJson);
JsonNode scannedNode = jsonInHtml.get("scanned");
assertTrue(scannedNode.get("total").asInt(0) > 0);
assertTrue(scannedNode.get("transitive").asInt(0) > 0);
JsonNode status = jsonInHtml.get("providers").get("osv-nvd").get("status");
assertTrue(status.get("code").asInt(0) == 200);
assertTrue(status.get("ok").asBoolean(false));
}

private void handleHtmlResponseForImage(String analysisReportHtml)
throws JsonProcessingException {
ObjectMapper om = new ObjectMapper();
assertTrue(analysisReportHtml.contains("svg") && analysisReportHtml.contains("html"));
int jsonStart = analysisReportHtml.indexOf("\"report\":");
int jsonEnd = analysisReportHtml.indexOf("}}}}}}");
String embeddedJson = analysisReportHtml.substring(jsonStart + 9, jsonEnd + 6);
JsonNode jsonInHtml = om.readTree(embeddedJson);
JsonNode scannedNode = jsonInHtml.findValue("scanned");
assertTrue(scannedNode.get("total").asInt(0) > 0);
assertTrue(scannedNode.get("transitive").asInt(0) >= 0);
JsonNode status = jsonInHtml.findValue("providers").get("osv-nvd").get("status");
assertTrue(status.get("code").asInt(0) == 200);
assertTrue(status.get("ok").asBoolean(false));
}

private void mockMavenDependencyTree(Ecosystem.Type packageManager) throws IOException {
Expand Down

0 comments on commit 3e2240b

Please sign in to comment.