use of com.mercedesbenz.sechub.domain.authorization.AuthUser in project sechub by mercedes-benz.
the class AuthUserUpdateRolesServiceTest method a_user_having_role_superadmin_and_updated_as_user_only__has_role_user_and_no_longer_superadmin.
@Test
public void a_user_having_role_superadmin_and_updated_as_user_only__has_role_user_and_no_longer_superadmin() {
/* prepare */
AuthUser user = new AuthUser();
user.setRoleSuperAdmin(true);
when(authUserRepository.findOrFail("user")).thenReturn(user);
/* execute */
serviceToTest.updateRoles("user", new LinkedHashSet<>(Arrays.asList(RoleConstants.ROLE_USER)));
/* test */
assertTrue(user.isRoleUser());
assertFalse(user.isRoleOwner());
assertFalse(user.isRoleSuperAdmin());
}
use of com.mercedesbenz.sechub.domain.authorization.AuthUser in project sechub by mercedes-benz.
the class AuthUserUpdateRolesServiceTest method a_user_having_no_role_and_updated_as_user_has_role_user.
@Test
public void a_user_having_no_role_and_updated_as_user_has_role_user() {
/* prepare */
AuthUser user = new AuthUser();
when(authUserRepository.findOrFail("user")).thenReturn(user);
/* execute */
serviceToTest.updateRoles("user", Collections.singleton(RoleConstants.ROLE_USER));
/* test */
assertTrue(user.isRoleUser());
assertFalse(user.isRoleOwner());
assertFalse(user.isRoleSuperAdmin());
}
Aggregations