From 8d3e95fb6581db82dbda3874ce3ce437031cc657 Mon Sep 17 00:00:00 2001 From: jsteenke <146953549+jsteenke@users.noreply.github.com> Date: Tue, 9 Apr 2024 12:06:15 +0200 Subject: [PATCH] feat: grant and revoke assignment changes (#19) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add roleId to search * feat: grant and revoke assignment by appId * fix: grant and revoke assignment by appId * fix: openapi fix --------- Co-authored-by: Henry Täschner <129834483+HenryT-CG@users.noreply.github.com> --- .../rs/controllers/AssignmentRestController.java | 4 ++-- src/main/openapi/openapi-bff.yaml | 13 ++++++++----- .../permission/rs/AssignmentRestControllerTest.java | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/tkit/onecx/permission/bff/rs/controllers/AssignmentRestController.java b/src/main/java/org/tkit/onecx/permission/bff/rs/controllers/AssignmentRestController.java index c1f91df..f4fa508 100644 --- a/src/main/java/org/tkit/onecx/permission/bff/rs/controllers/AssignmentRestController.java +++ b/src/main/java/org/tkit/onecx/permission/bff/rs/controllers/AssignmentRestController.java @@ -45,8 +45,8 @@ public Response createAssignment(CreateAssignmentRequestDTO createAssignmentRequ } @Override - public Response createProductAssignments(CreateProductAssignmentsRequestDTO createProductAssignmentsRequestDTO) { - try (Response response = assignmentClient.createProductAssignment(mapper.map(createProductAssignmentsRequestDTO))) { + public Response grantAssignments(CreateProductAssignmentsRequestDTO createProductAssignmentsRequestDTO) { + try (Response response = assignmentClient.grantAssignment(mapper.map(createProductAssignmentsRequestDTO))) { return Response.status(response.getStatus()).build(); } } diff --git a/src/main/openapi/openapi-bff.yaml b/src/main/openapi/openapi-bff.yaml index d9deb1b..28d60d8 100644 --- a/src/main/openapi/openapi-bff.yaml +++ b/src/main/openapi/openapi-bff.yaml @@ -274,7 +274,7 @@ paths: application/json: schema: $ref: '#/components/schemas/ProblemDetailResponse' - /assignments/product: + /assignments/grant: post: x-onecx: permissions: @@ -282,8 +282,8 @@ paths: - write tags: - assignment - description: Create new assignments for products - operationId: createProductAssignments + description: Create new assignments by criteria + operationId: grantAssignments requestBody: required: true content: @@ -292,7 +292,7 @@ paths: $ref: '#/components/schemas/CreateProductAssignmentsRequest' responses: 201: - description: New assignment created + description: New assignments created 400: description: Bad request content: @@ -714,10 +714,11 @@ components: type: object required: - roleId - - productNames properties: roleId: type: string + appId: + type: string productNames: type: array items: @@ -729,6 +730,8 @@ components: properties: roleId: type: string + appId: + type: string permissionId: type: string productNames: diff --git a/src/test/java/org/tkit/onecx/permission/rs/AssignmentRestControllerTest.java b/src/test/java/org/tkit/onecx/permission/rs/AssignmentRestControllerTest.java index ca777c4..595b221 100644 --- a/src/test/java/org/tkit/onecx/permission/rs/AssignmentRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/permission/rs/AssignmentRestControllerTest.java @@ -257,7 +257,7 @@ void createProductAssignmentsTest() { request.setProductNames(List.of("product1")); // create mock rest endpoint - mockServerClient.when(request().withPath("/internal/assignments/product").withMethod(HttpMethod.POST) + mockServerClient.when(request().withPath("/internal/assignments/grant").withMethod(HttpMethod.POST) .withBody(JsonBody.json(request))) .withId(MOCKID) .respond(httpRequest -> response().withStatusCode(Response.Status.CREATED.getStatusCode()) @@ -272,7 +272,7 @@ void createProductAssignmentsTest() { .header(APM_HEADER_PARAM, ADMIN) .contentType(APPLICATION_JSON) .body(requestDTO) - .post("/product") + .post("/grant") .then() .statusCode(Response.Status.CREATED.getStatusCode()); }