diff --git a/api-examples/Get CVEs by Gardenlinux Version Packages.bru b/api-examples/Get CVEs by Gardenlinux Version Packages.bru index 8503675..4c9512a 100644 --- a/api-examples/Get CVEs by Gardenlinux Version Packages.bru +++ b/api-examples/Get CVEs by Gardenlinux Version Packages.bru @@ -5,7 +5,7 @@ meta { } get { - url: http://{{hostname}}:{{port}}/v1/cves/gardenlinux/1592.0/packages/vim,bash,python3,curl + url: {{schema_hostname_port}}/v1/cves/1592.0/packages/vim,bash,python3,curl body: none auth: none } diff --git a/api-examples/Get CVEs by Gardenlinux Version.bru b/api-examples/Get CVEs by Gardenlinux Version.bru index 7ce501c..b74ea47 100644 --- a/api-examples/Get CVEs by Gardenlinux Version.bru +++ b/api-examples/Get CVEs by Gardenlinux Version.bru @@ -5,7 +5,7 @@ meta { } get { - url: http://{{hostname}}:{{port}}/v1/cves/gardenlinux/1592.0?sortBy=cveId + url: {{schema_hostname_port}}/v1/cves/1592.0?sortBy=cveId body: none auth: none } diff --git a/api-examples/Get Packages by Vulnerability.bru b/api-examples/Get Packages by Vulnerability.bru index 9d24dfb..4e0a7d7 100644 --- a/api-examples/Get Packages by Vulnerability.bru +++ b/api-examples/Get Packages by Vulnerability.bru @@ -5,7 +5,7 @@ meta { } get { - url: http://{{hostname}}:{{port}}/v1/packages/distro/gardenlinux/1443.0/CVE-2023-50387 + url: {{schema_hostname_port}}/v1/distro/1443.0/CVE-2023-50387 body: none auth: none } diff --git a/api-examples/Get Vulnerabilities by Package by Version.bru b/api-examples/Get Vulnerabilities by Package by Version.bru index 76c3352..78c315b 100644 --- a/api-examples/Get Vulnerabilities by Package by Version.bru +++ b/api-examples/Get Vulnerabilities by Package by Version.bru @@ -5,7 +5,7 @@ meta { } get { - url: http://{{hostname}}:{{port}}/v1/packages/vim/2:9.1.0496-1+b1 + url: {{schema_hostname_port}}/v1/packages/vim/2:9.1.0496-1+b1 body: none auth: none } diff --git a/api-examples/Get Vulnerabilities by Package.bru b/api-examples/Get Vulnerabilities by Package.bru index 7b00d84..80c2443 100644 --- a/api-examples/Get Vulnerabilities by Package.bru +++ b/api-examples/Get Vulnerabilities by Package.bru @@ -5,7 +5,7 @@ meta { } get { - url: http://{{hostname}}:{{port}}/v1/packages/vim + url: {{schema_hostname_port}}/v1/packages/vim body: none auth: none } diff --git a/api-examples/List Packages in Distro.bru b/api-examples/List Packages in Distro.bru index 70d1429..3ab563a 100644 --- a/api-examples/List Packages in Distro.bru +++ b/api-examples/List Packages in Distro.bru @@ -5,7 +5,7 @@ meta { } get { - url: http://{{hostname}}:{{port}}/v1/packages/distro/gardenlinux/1592.0?sortBy=sourcePackageName&sortOrder=ASC + url: {{schema_hostname_port}}/v1/distro/gardenlinux/1592.0?sortBy=sourcePackageName&sortOrder=ASC body: none auth: none } diff --git a/api-examples/environments/gardener.bru b/api-examples/environments/gardener.bru new file mode 100644 index 0000000..cb4cc60 --- /dev/null +++ b/api-examples/environments/gardener.bru @@ -0,0 +1,3 @@ +vars { + schema_hostname_port: https://glvd.ingress.glvd.gardnlinux.shoot.canary.k8s-hana.ondemand.com +} diff --git a/api-examples/environments/local.bru b/api-examples/environments/local.bru index 40a5cd4..3df4a6e 100644 --- a/api-examples/environments/local.bru +++ b/api-examples/environments/local.bru @@ -1,4 +1,3 @@ vars { - hostname: localhost - port: 8080 + schema_hostname_port: http://localhost:8080 } diff --git a/src/main/java/io/gardenlinux/glvd/GlvdController.java b/src/main/java/io/gardenlinux/glvd/GlvdController.java index 6eb03bc..0bf6f0d 100644 --- a/src/main/java/io/gardenlinux/glvd/GlvdController.java +++ b/src/main/java/io/gardenlinux/glvd/GlvdController.java @@ -20,7 +20,7 @@ public GlvdController(@Nonnull GlvdService glvdService) { this.glvdService = glvdService; } - @GetMapping("/cves/{distro}/{gardenlinuxVersion}") + @GetMapping("/cves/{gardenlinuxVersion}") ResponseEntity> getCveDistro( @PathVariable final String gardenlinuxVersion, @RequestParam(defaultValue = "cveId") final String sortBy, @@ -29,22 +29,13 @@ ResponseEntity> getCveDistro( return ResponseEntity.ok().body(glvdService.getCveForDistribution(gardenlinuxVersion, sortBy, sortOrder)); } - @GetMapping("/cves/{distro}/{gardenlinuxVersion}/packages/{packageList}") + @GetMapping("/cves/{gardenlinuxVersion}/packages/{packageList}") ResponseEntity> getCvePackages( @PathVariable final String gardenlinuxVersion, @PathVariable final String packageList) { var cveForPackages = glvdService.getCveForPackages(gardenlinuxVersion, packageList); return ResponseEntity.ok().body(cveForPackages); } - @GetMapping("/packages/distro/{distro}/{gardenlinuxVersion}") - ResponseEntity> packagesForDistro( - @PathVariable final String gardenlinuxVersion, - @RequestParam(defaultValue = "sourcePackageName") final String sortBy, - @RequestParam(defaultValue = "ASC") final String sortOrder - ) { - return ResponseEntity.ok(glvdService.getPackagesForDistro(gardenlinuxVersion, sortBy, sortOrder)); - } - @GetMapping("/packages/{sourcePackage}") ResponseEntity> packageWithVulnerabilities( @PathVariable final String sourcePackage, @@ -63,7 +54,16 @@ ResponseEntity> packageWithVulnerabilitiesByVersion( return ResponseEntity.ok(glvdService.getPackageWithVulnerabilitiesByVersion(sourcePackage, sourcePackageVersion, sortBy)); } - @GetMapping("/packages/distro/{distro}/{gardenlinuxVersion}/{cveId}") + @GetMapping("/distro/{gardenlinuxVersion}") + ResponseEntity> packagesForDistro( + @PathVariable final String gardenlinuxVersion, + @RequestParam(defaultValue = "sourcePackageName") final String sortBy, + @RequestParam(defaultValue = "ASC") final String sortOrder + ) { + return ResponseEntity.ok(glvdService.getPackagesForDistro(gardenlinuxVersion, sortBy, sortOrder)); + } + + @GetMapping("/distro/{gardenlinuxVersion}/{cveId}") ResponseEntity> packagesByVulnerability( @PathVariable final String gardenlinuxVersion, @PathVariable final String cveId, diff --git a/src/test/java/io/gardenlinux/glvd/GlvdControllerTest.java b/src/test/java/io/gardenlinux/glvd/GlvdControllerTest.java index ec33dd2..24873fe 100644 --- a/src/test/java/io/gardenlinux/glvd/GlvdControllerTest.java +++ b/src/test/java/io/gardenlinux/glvd/GlvdControllerTest.java @@ -79,7 +79,7 @@ public void shouldReturnCvesForGardenlinux() { .filter(document("getCveForDistro", preprocessRequest(modifyUris().scheme("https").host("glvd.gardenlinux.io").removePort()), preprocessResponse(prettyPrint()))) - .when().port(this.port).get("/v1/cves/gardenlinux/1592.0?sortBy=cveId&sortOrder=DESC") + .when().port(this.port).get("/v1/cves/1592.0?sortBy=cveId&sortOrder=DESC") .then().statusCode(HttpStatus.SC_OK); } @@ -89,7 +89,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/gardenlinux/1592.0/packages/crun,vim") + .when().port(this.port).get("/v1/cves/1592.0/packages/crun,vim") .then().statusCode(HttpStatus.SC_OK); } @@ -99,7 +99,7 @@ public void shouldGetPackagesForDistro() { .filter(document("getPackages", preprocessRequest(modifyUris().scheme("https").host("glvd.gardenlinux.io").removePort()), preprocessResponse(prettyPrint()))) - .when().port(this.port).get("/v1/packages/distro/gardenlinux/1592.0") + .when().port(this.port).get("/v1/distro/1592.0") .then().statusCode(200); } @@ -129,7 +129,7 @@ public void shouldGetPackagesByVulnerability() { .filter(document("getPackagesByVulnerability", preprocessRequest(modifyUris().scheme("https").host("glvd.gardenlinux.io").removePort()), preprocessResponse(prettyPrint()))) - .when().port(this.port).get("/v1/packages/distro/gardenlinux/1592.0/CVE-2023-50387") + .when().port(this.port).get("/v1/distro/1592.0/CVE-2023-50387") .then().statusCode(200).body("[0].cveId", equalTo("CVE-2023-50387")); }