use of org.hisp.dhis.user.sharing.Sharing in project dhis2-core by dhis2.
the class SharingTest method withAccessKeepsExternal.
@Test
void withAccessKeepsExternal() {
Sharing original = new Sharing();
original.setExternal(true);
assertTrue(original.withAccess(Sharing::copyMetadataToData).isExternal());
}
use of org.hisp.dhis.user.sharing.Sharing in project dhis2-core by dhis2.
the class SharingTest method withAccessKeepsOwner.
@Test
void withAccessKeepsOwner() {
Sharing original = new Sharing();
original.setOwner("userid");
assertEquals("userid", original.withAccess(Sharing::copyMetadataToData).getOwner());
}
use of org.hisp.dhis.user.sharing.Sharing in project dhis2-core by dhis2.
the class SharingTest method addUserGroupAccessCreatesMapWhenNeeded.
@Test
void addUserGroupAccessCreatesMapWhenNeeded() {
Sharing actual = new Sharing();
actual.addUserGroupAccess(new UserGroupAccess("rw------", "uid"));
assertEquals(1, actual.getUserGroups().size());
}
use of org.hisp.dhis.user.sharing.Sharing in project dhis2-core by dhis2.
the class DashboardCascadeSharingTest method testCascadeShareEventVisualizationError.
@Test
void testCascadeShareEventVisualizationError() {
DataElement dataElementA = createDataElement('A');
dataElementA.setSharing(Sharing.builder().publicAccess(DEFAULT).build());
objectManager.save(dataElementA, false);
Program program = createProgram('Y', null, null);
objectManager.save(program);
EventVisualization eventVisualizationA = createEventVisualization('A', program);
eventVisualizationA.setSharing(Sharing.builder().publicAccess(DEFAULT).build());
eventVisualizationA.addDataDimensionItem(dataElementA);
objectManager.save(eventVisualizationA, false);
Sharing sharing = new Sharing();
sharing.setPublicAccess(DEFAULT);
sharing.addUserAccess(new UserAccess(userB, DEFAULT));
Dashboard dashboard = createDashboardWithItem("A", sharing);
dashboard.getItems().get(0).setEventVisualization(eventVisualizationA);
objectManager.save(dashboard, false);
CascadeSharingReport report = cascadeSharingService.cascadeSharing(dashboard, new CascadeSharingParameters());
assertEquals(0, report.getUpdateObjects().size());
assertFalse(aclService.canRead(userB, eventVisualizationA));
assertFalse(aclService.canRead(userB, dataElementA));
}
use of org.hisp.dhis.user.sharing.Sharing in project dhis2-core by dhis2.
the class DashboardCascadeSharingTest method testCascadeShareVisualizationError.
@Test
void testCascadeShareVisualizationError() {
DataElement dataElementA = createDataElement('A');
dataElementA.setSharing(Sharing.builder().publicAccess(DEFAULT).build());
objectManager.save(dataElementA, false);
Visualization vzA = createVisualization('A');
vzA.setSharing(Sharing.builder().publicAccess(DEFAULT).build());
vzA.addDataDimensionItem(dataElementA);
objectManager.save(vzA, false);
Sharing sharing = new Sharing();
sharing.setPublicAccess(DEFAULT);
sharing.addUserAccess(new UserAccess(userB, DEFAULT));
Dashboard dashboard = createDashboardWithItem("A", sharing);
dashboard.getItems().get(0).setVisualization(vzA);
objectManager.save(dashboard, false);
CascadeSharingReport report = cascadeSharingService.cascadeSharing(dashboard, new CascadeSharingParameters());
assertEquals(0, report.getUpdateObjects().size());
assertFalse(aclService.canRead(userB, vzA));
assertFalse(aclService.canRead(userB, dataElementA));
}
Aggregations