Skip to content

Commit

Permalink
feat: grant and revoke assignment changes (#19)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
jsteenke and HenryT-CG authored Apr 9, 2024
1 parent f6bf91f commit 8d3e95f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
13 changes: 8 additions & 5 deletions src/main/openapi/openapi-bff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,16 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ProblemDetailResponse'
/assignments/product:
/assignments/grant:
post:
x-onecx:
permissions:
assignment:
- write
tags:
- assignment
description: Create new assignments for products
operationId: createProductAssignments
description: Create new assignments by criteria
operationId: grantAssignments
requestBody:
required: true
content:
Expand All @@ -292,7 +292,7 @@ paths:
$ref: '#/components/schemas/CreateProductAssignmentsRequest'
responses:
201:
description: New assignment created
description: New assignments created
400:
description: Bad request
content:
Expand Down Expand Up @@ -714,10 +714,11 @@ components:
type: object
required:
- roleId
- productNames
properties:
roleId:
type: string
appId:
type: string
productNames:
type: array
items:
Expand All @@ -729,6 +730,8 @@ components:
properties:
roleId:
type: string
appId:
type: string
permissionId:
type: string
productNames:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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());
}
Expand Down

0 comments on commit 8d3e95f

Please sign in to comment.