Skip to content

Commit

Permalink
restructure tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jwigert committed Oct 19, 2023
1 parent 41776ed commit ded7287
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 46 deletions.
30 changes: 30 additions & 0 deletions src/test/java/edu/hm/hafner/analysis/parser/GrypeParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import edu.hm.hafner.analysis.Report;
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.analysis.assertions.SoftAssertions;
import org.junit.jupiter.api.Test;
import static j2html.TagCreator.a;
import static j2html.TagCreator.p;

Expand Down Expand Up @@ -40,6 +41,35 @@ protected void assertThatIssuesArePresent(final Report report, final SoftAsserti
.withText("https://nvd.nist.gov/vuln/detail/CVE-2016-8745")).render());
}

@Test
void assertThatVulnerabilityWithoutDescriptionCanBeParsed() {
var fileWithIssues = "grype-report-wo-description.json";
var report = super.parse(fileWithIssues);

try (var softly = new SoftAssertions()) {
softly.assertThat(report).hasSize(20).hasDuplicatesSize(13);
softly.assertThat(report.get(0))
.hasFileName("/usr/local/bin/environment-to-ini")
.hasSeverity(Severity.ERROR)
.hasCategory("Critical")
.hasType("GHSA-pg38-r834-g45j")
.hasMessage("Improper Privilege Management in Gitea")
.hasDescription(p().with(a()
.withHref("https://github.com/advisories/GHSA-pg38-r834-g45j")
.withText("https://github.com/advisories/GHSA-pg38-r834-g45j")).render());

softly.assertThat(report.get(13))
.hasFileName("/lib/apk/db/installed")
.hasSeverity(Severity.WARNING_HIGH)
.hasCategory("High")
.hasType("CVE-2023-38039")
.hasMessage("Unknown")
.hasDescription(p().with(a()
.withHref("http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-38039")
.withText("http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-38039")).render());
}
}

@Override
protected IssueParser createParser() {
return new GrypeParser();
Expand Down

This file was deleted.

0 comments on commit ded7287

Please sign in to comment.