Skip to content

Commit

Permalink
Add null checks on role mapping (Apicurio#3800)
Browse files Browse the repository at this point in the history
* Add null checks on  role mapping

* Add check for Role and Unit Test

Fix integration tests workflow
  • Loading branch information
Amoncy authored and carlesarnal committed Oct 17, 2023
1 parent f346c9e commit 550fd22
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: mvn -N io.takari:maven:wrapper -Dmaven=3.8.2

- name: Build Sql Variant
run: make SKIP_TESTS=true BUILD_FLAGS='-DskipUiBuild=true -Dmaven.javadoc.skip=true --no-transfer-progress -Dmaven.wagon.httpconnectionManager.maxTotal=30 -Dmaven.wagon.http.retryHandler.count=5' build-sql
run: make SKIP_TESTS=true BUILD_FLAGS='-Dmaven.javadoc.skip=true --no-transfer-progress -Dmaven.wagon.httpconnectionManager.maxTotal=30 -Dmaven.wagon.http.retryHandler.count=5' build-sql

- name: Build and Push Sql image
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ public RoleMapping getRoleMapping(String principalId) {
@Authorized(style=AuthorizedStyle.None, level=AuthorizedLevel.Admin)
@RoleBasedAccessApiOperation
public void updateRoleMapping(String principalId, UpdateRole data) {
requireParameter("principalId", principalId);
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 550fd22

Please sign in to comment.