Search in sources :

Example 51 with User

use of org.olat.core.id.User in project OpenOLAT by OpenOLAT.

the class ShibbolethAttributesTest method shouldReturnFalseIfNoAttributeHasChanged.

@Test
public void shouldReturnFalseIfNoAttributeHasChanged() {
    User user = getIdenticalOlatUser();
    boolean hasDifference = sut.hasDifference(user);
    assertThat(hasDifference).isFalse();
}
Also used : User(org.olat.core.id.User) Test(org.junit.Test)

Example 52 with User

use of org.olat.core.id.User in project OpenOLAT by OpenOLAT.

the class ShibbolethAttributesTest method shouldChangeChangedPropertyOfSyncedUser.

@Test
public void shouldChangeChangedPropertyOfSyncedUser() {
    User user = getIdenticalOlatUser();
    user.setProperty(USER_NAME_KEY, USER_OLD_VALUE);
    User syncedUser = sut.syncUser(user);
    assertThat(syncedUser.getProperty(USER_CITY_KEY, null)).isEqualTo(SHIB_CITY_VALUE_NULL);
}
Also used : User(org.olat.core.id.User) Test(org.junit.Test)

Example 53 with User

use of org.olat.core.id.User in project OpenOLAT by OpenOLAT.

the class ShibbolethAttributesTest method shouldChangePropertyOfSyncedUserIfItWasNotPresent.

@Test
public void shouldChangePropertyOfSyncedUserIfItWasNotPresent() {
    User user = getIdenticalOlatUser();
    user.setProperty(USER_NAME_KEY, null);
    User syncedUser = sut.syncUser(user);
    assertThat(syncedUser.getProperty(USER_CITY_KEY, null)).isEqualTo(SHIB_CITY_VALUE_NULL);
}
Also used : User(org.olat.core.id.User) Test(org.junit.Test)

Example 54 with User

use of org.olat.core.id.User in project OpenOLAT by OpenOLAT.

the class UserManagerImplTest method shouldAllowEmailIfItsOwnEmail.

@Test
public void shouldAllowEmailIfItsOwnEmail() {
    when(userModuleMock.isEmailUnique()).thenReturn(true);
    when(userModuleMock.isEmailMandatory()).thenReturn(true);
    User myselfMock = mock(User.class);
    when(myselfMock.getEmail()).thenReturn(DUPLICATE_EMAIL);
    boolean isEmailAllowed = sut.isEmailAllowed(DUPLICATE_EMAIL, myselfMock);
    assertThat(isEmailAllowed).isTrue();
}
Also used : User(org.olat.core.id.User) Test(org.junit.Test)

Example 55 with User

use of org.olat.core.id.User in project OpenOLAT by OpenOLAT.

the class UserManagerImplTest method shouldEnsureEmailIfHasNoEmail.

@Test
public void shouldEnsureEmailIfHasNoEmail() {
    Long userKey = 123l;
    String issuer = "issuer";
    AuthenticationProvider authenticationProviderMock = mock(AuthenticationProvider.class);
    when(authenticationProviderMock.getIssuerIdentifier(any())).thenReturn(issuer);
    when(loginModuleMock.getAuthenticationProvider("OLAT")).thenReturn(authenticationProviderMock);
    User userWithoutEmailMock = mock(User.class);
    when(userWithoutEmailMock.getKey()).thenReturn(userKey);
    String ensuredEmail = sut.getEnsuredEmail(userWithoutEmailMock);
    String expectedValue = userKey + "@" + issuer;
    assertThat(ensuredEmail).isEqualTo(expectedValue);
}
Also used : User(org.olat.core.id.User) AuthenticationProvider(org.olat.login.auth.AuthenticationProvider) Test(org.junit.Test)

Aggregations

User (org.olat.core.id.User)260 Identity (org.olat.core.id.Identity)126 Test (org.junit.Test)82 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)52 HashMap (java.util.HashMap)28 Translator (org.olat.core.gui.translator.Translator)26 SecurityGroup (org.olat.basesecurity.SecurityGroup)20 Date (java.util.Date)18 ArrayList (java.util.ArrayList)16 Locale (java.util.Locale)16 FormItem (org.olat.core.gui.components.form.flexible.FormItem)16 File (java.io.File)14 VelocityContext (org.apache.velocity.VelocityContext)14 MailTemplate (org.olat.core.util.mail.MailTemplate)12 LDAPUser (org.olat.ldap.model.LDAPUser)12 UserManager (org.olat.user.UserManager)12 IOException (java.io.IOException)10 Map (java.util.Map)10 List (java.util.List)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8