Search in sources :

Example 11 with AuthUser

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());
}
Also used : AuthUser(com.mercedesbenz.sechub.domain.authorization.AuthUser) Test(org.junit.Test)

Example 12 with AuthUser

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());
}
Also used : AuthUser(com.mercedesbenz.sechub.domain.authorization.AuthUser) Test(org.junit.Test)

Aggregations

AuthUser (com.mercedesbenz.sechub.domain.authorization.AuthUser)12 Test (org.junit.Test)9 IsSendingAsyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)1 UseCaseAdminAcceptsSignup (com.mercedesbenz.sechub.sharedkernel.usecases.admin.signup.UseCaseAdminAcceptsSignup)1 UseCaseUserClicksLinkToGetNewAPIToken (com.mercedesbenz.sechub.sharedkernel.usecases.user.UseCaseUserClicksLinkToGetNewAPIToken)1 InOrder (org.mockito.InOrder)1 OptimisticLockingFailureException (org.springframework.dao.OptimisticLockingFailureException)1