use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class AclServiceTest method testUserBCanUpdateVisualizationWithoutAuthority.
@Test
void testUserBCanUpdateVisualizationWithoutAuthority() {
User userA = createUser('A');
manager.save(userA);
Visualization visualization = new Visualization();
visualization.setAutoFields();
visualization.setName("FavA");
visualization.setCreatedBy(userA);
visualization.getSharing().setOwner(userA);
visualization.setPublicAccess(AccessStringHelper.DEFAULT);
visualization.setType(VisualizationType.COLUMN);
assertTrue(aclService.canUpdate(userA, visualization));
manager.save(visualization);
User userB = createUser('B');
manager.save(userB);
visualization.getSharing().addUserAccess(new UserAccess(userB, AccessStringHelper.FULL));
manager.update(visualization);
assertTrue(aclService.canUpdate(userB, visualization));
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class AclServiceTest method testUserBCanUpdateVisualizationWithAuthority.
@Test
void testUserBCanUpdateVisualizationWithAuthority() {
User userA = createUser('A');
manager.save(userA);
Visualization visualization = new Visualization();
visualization.setAutoFields();
visualization.setName("FavA");
visualization.setCreatedBy(userA);
visualization.getSharing().setOwner(userA);
visualization.setPublicAccess(AccessStringHelper.DEFAULT);
visualization.setType(VisualizationType.COLUMN);
assertTrue(aclService.canUpdate(userA, visualization));
manager.save(visualization);
UserAuthorityGroup userAuthorityGroup = new UserAuthorityGroup();
userAuthorityGroup.setAutoFields();
userAuthorityGroup.setName("UR");
userAuthorityGroup.getAuthorities().add("F_VISUALIZATION_PUBLIC_ADD");
manager.save(userAuthorityGroup);
User userB = createUser('B');
userB.getUserAuthorityGroups().add(userAuthorityGroup);
manager.save(userB);
visualization.getSharing().addUserAccess(new UserAccess(userB, AccessStringHelper.FULL));
manager.update(visualization);
assertTrue(aclService.canUpdate(userB, visualization));
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class AclServiceTest method testCanUpdatePrivateVisualization.
@Test
void testCanUpdatePrivateVisualization() {
User user = createAdminUser("F_DATAELEMENT_PRIVATE_ADD");
Visualization visualization = new Visualization("Visualization");
visualization.setAutoFields();
visualization.setCreatedBy(user);
visualization.getSharing().setOwner(user);
visualization.setType(VisualizationType.COLUMN);
visualization.setPublicAccess(AccessStringHelper.DEFAULT);
assertTrue(aclService.canUpdate(user, visualization));
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class AclServiceTest method testShouldBlockUpdatesForNoAuthorityUserEvenWithNonPublicObject.
@Test
void testShouldBlockUpdatesForNoAuthorityUserEvenWithNonPublicObject() {
User adminUser = createAndInjectAdminUser();
assertEquals(adminUser, currentUserService.getCurrentUser());
User user1 = createUser("user1A3");
User user2 = createUser("user2A3");
injectSecurityContext(user1);
assertEquals(user1, currentUserService.getCurrentUser());
Visualization visualization = new Visualization();
visualization.setName("RT");
visualization.setCreatedBy(user1);
visualization.getSharing().setOwner(user1);
visualization.setAutoFields();
visualization.setExternalAccess(false);
visualization.setType(VisualizationType.COLUMN);
manager.save(visualization);
visualization.setPublicAccess(AccessStringHelper.DEFAULT);
manager.update(visualization);
injectSecurityContext(user2);
assertEquals(user2, currentUserService.getCurrentUser());
List<ErrorReport> errorReports = aclService.verifySharing(visualization, user2);
assertFalse(errorReports.isEmpty());
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class AclServiceTest method testVerifyVisualizationCantExternalize.
@Test
void testVerifyVisualizationCantExternalize() {
User user = createAdminUser("F_VISUALIZATION_PUBLIC_ADD");
Visualization visualization = new Visualization();
visualization.setAutoFields();
visualization.setPublicAccess(AccessStringHelper.DEFAULT);
visualization.setExternalAccess(true);
visualization.setType(VisualizationType.COLUMN);
assertFalse(aclService.verifySharing(visualization, user).isEmpty());
}
Aggregations