Skip to content

Commit

Permalink
Implement packages list
Browse files Browse the repository at this point in the history
  • Loading branch information
fwilhe committed Sep 3, 2024
1 parent f6e7485 commit 5d09bf0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 101 deletions.
14 changes: 10 additions & 4 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ To use a specific distribution version number, use this endpoint:

include::{snippets}/getCveForDistroByVersion/curl-request.adoc[]

The expected response looks like this:

include::{snippets}/getCveForDistroByVersion/http-response.adoc[]
The expected response is the same as for the previous request.

=== Get a list of CVEs for packages by distro

Expand All @@ -62,4 +60,12 @@ include::{snippets}/getCveForPackagesByDistroVersion/curl-request.adoc[]

The expected response looks like this:

include::{snippets}/getCveForPackagesByDistroVersion/http-response.adoc[]
include::{snippets}/getCveForPackagesByDistroVersion/http-response.adoc[]

== Get List of Packages

include::{snippets}/getPackages/curl-request.adoc[]

The expected response looks like this:

include::{snippets}/getPackages/http-response.adoc[]
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/glvd
spring.datasource.username=glvd
spring.datasource.password=glvd
spring.sql.init.mode=never
jakarta.persistence.query.timeout=5000
jakarta.persistence.query.timeout=7000
21 changes: 16 additions & 5 deletions src/test/java/io/gardenlinux/glvd/GlvdControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class GlvdControllerTest {

@Container
@ServiceConnection
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>(glvdPostgresImage).withDatabaseName("glvd")
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>(glvdPostgresImage)
.withDatabaseName("glvd")
.withUsername("glvd").withPassword("glvd");

@Autowired
Expand Down Expand Up @@ -100,7 +101,7 @@ public void shouldReturnCvesForBookworm() {
.filter(document("getCveForDistro",
preprocessRequest(modifyUris().scheme("https").host("glvd.gardenlinux.io").removePort()),
preprocessResponse(prettyPrint())))
.when().port(this.port).get("/v1/cves/debian_linux/bookworm")
.when().port(this.port).get("/v1/cves/gardenlinux/1592")
.then().statusCode(HttpStatus.SC_OK);
}

Expand All @@ -110,7 +111,7 @@ public void shouldReturnCvesForBookwormByVersion() {
.filter(document("getCveForDistroByVersion",
preprocessRequest(modifyUris().scheme("https").host("glvd.gardenlinux.io").removePort()),
preprocessResponse(prettyPrint())))
.when().port(this.port).get("/v1/cves/debian_linux/version/12")
.when().port(this.port).get("/v1/cves/gardenlinux/version/1592.0")
.then().statusCode(HttpStatus.SC_OK);
}

Expand All @@ -120,7 +121,7 @@ public void shouldReturnCvesForListOfPackages() {
.filter(document("getCveForPackages",
preprocessRequest(modifyUris().scheme("https").host("glvd.gardenlinux.io").removePort()),
preprocessResponse(prettyPrint())))
.when().port(this.port).get("/v1/cves/debian_linux/bookworm/packages/dav1d,firefox-esr")
.when().port(this.port).get("/v1/cves/gardenlinux/1592/packages/crun,vim")
.then().statusCode(HttpStatus.SC_OK);
}

Expand All @@ -130,7 +131,7 @@ public void shouldReturnCvesForListOfPackagesByDistroVersion() {
.filter(document("getCveForPackagesByDistroVersion",
preprocessRequest(modifyUris().scheme("https").host("glvd.gardenlinux.io").removePort()),
preprocessResponse(prettyPrint())))
.when().port(this.port).get("/v1/cves/debian_linux/version/12/packages/dav1d,firefox-esr")
.when().port(this.port).get("/v1/cves/gardenlinux/version/1592.0/packages/crun,vim")
.then().statusCode(HttpStatus.SC_OK);
}

Expand All @@ -144,4 +145,14 @@ public void shouldBeReady() {
.then().statusCode(HttpStatus.SC_OK).body("dbCheck", containsString("true"));
}

@Test
public void shouldGetPackagesForDistro() {
given(this.spec).accept("application/json")
.filter(document("getPackages",
preprocessRequest(modifyUris().scheme("https").host("glvd.gardenlinux.io").removePort()),
preprocessResponse(prettyPrint())))
.when().port(this.port).get("/v1/packages/1592.0")
.then().statusCode(200);
}

}
91 changes: 0 additions & 91 deletions src/test/java/io/gardenlinux/glvd/PackageControllerTest.java

This file was deleted.

0 comments on commit 5d09bf0

Please sign in to comment.