use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class AuthTokenDaoImplTest method testCreateAuthToken_expectOk.
@Test
public void testCreateAuthToken_expectOk() throws Exception {
User user = userService.createUser(UserFactory.createNewUserTemplate());
passwordService.setUserPassword(user.getUuid(), "aaa");
AuthToken authToken = authTokenService.authenticate(user.getEmail(), "aaa", "LOCAL");
assertNotNull(authToken);
}
use of org.summerb.users.api.dto.User 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);
}
use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class AuthTokenDaoImplTest method testDeleteAuthToken_expectDeletedAuthTokenMustNotBeValid.
@Test
public void testDeleteAuthToken_expectDeletedAuthTokenMustNotBeValid() 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);
authTokenService.deleteAuthToken(authToken.getUuid());
result = authTokenService.isAuthTokenValid(user.getUuid(), authToken.getUuid(), authToken.getTokenValue());
assertNull(result);
}
use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class AuthTokenDaoImplTest method testFindExpiredAuthTokens_expect2Tokens.
@Test
public void testFindExpiredAuthTokens_expect2Tokens() throws Exception {
User user = userService.createUser(UserFactory.createNewUserTemplate());
passwordService.setUserPassword(user.getUuid(), "aaa");
AuthToken authToken1 = authTokenService.authenticate(user.getEmail(), "aaa", "LOCAL");
assertNotNull(authToken1);
Thread.sleep(501);
AuthToken authToken2 = authTokenService.authenticate(user.getEmail(), "aaa", "LOCAL");
assertNotNull(authToken2);
Thread.sleep(501);
List<AuthToken> tokens = authTokenService.findUserAuthTokens(user.getUuid());
assertEquals(2, tokens.size());
}
use of org.summerb.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());
}
Aggregations