Added some tests

This commit is contained in:
Šesták Vít
2020-01-23 10:02:26 +01:00
parent 2db75d0617
commit 70984229f0

View File

@@ -10,6 +10,12 @@ class VulnerabilitySpec extends Specification {
VulnerableSoftware(allPreviousVersion = false, "cpe:/a:asd:asd:1.0")
), Seq())
val nonCpeVuln = Vulnerability("some-vuln", None, CvssRating(None, None, None, None, None, None, None), "descr", Seq(
VulnerableSoftware(allPreviousVersion = false, "cpex:/a:ftp:ftp"),
VulnerableSoftware(allPreviousVersion = false, "cpex:/a:ssh:ssh:1.0"),
VulnerableSoftware(allPreviousVersion = false, "cpex:/a:asd:asd:1.0")
), Seq())
def id(name: String) = Identifier(name = name, confidence = Confidence.Highest, url = "", identifierType = "cpe")
@@ -32,6 +38,9 @@ class VulnerabilitySpec extends Specification {
"when it matches without version, but it also matches with version and everything matches" >> {
vuln.likelyMatchesOnlyWithoutVersion(Set(id("cpe:/a:ftp:ftp:1.0"), id("cpe:/a:ssh:ssh:1.0"), id("cpe:/a:asd:asd:1.0"))) should beFalse
}
"for non-CPE identifiers, as they are not supported" >> {
nonCpeVuln.likelyMatchesOnlyWithoutVersion(Set(id("cpe:/a:ftp:ftp:1.0"))) should beFalse
}
}
// TODO: Add tests for version matching; They would not pass now, though.
}