Skip to content

Commit

Permalink
fix: Minor refactor after PR [TECH-1656]
Browse files Browse the repository at this point in the history
  • Loading branch information
muilpp committed Nov 27, 2023
1 parent a5e1e57 commit 394858c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
package org.hisp.dhis.tracker.export.event;

import static org.hisp.dhis.security.Authorities.F_TRACKED_ENTITY_INSTANCE_SEARCH_IN_ALL_ORGUNITS;
import static org.hisp.dhis.tracker.export.OperationsParamsValidator.validateOrgUnitMode;

import java.util.List;
Expand Down Expand Up @@ -190,7 +191,9 @@ private void validateUser(
User user, Program program, ProgramStage programStage, OrganisationUnit requestedOrgUnit)
throws ForbiddenException {

if (user == null || user.isSuper()) {
if (user == null
|| user.isSuper()
|| user.isAuthorized(F_TRACKED_ENTITY_INSTANCE_SEARCH_IN_ALL_ORGUNITS)) {
return;
}
if (program != null && !aclService.canDataRead(user, program)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,6 @@ void shouldMapOrgUnitWhenModeAllProgramProvidedAndRequestedOrgUnitInSearchScope(
when(currentUserService.getCurrentUser()).thenReturn(user);
when(organisationUnitService.getOrganisationUnit(searchScopeChildOrgUnit.getUid()))
.thenReturn(searchScopeChildOrgUnit);
when(organisationUnitService.isInUserHierarchy(
searchScopeChildOrgUnit.getUid(), user.getTeiSearchOrganisationUnitsWithFallback()))
.thenReturn(true);

EventOperationParams operationParams =
eventBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserRole;
import org.hisp.dhis.webapi.controller.event.mapper.SortDirection;
import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -688,7 +687,7 @@ void shouldFailWhenGlobalSearchAndNoAttributeSpecified() {
.build();

Exception IllegalQueryException =
Assert.assertThrows(IllegalQueryException.class, () -> mapper.map(operationParams));
assertThrows(IllegalQueryException.class, () -> mapper.map(operationParams));

assertEquals(
"At least 1 attributes should be mentioned in the search criteria.",
Expand All @@ -715,7 +714,7 @@ void shouldaFailWhenGlobalSearchAndNoAttributeSpecified() {
.build();

Exception IllegalQueryException =
Assert.assertThrows(IllegalQueryException.class, () -> mapper.map(operationParams));
assertThrows(IllegalQueryException.class, () -> mapper.map(operationParams));

assertEquals("maxteicountreached", IllegalQueryException.getMessage());
}
Expand Down

0 comments on commit 394858c

Please sign in to comment.