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));
}
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);
}
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));
}
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);
}
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);
}
}
}
Aggregations