Search in sources :

Example 16 with User

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

the class UserServiceTest method getUserInum_userId_inum.

@Test
private void getUserInum_userId_inum() {
    User user = spy(getBasicUser("123", "dn123"));
    when(user.getAttribute("inum")).thenReturn("inumExample");
    when(dataSourceTypeService.isSpanner(anyString())).thenReturn(true);
    when(persistenceEntryManager.findEntries(anyString(), any(), any(), any())).thenReturn(getListBasicOneUser(user));
    String inum = userService.getUserInum("123");
    assertNotNull(inum);
    assertEquals(inum, "inumExample");
}
Also used : User(io.jans.as.common.model.common.User) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test)

Example 17 with User

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

the class UserServiceTest method getUserInum_userNull_null.

@Test
private void getUserInum_userNull_null() {
    User user = null;
    String inum = userService.getUserInum(user);
    assertNull(inum);
}
Also used : User(io.jans.as.common.model.common.User) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test)

Example 18 with User

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

the class UserServiceTest method getUsersWithPersistentJwts_noParams_listUsers.

@Test
private void getUsersWithPersistentJwts_noParams_listUsers() {
    String userId = "123";
    String baseDn = "dn123";
    when(persistenceEntryManager.findEntries(anyString(), any(), any())).thenReturn(getListBasicOneUser(userId, baseDn));
    List<User> list = userService.getUsersWithPersistentJwts();
    assertNotNull(list);
    assertTrue(list.size() == 1);
}
Also used : User(io.jans.as.common.model.common.User) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test)

Example 19 with User

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

the class UserServiceTest method addDefaultUser_withUidNoEmptyPersonCustomObject_user.

@Test
private void addDefaultUser_withUidNoEmptyPersonCustomObject_user() {
    String uid = UUID.randomUUID().toString();
    User user = getBasicUser(uid, "dn123");
    user.setCustomObjectClasses(TestUserService.DEFAULT_PERSON_CUSTOM_OBJECT_CLASS_LIST);
    doNothing().when(persistenceEntryManager).persist(any());
    when(dataSourceTypeService.isSpanner(anyString())).thenReturn(true);
    when(persistenceEntryManager.findEntries(anyString(), any(), any(), any())).thenReturn(getListBasicOneUser(user));
    when(inumService.generatePeopleInum()).thenReturn(uid);
    userService.setReturnTestListPersonCustomObjectClassList(true);
    User resultUser = userService.addDefaultUser(uid);
    assertNotNull(resultUser);
    assertNotNull(resultUser.getUserId());
    assertEquals(resultUser.getUserId(), uid);
    assertTrue(resultUser.getCustomObjectClasses().length == 2);
    assertTrue(resultUser.getCustomObjectClasses()[0].equals(user.getCustomObjectClasses()[0]));
}
Also used : User(io.jans.as.common.model.common.User) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test)

Example 20 with User

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

the class UserServiceTest method removeUserAttribute_noExistentAttribute_null.

@Test
private void removeUserAttribute_noExistentAttribute_null() {
    String userId = "123";
    String baseDn = "dn123";
    User user = spy(getBasicUser("123", "dn123"));
    CustomObjectAttribute customAttribute1 = new CustomObjectAttribute("attribute1", "value1");
    user.setCustomAttributes(new ArrayList<>());
    user.getCustomAttributes().add(customAttribute1);
    when(dataSourceTypeService.isSpanner(anyString())).thenReturn(true);
    when(persistenceEntryManager.findEntries(anyString(), any(), any(), any())).thenReturn(getListBasicOneUser(userId, baseDn));
    User resultUser = userService.removeUserAttributeValue(userId, "attribute2", "value2");
    assertNull(resultUser);
}
Also used : CustomObjectAttribute(io.jans.orm.model.base.CustomObjectAttribute) 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