Skip to content

Commit

Permalink
Fixing NPE when querying resources by type
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroigor committed Apr 7, 2022
1 parent 5d271c1 commit b4770c3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ default List<Policy> findByResource(ResourceServer resourceServer, Resource reso
default List<Policy> findByResourceType(ResourceServer resourceServer, String resourceType) {
List<Policy> result = new LinkedList<>();

findByResourceType((ResourceServer) null, resourceType, result::add);
findByResourceType(resourceServer, resourceType, result::add);

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ public void testCreate() {
assertEquals(1, attributes.get("b").size());
}

@Test
public void testCreateWithResourceType() {
ResourceRepresentation newResource = new ResourceRepresentation();

newResource.setName("test");
newResource.setDisplayName("display");
newResource.setType("some-type");

newResource = doCreateResource(newResource);

ResourceResource resource = getClientResource().authorization().resources().resource(newResource.getId());

assertTrue(resource.permissions().isEmpty());
}

@Test
public void failCreateWithSameName() {
ResourceRepresentation newResource = createResource();
Expand Down

0 comments on commit b4770c3

Please sign in to comment.