@Test public void hasPermissionResource_noMembership() { DefaultUser user = new DefaultUser("user"); user.setId(USER_ID); when(groupService.findByMember(user.getId())).thenReturn(Single.just(emptyList())); when(membershipService.findByCriteria(eq(ReferenceType.ORGANIZATION), eq(ORGANIZATION_ID), any(MembershipCriteria.class))).thenReturn(Flowable.empty()); TestObserver<Boolean> obs = cut.hasPermission(user, of(ReferenceType.ORGANIZATION, ORGANIZATION_ID, Permission.ORGANIZATION, READ)) .test(); obs.awaitTerminalEvent(); obs.assertComplete(); obs.assertValue(false); }
public Single<Boolean> hasPermission(User user, PermissionAcls permissions) { return findMembershipPermissions(user, permissions.referenceStream()) .map(permissions::match); }
PermissionService { public Single<Boolean> hasPermission(User user, PermissionAcls permissions) { return findMembershipPermissions(user, permissions.referenceStream()) .map(permissions::match); } }
PermissionService { public Single<Boolean> hasPermission(User user, PermissionAcls permissions) { return findMembershipPermissions(user, permissions.referenceStream()) .map(permissions::match); } PermissionService(MembershipService membershipService,
                             GroupService groupService,
                             RoleService roleService); }
PermissionService { public Single<Boolean> hasPermission(User user, PermissionAcls permissions) { return findMembershipPermissions(user, permissions.referenceStream()) .map(permissions::match); } PermissionService(MembershipService membershipService,
                             GroupService groupService,
                             RoleService roleService); Single<Map<Permission, Set<Acl>>> findAllPermissions(User user, ReferenceType referenceType, String referenceId); Single<Boolean> hasPermission(User user, PermissionAcls permissions); }
PermissionService { public Single<Boolean> hasPermission(User user, PermissionAcls permissions) { return findMembershipPermissions(user, permissions.referenceStream()) .map(permissions::match); } PermissionService(MembershipService membershipService,
                             GroupService groupService,
                             RoleService roleService); Single<Map<Permission, Set<Acl>>> findAllPermissions(User user, ReferenceType referenceType, String referenceId); Single<Boolean> hasPermission(User user, PermissionAcls permissions);  }