Search in sources :

Example 26 with AuthToken

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

the class AuthTokenServiceDbImplTest method testGetAuthTokenByUuid_blackbox_expectOk.

@Test
public void testGetAuthTokenByUuid_blackbox_expectOk() throws Exception {
    AuthTokenServiceImpl fixture = AuthTokenServiceDbImplFactory.createAuthTokenServiceDbImpl();
    AuthToken result = fixture.getAuthTokenByUuid(AuthTokenFactory.AUTH_TOKEN_EXISTENT);
    assertNotNull(result);
}
Also used : AuthToken(org.summerb.microservices.users.api.dto.AuthToken) Test(org.junit.Test)

Example 27 with AuthToken

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

the class AuthTokenDaoImplTest method testIsAuthTokenValid_expectWillNotUpdateLastVerifiedForOldValue.

@Test
public void testIsAuthTokenValid_expectWillNotUpdateLastVerifiedForOldValue() throws Exception {
    User user = userService.createUser(UserFactory.createNewUserTemplate());
    passwordService.setUserPassword(user.getUuid(), "aaa");
    AuthToken authToken = authTokenService.authenticate(user.getEmail(), "aaa", "LOCAL");
    assertNotNull(authToken);
    authTokenDao.updateToken(authToken.getUuid(), 5, null);
    authToken = authTokenService.getAuthTokenByUuid(authToken.getUuid());
    assertTrue(authToken.getLastVerifiedAt() > 5);
}
Also used : User(org.summerb.microservices.users.api.dto.User) AuthToken(org.summerb.microservices.users.api.dto.AuthToken) Test(org.junit.Test)

Example 28 with AuthToken

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

the class AuthTokenDaoImplTest method testIsAuthTokenValid_expectTokenMustBeValidRightAfterCreation.

@Test
public void testIsAuthTokenValid_expectTokenMustBeValidRightAfterCreation() throws Exception {
    User user = userService.createUser(UserFactory.createNewUserTemplate());
    passwordService.setUserPassword(user.getUuid(), "aaa");
    AuthToken authToken = authTokenService.authenticate(user.getEmail(), "aaa", "LOCAL");
    assertNotNull(authToken);
    AuthToken result = authTokenService.isAuthTokenValid(user.getUuid(), authToken.getUuid(), authToken.getTokenValue());
    assertNotNull(result);
}
Also used : User(org.summerb.microservices.users.api.dto.User) AuthToken(org.summerb.microservices.users.api.dto.AuthToken) Test(org.junit.Test)

Aggregations

AuthToken (org.summerb.microservices.users.api.dto.AuthToken)28 Test (org.junit.Test)12 User (org.summerb.microservices.users.api.dto.User)11 Transactional (org.springframework.transaction.annotation.Transactional)3 FieldValidationException (org.summerb.approaches.validation.FieldValidationException)3 UserNotFoundException (org.summerb.microservices.users.api.exceptions.UserNotFoundException)3 UserServiceUnexpectedException (org.summerb.microservices.users.api.exceptions.UserServiceUnexpectedException)3 File (java.io.File)2 Date (java.util.Date)2 AuthTokenNotFoundException (org.summerb.microservices.users.api.exceptions.AuthTokenNotFoundException)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 FileWriter (java.io.FileWriter)1 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)1 PersistentRememberMeToken (org.springframework.security.web.authentication.rememberme.PersistentRememberMeToken)1 PagerParams (org.summerb.approaches.jdbccrud.api.dto.PagerParams)1 PaginatedList (org.summerb.approaches.jdbccrud.api.dto.PaginatedList)1