Skip to content

Commit

Permalink
Add check for Role and Unit Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Amoncy committed Oct 15, 2023
1 parent 5cba304 commit 0aee18e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import static io.apicurio.registry.util.DtoUtil.appAuthPropertyToRegistry;
import static io.apicurio.registry.util.DtoUtil.registryAuthPropertyToApp;


/**
* @author [email protected]
*/
Expand Down Expand Up @@ -338,8 +339,7 @@ public RoleMapping getRoleMapping(String principalId) {
@RoleBasedAccessApiOperation
public void updateRoleMapping(String principalId, UpdateRole data) {
requireParameter("principalId", principalId);
requireParameter("roleName", data.getRole().name());

requireParameter("role", data.getRole());
storage.updateRoleMapping(principalId, data.getRole().name());
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/test/java/io/apicurio/registry/rbac/AdminResourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,16 @@ public void testRoleMappings() throws Exception {
.body("error_code", equalTo(404))
.body("message", equalTo("No mapping for principal 'UnknownPrincipal' and role 'READ_ONLY' was found."));

//Update a mapping with null RoleType
update.setRole(null);
given()
.when()
.contentType(CT_JSON)
.body(update)
.put("/registry/v2/admin/roleMappings/TestUser")
.then()
.statusCode(400);

// Delete a role mapping
given()
.when()
Expand Down

0 comments on commit 0aee18e

Please sign in to comment.