Search in sources :

Example 51 with UserAuthorityGroup

use of org.hisp.dhis.user.UserAuthorityGroup in project dhis2-core by dhis2.

the class TrackerTest method makeUserSuper.

protected void makeUserSuper(User user) {
    UserAuthorityGroup group = new UserAuthorityGroup();
    group.setName("Super");
    group.setUid("uid4");
    group.setAuthorities(new HashSet<>(Arrays.asList("z1", UserAuthorityGroup.AUTHORITY_ALL)));
    user.setUserAuthorityGroups(Sets.newHashSet(group));
}
Also used : UserAuthorityGroup(org.hisp.dhis.user.UserAuthorityGroup)

Example 52 with UserAuthorityGroup

use of org.hisp.dhis.user.UserAuthorityGroup in project dhis2-core by dhis2.

the class SupplementaryDataProviderTest method getAuthorityGroups.

private Set<UserAuthorityGroup> getAuthorityGroups() {
    UserAuthorityGroup groupA = createUserAuthorityGroup('A');
    UserAuthorityGroup groupB = createUserAuthorityGroup('B');
    return Sets.newHashSet(groupA, groupB);
}
Also used : UserAuthorityGroup(org.hisp.dhis.user.UserAuthorityGroup)

Example 53 with UserAuthorityGroup

use of org.hisp.dhis.user.UserAuthorityGroup in project dhis2-core by dhis2.

the class TrackedEntityInstanceAttributesAggregateAclTest method setUserAuthorityToNonSuper.

protected void setUserAuthorityToNonSuper(User user) {
    UserAuthorityGroup userAuthorityGroup = new UserAuthorityGroup();
    userAuthorityGroup.setName("UserAuthorityGroup_" + user.getUsername());
    userAuthorityGroup.setUid(CodeGenerator.generateUid());
    userAuthorityGroup.setAuthorities(new HashSet<>(Collections.singletonList("user")));
    user.setUserAuthorityGroups(Sets.newHashSet(userAuthorityGroup));
}
Also used : UserAuthorityGroup(org.hisp.dhis.user.UserAuthorityGroup)

Example 54 with UserAuthorityGroup

use of org.hisp.dhis.user.UserAuthorityGroup in project dhis2-core by dhis2.

the class ObjectBundleServiceUserTest method testCreateUserRoleWithCode.

@Test
void testCreateUserRoleWithCode() throws IOException {
    createUserAndInjectSecurityContext(true);
    ObjectBundleParams params = createBundleParams(ObjectBundleMode.COMMIT, ImportStrategy.CREATE, AtomicMode.ALL, "dxf2/user_userrole_code.json");
    params.setPreheatIdentifier(PreheatIdentifier.CODE);
    ObjectBundle bundle = objectBundleService.create(params);
    objectBundleService.commit(bundle);
    User userA = manager.get(User.class, "sPWjoHSY03y");
    assertNotNull(userA);
    assertEquals(1, userA.getUserAuthorityGroups().size());
    assertEquals(1, userA.getDataViewOrganisationUnits().size());
    UserAuthorityGroup userManagerRole = manager.get(UserAuthorityGroup.class, "xJZBzAHI88H");
    assertNotNull(userManagerRole);
}
Also used : User(org.hisp.dhis.user.User) UserAuthorityGroup(org.hisp.dhis.user.UserAuthorityGroup) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 55 with UserAuthorityGroup

use of org.hisp.dhis.user.UserAuthorityGroup in project dhis2-core by dhis2.

the class UserController method populateUserCredentialsDtoFields.

private void populateUserCredentialsDtoFields(User user) {
    UserCredentialsDto userCredentialsRaw = user.getUserCredentialsRaw();
    if (userCredentialsRaw != null) {
        copyProperties(userCredentialsRaw, user, KEY_PASSWORD);
        if (userCredentialsRaw.getPassword() != null) {
            user.setPassword(userCredentialsRaw.getPassword());
        }
        Set<UserAuthorityGroup> userRoles = userCredentialsRaw.getUserRoles();
        if (userRoles != null) {
            user.setUserAuthorityGroups(userRoles);
        }
    }
}
Also used : UserAuthorityGroup(org.hisp.dhis.user.UserAuthorityGroup) UserCredentialsDto(org.hisp.dhis.user.UserCredentialsDto)

Aggregations

UserAuthorityGroup (org.hisp.dhis.user.UserAuthorityGroup)56 User (org.hisp.dhis.user.User)41 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)19 Test (org.junit.jupiter.api.Test)19 TransactionalIntegrationTest (org.hisp.dhis.TransactionalIntegrationTest)17 List (java.util.List)15 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)15 DataSet (org.hisp.dhis.dataset.DataSet)15 DataElement (org.hisp.dhis.dataelement.DataElement)14 ClassPathResource (org.springframework.core.io.ClassPathResource)14 ObjectBundleValidationReport (org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport)11 HashSet (java.util.HashSet)7 Program (org.hisp.dhis.program.Program)7 UserGroup (org.hisp.dhis.user.UserGroup)6 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)5 Section (org.hisp.dhis.dataset.Section)4 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)4 EventVisualization (org.hisp.dhis.eventvisualization.EventVisualization)4 ProgramStage (org.hisp.dhis.program.ProgramStage)4 ProgramStageDataElement (org.hisp.dhis.program.ProgramStageDataElement)4