Skip to content

Commit

Permalink
feat: delete application (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
JordenReuter authored Nov 11, 2024
1 parent defa1e2 commit b4dc5c9
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down
25 changes: 25 additions & 0 deletions src/main/openapi/openapi-bff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}

0 comments on commit b4dc5c9

Please sign in to comment.