use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class DashboardTest method testGetAvailableItemByType.
@Test
void testGetAvailableItemByType() {
Dashboard dashboard = new Dashboard();
DashboardItem diA = new DashboardItem();
DashboardItem diB = new DashboardItem();
DashboardItem diC = new DashboardItem();
diA.setUid("A");
diB.setUid("B");
diC.setUid("C");
diA.setVisualization(new Visualization("A"));
diB.getReports().add(new Report("A", null, null, new Visualization()));
diB.getReports().add(new Report("B", null, null, new Visualization()));
diC.getResources().add(new Document("A", null, false, null));
diC.getResources().add(new Document("B", null, false, null));
diC.getResources().add(new Document("C", null, false, null));
dashboard.getItems().add(diA);
dashboard.getItems().add(diB);
dashboard.getItems().add(diC);
assertEquals(diB, dashboard.getAvailableItemByType(DashboardItemType.REPORTS));
assertEquals(diC, dashboard.getAvailableItemByType(DashboardItemType.RESOURCES));
assertNull(dashboard.getAvailableItemByType(DashboardItemType.MAP));
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class AclServiceTest method testNotShouldBlockAdminUpdatesForNoAuthorityUserEvenWithNonPublicObject.
@Test
void testNotShouldBlockAdminUpdatesForNoAuthorityUserEvenWithNonPublicObject() {
User adminUser = createAndInjectAdminUser();
assertEquals(adminUser, currentUserService.getCurrentUser());
User user1 = createUser("user1A4");
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(adminUser);
assertEquals(adminUser, currentUserService.getCurrentUser());
List<ErrorReport> errorReports = aclService.verifySharing(visualization, adminUser);
assertTrue(errorReports.isEmpty());
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class AclServiceTest method testUserBCanUpdateVisualizationWithAuthorityNoUserAccess.
@Test
void testUserBCanUpdateVisualizationWithAuthorityNoUserAccess() {
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);
manager.update(visualization);
assertFalse(aclService.canUpdate(userB, visualization));
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class AclServiceTest method testShouldBlockUpdatesForNoAuthorityUser.
@Test
void testShouldBlockUpdatesForNoAuthorityUser() {
User adminUser = createAndInjectAdminUser();
assertEquals(adminUser, currentUserService.getCurrentUser());
User userNoAuthorities = createUser("user1A2");
manager.save(userNoAuthorities);
Visualization visualization = new Visualization();
visualization.setName("RT");
visualization.setCreatedBy(adminUser);
visualization.getSharing().setOwner(adminUser);
visualization.setAutoFields();
visualization.setPublicAccess(AccessStringHelper.READ);
visualization.setExternalAccess(true);
visualization.setType(VisualizationType.COLUMN);
manager.save(visualization);
injectSecurityContext(userNoAuthorities);
assertEquals(userNoAuthorities, currentUserService.getCurrentUser());
List<ErrorReport> errorReports = aclService.verifySharing(visualization, userNoAuthorities);
assertFalse(errorReports.isEmpty());
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class AclServiceTest method testResetSharingPropsPrivate.
@Test
void testResetSharingPropsPrivate() {
User user = createAdminUser();
Visualization visualization = new Visualization();
visualization.setAutoFields();
visualization.setPublicAccess(AccessStringHelper.DEFAULT);
visualization.setExternalAccess(true);
visualization.setType(VisualizationType.COLUMN);
assertFalse(aclService.verifySharing(visualization, user).isEmpty());
aclService.resetSharing(visualization, user);
assertTrue(AccessStringHelper.DEFAULT.equals(visualization.getPublicAccess()));
assertFalse(visualization.getExternalAccess());
assertTrue(visualization.getUserAccesses().isEmpty());
assertTrue(visualization.getUserGroupAccesses().isEmpty());
}
Aggregations