Search in sources :

Example 16 with User

use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.

the class AuthTokenDaoImplTest method testUpdateToken_expectValueWillBeUpdated.

@Test
public void testUpdateToken_expectValueWillBeUpdated() throws Exception {
    User user = userService.createUser(UserFactory.createNewUserTemplate());
    passwordService.setUserPassword(user.getUuid(), "aaa");
    AuthToken authToken = authTokenService.createAuthToken(user.getEmail(), "LOCAL", "tUuid1", "tValue1");
    assertNotNull(authToken);
    authTokenDao.updateToken(authToken.getUuid(), new Date().getTime() + 1, "newValue2");
    authToken = authTokenService.getAuthTokenByUuid(authToken.getUuid());
    assertEquals("newValue2", authToken.getTokenValue());
}
Also used : User(org.summerb.microservices.users.api.dto.User) AuthToken(org.summerb.microservices.users.api.dto.AuthToken) Date(java.util.Date) Test(org.junit.Test)

Example 17 with User

use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.

the class AuthTokenDaoImplTest method testSetRestorationToken_expectWillReportAffectedRecords.

@Test
public void testSetRestorationToken_expectWillReportAffectedRecords() throws Exception {
    User user = userService.createUser(UserFactory.createNewUserTemplate());
    passwordService.setUserPassword(user.getUuid(), "aaa");
    int result = passwordDao.setRestorationToken(user.getUuid(), "new-hash");
    assertTrue(result > 0);
    // do the same. Still expect affected > 0
    result = passwordDao.setRestorationToken(user.getUuid(), "new-hash");
    assertTrue(result > 0);
}
Also used : User(org.summerb.microservices.users.api.dto.User) Test(org.junit.Test)

Example 18 with User

use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.

the class AuthTokenDaoImplTest method testUpdateUserPassword_expectWillReportAffectedRecords.

@Test
public void testUpdateUserPassword_expectWillReportAffectedRecords() throws Exception {
    User user = userService.createUser(UserFactory.createNewUserTemplate());
    passwordService.setUserPassword(user.getUuid(), "aaa");
    int result = passwordDao.updateUserPassword(user.getUuid(), "new-hash");
    assertTrue(result > 0);
    // do the same. Still expect affected > 0
    result = passwordDao.updateUserPassword(user.getUuid(), "new-hash");
    assertTrue(result > 0);
}
Also used : User(org.summerb.microservices.users.api.dto.User) Test(org.junit.Test)

Example 19 with User

use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.

the class PasswordDaoImplTest method testSetUserPassword_expectDuplicateWillBeRewrittenWithoutErrors.

@Test
public void testSetUserPassword_expectDuplicateWillBeRewrittenWithoutErrors() throws Exception {
    User createdUser = userService.createUser(UserFactory.createNewUserTemplate());
    String pwd1 = "aaaa";
    passwordService.setUserPassword(createdUser.getUuid(), pwd1);
    String pwd2 = "bbbb";
    passwordService.setUserPassword(createdUser.getUuid(), pwd2);
    boolean result = passwordService.isUserPasswordValid(createdUser.getUuid(), pwd2);
    assertTrue(result);
}
Also used : User(org.summerb.microservices.users.api.dto.User) Test(org.junit.Test)

Example 20 with User

use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.

the class PasswordDaoImplTest method testSetUserPassword_expectWillBePerformedOk.

@Test
public void testSetUserPassword_expectWillBePerformedOk() throws Exception {
    User createdUser = userService.createUser(UserFactory.createNewUserTemplate());
    String pwd1 = "aaaa";
    passwordService.setUserPassword(createdUser.getUuid(), pwd1);
    boolean result = passwordService.isUserPasswordValid(createdUser.getUuid(), pwd1);
    assertTrue(result);
}
Also used : User(org.summerb.microservices.users.api.dto.User) Test(org.junit.Test)

Aggregations

User (org.summerb.microservices.users.api.dto.User)61 Test (org.junit.Test)34 UserNotFoundException (org.summerb.microservices.users.api.exceptions.UserNotFoundException)13 FieldValidationException (org.summerb.approaches.validation.FieldValidationException)11 AuthToken (org.summerb.microservices.users.api.dto.AuthToken)11 UserServiceUnexpectedException (org.summerb.microservices.users.api.exceptions.UserServiceUnexpectedException)11 Transactional (org.springframework.transaction.annotation.Transactional)8 Date (java.util.Date)4 PagerParams (org.summerb.approaches.jdbccrud.api.dto.PagerParams)4 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)3 InvalidPasswordException (org.summerb.microservices.users.api.exceptions.InvalidPasswordException)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 UserDetailsImpl (org.summerb.approaches.springmvc.security.dto.UserDetailsImpl)2 ValidationContext (org.summerb.approaches.validation.ValidationContext)2 GenericException (org.summerb.utils.exceptions.GenericException)2 CacheBuilder (com.google.common.cache.CacheBuilder)1 EventBus (com.google.common.eventbus.EventBus)1 Gson (com.google.gson.Gson)1 Locale (java.util.Locale)1 Secured (org.springframework.security.access.annotation.Secured)1