Skip to content

Commit

Permalink
refactor(clients)!: Rename OSV classes according to ORT conventions
Browse files Browse the repository at this point in the history
OSV currently is the only client library project that provides another
"wrapper" around the low-level service API. Use "ServiceWrapper" as a
conventional suffix for that class.

Reword some docs / rename some variables accordingly along the way.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Jun 18, 2024
1 parent 19d0e9f commit ae9d0d3
Show file tree
Hide file tree
Showing 6 changed files with 255 additions and 255 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,25 @@ private val emptyJsonObject = JsonObject(emptyMap())

private fun List<Vulnerability>.patchFields() = map { it.patchIgnorableFields().normalizeUrls() }

class OsvServiceFunTest : StringSpec({
class OsvServiceWrapperFunTest : StringSpec({

Check warning on line 65 in clients/osv/src/funTest/kotlin/OsvServiceWrapperFunTest.kt

View workflow job for this annotation

GitHub Actions / qodana-scan

Unused symbol

Class "OsvServiceWrapperFunTest" is never used
"getVulnerabilitiesForPackage() returns the expected vulnerability when queried by commit" {
val expectedResult = getAssetAsString("vulnerabilities-by-commit-expected-result.json")

val result = OsvService().getVulnerabilitiesForPackage(VULNERABILITY_FOR_PACKAGE_BY_COMMIT_REQUEST)
val result = OsvServiceWrapper().getVulnerabilitiesForPackage(VULNERABILITY_FOR_PACKAGE_BY_COMMIT_REQUEST)

result.shouldBeSuccess { actualData ->
val expectedData = OsvApiClient.JSON.decodeFromString<List<Vulnerability>>(expectedResult)
val expectedData = OsvService.JSON.decodeFromString<List<Vulnerability>>(expectedResult)
actualData.patchFields() shouldContainExactlyInAnyOrder expectedData.patchFields()
}
}

"getVulnerabilitiesForPackage() returns the expected vulnerability when queried by name and version" {
val expectedResult = getAssetAsString("vulnerabilities-by-name-and-version-expected-result.json")

val result = OsvService().getVulnerabilitiesForPackage(VULNERABILITY_FOR_PACKAGE_BY_NAME_AND_VERSION)
val result = OsvServiceWrapper().getVulnerabilitiesForPackage(VULNERABILITY_FOR_PACKAGE_BY_NAME_AND_VERSION)

result.shouldBeSuccess { actualData ->
val expectedData = OsvApiClient.JSON.decodeFromString<List<Vulnerability>>(expectedResult)
val expectedData = OsvService.JSON.decodeFromString<List<Vulnerability>>(expectedResult)
actualData.patchFields() shouldContainExactlyInAnyOrder expectedData.patchFields()
}
}
Expand All @@ -92,7 +92,7 @@ class OsvServiceFunTest : StringSpec({
VULNERABILITY_FOR_PACKAGE_BY_NAME_AND_VERSION
)

val result = OsvService().getVulnerabilityIdsForPackages(requests)
val result = OsvServiceWrapper().getVulnerabilityIdsForPackages(requests)

result.shouldBeSuccess {
it shouldBe listOf(
Expand Down Expand Up @@ -124,18 +124,18 @@ class OsvServiceFunTest : StringSpec({
"getVulnerabilityForId() returns the expected vulnerability for the given ID" {
val expectedResult = getAssetAsString("vulnerability-by-id-expected-result.json")

val result = OsvService().getVulnerabilityForId("GHSA-xvch-5gv4-984h")
val result = OsvServiceWrapper().getVulnerabilityForId("GHSA-xvch-5gv4-984h")

result.shouldBeSuccess { actualData ->
val expectedData = OsvApiClient.JSON.decodeFromString<Vulnerability>(expectedResult)
val expectedData = OsvService.JSON.decodeFromString<Vulnerability>(expectedResult)
actualData.patchIgnorableFields() shouldBe expectedData.patchIgnorableFields()
}
}

"getVulnerabilitiesForIds() return the vulnerabilities for the given IDs" {
val ids = setOf("GHSA-xvch-5gv4-984h", "PYSEC-2014-82")

val result = OsvService().getVulnerabilitiesForIds(ids)
val result = OsvServiceWrapper().getVulnerabilitiesForIds(ids)

result.shouldBeSuccess {
it.map { vulnerability -> vulnerability.id } shouldContainExactlyInAnyOrder ids
Expand Down
154 changes: 0 additions & 154 deletions clients/osv/src/main/kotlin/OsvApiClient.kt

This file was deleted.

Loading

0 comments on commit ae9d0d3

Please sign in to comment.