Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: grant and revoke assignment changes #19

Merged
merged 5 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading