From b4dc5c96d94337f26e40357b2083f3daca0ebb70 Mon Sep 17 00:00:00 2001 From: JordenReuter <149687553+JordenReuter@users.noreply.github.com> Date: Mon, 11 Nov 2024 09:41:33 +0100 Subject: [PATCH] feat: delete application (#87) --- .../onecx-permission-bff-extensions.adoc | 6 ++--- .../ApplicationRestController.java | 7 ++++++ src/main/openapi/openapi-bff.yaml | 25 +++++++++++++++++++ .../rs/ApplicationRestControllerTest.java | 24 ++++++++++++++++-- 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/docs/modules/onecx-permission-bff/pages/onecx-permission-bff-extensions.adoc b/docs/modules/onecx-permission-bff/pages/onecx-permission-bff-extensions.adoc index 31d9ec7..fc5b59c 100644 --- a/docs/modules/onecx-permission-bff/pages/onecx-permission-bff-extensions.adoc +++ b/docs/modules/onecx-permission-bff/pages/onecx-permission-bff-extensions.adoc @@ -89,8 +89,8 @@ h| Version | onecx-permissions | https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-permissions.html[Link] -| https://github.com/onecx/onecx-quarkus/blob/0.33.0/docs/modules/onecx-quarkus/pages/includes/onecx-permissions.adoc[Link] -| 0.33.0 +| https://github.com/onecx/onecx-quarkus/blob/0.34.0/docs/modules/onecx-quarkus/pages/includes/onecx-permissions.adoc[Link] +| 0.34.0 | quarkus-oidc @@ -102,7 +102,7 @@ h| Version | https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-core.html[Link] | -| 0.33.0 +| 0.34.0 | quarkus-micrometer-registry-prometheus diff --git a/src/main/java/org/tkit/onecx/permission/bff/rs/controllers/ApplicationRestController.java b/src/main/java/org/tkit/onecx/permission/bff/rs/controllers/ApplicationRestController.java index a052bbd..e00c664 100644 --- a/src/main/java/org/tkit/onecx/permission/bff/rs/controllers/ApplicationRestController.java +++ b/src/main/java/org/tkit/onecx/permission/bff/rs/controllers/ApplicationRestController.java @@ -29,6 +29,13 @@ public class ApplicationRestController implements ApplicationApiService { @Inject ApplicationMapper mapper; + @Override + public Response deleteByApplicationName(String name) { + try (Response response = applicationClient.deleteByApplicationName(name)) { + return Response.status(response.getStatus()).build(); + } + } + @Override public Response searchApplications(ApplicationSearchCriteriaDTO applicationSearchCriteriaDTO) { try (Response response = applicationClient.searchApplications(mapper.map(applicationSearchCriteriaDTO))) { diff --git a/src/main/openapi/openapi-bff.yaml b/src/main/openapi/openapi-bff.yaml index bc8eb69..21793be 100644 --- a/src/main/openapi/openapi-bff.yaml +++ b/src/main/openapi/openapi-bff.yaml @@ -690,6 +690,31 @@ paths: application/json: schema: $ref: '#/components/schemas/ProblemDetailResponse' + /applications/{name}: + delete: + x-onecx: + permissions: + application: + - delete + tags: + - application + description: delete application by name + operationId: deleteByApplicationName + parameters: + - name: name + in: path + required: true + schema: + type: string + responses: + 204: + description: Application deleted + 400: + description: Bad request + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetailResponse' /workspaces/search: post: x-onecx: diff --git a/src/test/java/org/tkit/onecx/permission/rs/ApplicationRestControllerTest.java b/src/test/java/org/tkit/onecx/permission/rs/ApplicationRestControllerTest.java index 7ff6c39..7aff3e8 100644 --- a/src/test/java/org/tkit/onecx/permission/rs/ApplicationRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/permission/rs/ApplicationRestControllerTest.java @@ -60,7 +60,7 @@ void searchApplicationByCriteriaTest() { .header(APM_HEADER_PARAM, ADMIN) .contentType(APPLICATION_JSON) .body(criteriaDTO) - .post() + .post("/search") .then() .statusCode(Response.Status.OK.getStatusCode()) .contentType(APPLICATION_JSON) @@ -95,10 +95,30 @@ void searchApplicationsByEmptyCriteriaTest() { .header(APM_HEADER_PARAM, ADMIN) .contentType(APPLICATION_JSON) .body(criteriaDTO) - .post() + .post("/search") .then() .statusCode(Response.Status.BAD_REQUEST.getStatusCode()); mockServerClient.clear(MOCKID); } + + @Test + void deleteApplicationByName() { + + // create mock rest endpoint + mockServerClient.when(request().withPath("/internal/applications/testApp").withMethod(HttpMethod.DELETE)).withId(MOCKID) + .respond(httpRequest -> response().withStatusCode(Response.Status.NO_CONTENT.getStatusCode())); + + given() + .when() + .auth().oauth2(keycloakClient.getAccessToken(ADMIN)) + .header(APM_HEADER_PARAM, ADMIN) + .contentType(APPLICATION_JSON) + .pathParam("name", "testApp") + .delete("/{name}") + .then() + .statusCode(Response.Status.NO_CONTENT.getStatusCode()); + + mockServerClient.clear(MOCKID); + } }