use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.STATUS in project dhis2-core by dhis2.
the class EventSecurityTest method testAddEventSimpleUserFullAccess5.
/**
* program = DATA READ programStage = DATA READ orgUnit = Accessible status
* = SUCCESS
*/
@Test
void testAddEventSimpleUserFullAccess5() {
programA.setPublicAccess(AccessStringHelper.DATA_READ_WRITE);
programStageA.setPublicAccess(AccessStringHelper.DATA_READ_WRITE);
manager.update(programA);
manager.update(programStageA);
Event event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid());
ImportSummary importSummary = eventService.addEvent(event, ImportOptions.getDefaultImportOptions(), false);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
assertEquals(event.getEvent(), importSummary.getReference());
programA.setPublicAccess(AccessStringHelper.DATA_READ);
programStageA.setPublicAccess(AccessStringHelper.DATA_READ);
manager.update(programA);
manager.update(programStageA);
User user = createUser("user1").setOrganisationUnits(Sets.newHashSet(organisationUnitA));
injectSecurityContext(user);
assertTrue(programStageInstanceService.programStageInstanceExists(event.getEvent()));
ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance(event.getUid());
assertNotNull(programStageInstance);
Event eventFromPsi = eventService.getEvent(programStageInstance);
assertNotNull(eventFromPsi);
assertEquals(event.getUid(), eventFromPsi.getEvent());
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.STATUS in project dhis2-core by dhis2.
the class EventSecurityTest method testAddEventSimpleUserFullAccess6.
/**
* program = DATA WRITE programStage = DATA WRITE orgUnit = Accessible
* status = SUCCESS
*/
@Test
void testAddEventSimpleUserFullAccess6() {
programA.setPublicAccess(AccessStringHelper.DATA_READ_WRITE);
programStageA.setPublicAccess(AccessStringHelper.DATA_READ_WRITE);
manager.update(programA);
manager.update(programStageA);
Event event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid());
ImportSummary importSummary = eventService.addEvent(event, ImportOptions.getDefaultImportOptions(), false);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
assertEquals(event.getEvent(), importSummary.getReference());
programA.setPublicAccess(AccessStringHelper.DATA_WRITE);
programStageA.setPublicAccess(AccessStringHelper.DATA_WRITE);
manager.update(programA);
manager.update(programStageA);
User user = createUser("user1").setOrganisationUnits(Sets.newHashSet(organisationUnitA));
injectSecurityContext(user);
assertTrue(programStageInstanceService.programStageInstanceExists(event.getEvent()));
ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance(event.getUid());
assertNotNull(programStageInstance);
Event eventFromPsi = eventService.getEvent(programStageInstance);
assertNotNull(eventFromPsi);
assertEquals(event.getUid(), eventFromPsi.getEvent());
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.STATUS in project dhis2-core by dhis2.
the class EventSecurityTest method testAddEventSimpleUserFullAccess9.
/**
* program = programStage = DATA READ orgUnit = Accessible status = ERROR
*/
@Test
void testAddEventSimpleUserFullAccess9() {
programA.setPublicAccess(AccessStringHelper.DATA_READ_WRITE);
programStageA.setPublicAccess(AccessStringHelper.DATA_READ_WRITE);
manager.update(programA);
manager.update(programStageA);
Event event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid());
ImportSummary importSummary = eventService.addEvent(event, ImportOptions.getDefaultImportOptions(), false);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
assertEquals(event.getEvent(), importSummary.getReference());
programA.setPublicAccess(AccessStringHelper.DEFAULT);
programStageA.setPublicAccess(AccessStringHelper.DATA_READ);
manager.update(programA);
manager.update(programStageA);
User user = createUser("user1").setOrganisationUnits(Sets.newHashSet(organisationUnitA));
injectSecurityContext(user);
assertTrue(programStageInstanceService.programStageInstanceExists(event.getEvent()));
ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance(event.getUid());
assertNotNull(programStageInstance);
assertThrows(IllegalQueryException.class, () -> eventService.getEvent(programStageInstance));
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.STATUS in project dhis2-core by dhis2.
the class EventSecurityTest method testAddEventSimpleUserFullAccess7.
/**
* program = DATA WRITE programStage = DATA WRITE orgUnit = Not Accessible
* status = ERROR
*/
@Test
void testAddEventSimpleUserFullAccess7() {
programA.setPublicAccess(AccessStringHelper.DATA_READ_WRITE);
programStageA.setPublicAccess(AccessStringHelper.DATA_READ_WRITE);
manager.update(programA);
manager.update(programStageA);
Event event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid());
ImportSummary importSummary = eventService.addEvent(event, ImportOptions.getDefaultImportOptions(), false);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
assertEquals(event.getEvent(), importSummary.getReference());
programA.setPublicAccess(AccessStringHelper.DATA_WRITE);
programStageA.setPublicAccess(AccessStringHelper.DATA_WRITE);
manager.update(programA);
manager.update(programStageA);
User user = createUser("user1");
injectSecurityContext(user);
assertTrue(programStageInstanceService.programStageInstanceExists(event.getEvent()));
ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance(event.getUid());
assertNotNull(programStageInstance);
assertThrows(IllegalQueryException.class, () -> eventService.getEvent(programStageInstance));
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.STATUS in project dhis2-core by dhis2.
the class EventSecurityTest method testAddEventSimpleUserFullAccess2.
/**
* program = DATA READ programStage = DATA READ/WRITE orgUnit = Accessible
* status = ERROR
*/
@Test
void testAddEventSimpleUserFullAccess2() {
programA.setPublicAccess(AccessStringHelper.DATA_READ);
programStageA.setPublicAccess(AccessStringHelper.DATA_READ_WRITE);
manager.update(programA);
manager.update(programStageA);
User user = createUser("user1").setOrganisationUnits(Sets.newHashSet(organisationUnitA));
injectSecurityContext(user);
Event event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid());
ImportSummary importSummary = eventService.addEvent(event, ImportOptions.getDefaultImportOptions(), false);
assertEquals(ImportStatus.ERROR, importSummary.getStatus());
}
Aggregations