Fixing NPE when querying resources by type

Closes #11137
This commit is contained in:
Pedro Igor 2022-04-06 07:37:21 -03:00
parent 5d271c1634
commit b4770c30fd
2 changed files with 16 additions and 1 deletions

View file

@ -126,7 +126,7 @@ public interface PolicyStore {
default List<Policy> findByResourceType(ResourceServer resourceServer, String resourceType) { default List<Policy> findByResourceType(ResourceServer resourceServer, String resourceType) {
List<Policy> result = new LinkedList<>(); List<Policy> result = new LinkedList<>();
findByResourceType((ResourceServer) null, resourceType, result::add); findByResourceType(resourceServer, resourceType, result::add);
return result; return result;
} }

View file

@ -70,6 +70,21 @@ public class ResourceManagementTest extends AbstractAuthorizationTest {
assertEquals(1, attributes.get("b").size()); 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 @Test
public void failCreateWithSameName() { public void failCreateWithSameName() {
ResourceRepresentation newResource = createResource(); ResourceRepresentation newResource = createResource();