Search in sources :

Example 21 with User

use of io.jans.as.common.model.common.User in project jans by JanssenProject.

the class UserServiceTest method getUser_nullUserId_user.

@Test
private void getUser_nullUserId_user() {
    User user = userService.getUser(null, null);
    assertNull(user);
}
Also used : User(io.jans.as.common.model.common.User) Test(org.testng.annotations.Test)

Example 22 with User

use of io.jans.as.common.model.common.User in project jans by JanssenProject.

the class UserServiceTest method getUserByAttributes_validAttributeNamesSize2NoIsSpanner_user.

@Test
private void getUserByAttributes_validAttributeNamesSize2NoIsSpanner_user() {
    String userId = "123";
    String baseDn = "baseDn";
    String[] attributeNames = { "attribute1", "attribute2" };
    String attributeValue = "value1";
    when(dataSourceTypeService.isSpanner(anyString())).thenReturn(false);
    when(persistenceEntryManager.findEntries(anyString(), any(), any(), any(), anyInt())).thenReturn(getListBasicOneUser(userId, baseDn));
    User resultUser = userService.getUserByAttributes(attributeValue, attributeNames, true, null);
    assertNotNull(resultUser);
}
Also used : User(io.jans.as.common.model.common.User) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test)

Example 23 with User

use of io.jans.as.common.model.common.User in project jans by JanssenProject.

the class UserServiceTest method addUser_noEmptyPersonCustomObject_user.

@Test
private void addUser_noEmptyPersonCustomObject_user() {
    User user = getBasicUser("123", "dn123");
    doNothing().when(persistenceEntryManager).persist(any());
    when(persistenceEntryManager.find(anyString(), any(), any())).thenReturn(user);
    when(inumService.generatePeopleInum()).thenReturn(UUID.randomUUID().toString());
    userService.setReturnTestListPersonCustomObjectClassList(true);
    User resultUser = userService.addUser(user, true);
    assertNotNull(resultUser);
    assertNotNull(resultUser.getUserId());
    assertNotNull(user.getAttribute("jansStatus"));
    assertNotNull(user.getAttribute("inum"));
    assertEquals(user.getAttribute("jansStatus"), GluuStatus.ACTIVE.getValue());
    assertTrue(resultUser.getCustomObjectClasses().length == 2);
    assertTrue(resultUser.getCustomObjectClasses()[0].equals(user.getCustomObjectClasses()[0]));
}
Also used : User(io.jans.as.common.model.common.User) Test(org.testng.annotations.Test)

Example 24 with User

use of io.jans.as.common.model.common.User in project jans by JanssenProject.

the class UserServiceTest method getUserByAttribute_validAttributeValueAttributeName_user.

@Test
private void getUserByAttribute_validAttributeValueAttributeName_user() {
    String userId = "123";
    String baseDn = "baseDn";
    String attributeName = "attribute1";
    String attributeValue = "value1";
    when(persistenceEntryManager.findEntries(anyString(), any(), any(), anyInt())).thenReturn(getListBasicOneUser(userId, baseDn));
    User resultUser = userService.getUserByAttribute(attributeName, attributeValue);
    assertNotNull(resultUser);
}
Also used : User(io.jans.as.common.model.common.User) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test)

Example 25 with User

use of io.jans.as.common.model.common.User in project jans by JanssenProject.

the class UserServiceTest method getUser_isSpannerPeopleBaseDn_user.

@Test
private void getUser_isSpannerPeopleBaseDn_user() {
    String userId = "123";
    String baseDn = "dn123";
    when(dataSourceTypeService.isSpanner(anyString())).thenReturn(true);
    when(persistenceEntryManager.findEntries(anyString(), any(), any(), any())).thenReturn(getListBasicOneUser(userId, baseDn));
    User user = userService.getUser(userId, null);
    assertNotNull(user);
    assertEquals(user.getUserId(), userId);
    assertEquals(user.getBaseDn(), baseDn);
}
Also used : User(io.jans.as.common.model.common.User) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test)

Aggregations

User (io.jans.as.common.model.common.User)95 Test (org.testng.annotations.Test)54 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)35 CustomObjectAttribute (io.jans.orm.model.base.CustomObjectAttribute)12 Client (io.jans.as.common.model.registration.Client)11 Date (java.util.Date)11 SessionId (io.jans.as.server.model.common.SessionId)9 Scope (io.jans.as.persistence.model.Scope)8 ArrayList (java.util.ArrayList)8 SimpleUser (io.jans.as.common.model.common.SimpleUser)7 WebApplicationException (javax.ws.rs.WebApplicationException)6 OAuth2AuditLog (io.jans.as.server.model.audit.OAuth2AuditLog)5 Response (javax.ws.rs.core.Response)5 JsonWebResponse (io.jans.as.model.token.JsonWebResponse)4 AuthorizationGrant (io.jans.as.server.model.common.AuthorizationGrant)4 EntryPersistenceException (io.jans.orm.exception.EntryPersistenceException)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 InvalidJwtException (io.jans.as.model.exception.InvalidJwtException)3 CibaRequestCacheControl (io.jans.as.server.model.common.CibaRequestCacheControl)3 CustomAttribute (io.jans.orm.model.base.CustomAttribute)3