Search in sources :

Example 81 with User

use of org.olat.core.id.User in project openolat by klemens.

the class ShibbolethAttributesTest method getIdenticalOlatUser.

private User getIdenticalOlatUser() {
    User user = new TestableUser();
    user.setProperty(USER_EMAIL_KEY, SHIB_EMAIL_VALUE);
    user.setProperty(USER_NAME_KEY, SHIB_NAME_VALUE);
    user.setProperty(USER_GENDER_KEY, SHIB_GENDER_VALUE);
    user.setProperty(USER_CITY_KEY, SHIB_CITY_VALUE_NULL);
    return user;
}
Also used : User(org.olat.core.id.User)

Example 82 with User

use of org.olat.core.id.User in project openolat by klemens.

the class JunitTestHelper method createAndPersistIdentityAsUser.

/**
 * Create an identity with user permissions
 * @param login
 * @return
 */
public static final Identity createAndPersistIdentityAsUser(String login) {
    BaseSecurity securityManager = BaseSecurityManager.getInstance();
    Identity identity = securityManager.findIdentityByName(login);
    if (identity != null)
        return identity;
    SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
    if (group == null)
        group = securityManager.createAndPersistNamedSecurityGroup(Constants.GROUP_OLATUSERS);
    User user = UserManager.getInstance().createUser("first" + login, "last" + login, login + "@" + maildomain);
    identity = securityManager.createAndPersistIdentityAndUser(login, null, user, BaseSecurityModule.getDefaultAuthProviderIdentifier(), login, PWD);
    securityManager.addIdentityToSecurityGroup(identity, group);
    return identity;
}
Also used : User(org.olat.core.id.User) Identity(org.olat.core.id.Identity) SecurityGroup(org.olat.basesecurity.SecurityGroup) BaseSecurity(org.olat.basesecurity.BaseSecurity)

Example 83 with User

use of org.olat.core.id.User in project openolat by klemens.

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 84 with User

use of org.olat.core.id.User in project openolat by klemens.

the class UserTest method testUmFindUserByKey.

/**
 * Test if usermanager.findUserByKey() works
 * @throws Exception
 */
@Test
public void testUmFindUserByKey() throws Exception {
    log.debug("Entering testUmFindUserByKey()");
    // find users that do exist
    User u3test = userManager.loadUserByKey(u1.getKey());
    assertTrue(u1.getKey().equals(u3test.getKey()));
}
Also used : User(org.olat.core.id.User) Test(org.junit.Test)

Example 85 with User

use of org.olat.core.id.User in project openolat by klemens.

the class UserTest method testEquals.

@Test
public void testEquals() {
    User user1 = userManager.findUniqueIdentityByEmail("salat@id.salat.uzh.ch").getUser();
    User user2 = userManager.findUniqueIdentityByEmail("migros@id.migros.uzh.ch").getUser();
    User user1_2 = userManager.findUniqueIdentityByEmail("salat@id.salat.uzh.ch").getUser();
    assertFalse("Wrong equals implementation, different types are recognized as equals ", user1.equals(new Integer(1)));
    assertFalse("Wrong equals implementation, different users are recognized as equals ", user1.equals(user2));
    assertFalse("Wrong equals implementation, null value is recognized as equals ", user1.equals(null));
    assertTrue("Wrong equals implementation, same users are NOT recognized as equals ", user1.equals(user1));
    assertTrue("Wrong equals implementation, same users are NOT recognized as equals ", user1.equals(user1_2));
}
Also used : User(org.olat.core.id.User) 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