use of org.summerb.users.api.dto.AuthToken in project summerb by skarpushin.
the class AuthTokenServiceDbImplTest method testIsAuthTokenValid_blackbox_expectFalseEvenForNonExistentToken.
@Test
public void testIsAuthTokenValid_blackbox_expectFalseEvenForNonExistentToken() throws Exception {
AuthTokenServiceImpl fixture = AuthTokenServiceDbImplFactory.createAuthTokenServiceDbImpl();
AuthToken result = fixture.isAuthTokenValid(UserFactory.EXISTENT_USER, AuthTokenFactory.AUTH_TOKEN_NOT_EXISTENT, "...");
assertNull(result);
}
use of org.summerb.users.api.dto.AuthToken in project summerb by skarpushin.
the class AuthTokenServiceDbImplTest method testCreateAuthToken_blackbox_expectNewAuthToken.
@Test
public void testCreateAuthToken_blackbox_expectNewAuthToken() throws Exception {
AuthTokenService fixture = AuthTokenServiceDbImplFactory.createAuthTokenServiceDbImpl();
AuthToken result = fixture.authenticate(UserFactory.EXISTENT_USER_EMAIL, PasswordFactory.RIGHT_PASSWORD_FOR_EXISTENT_USER, "0.0.0.0");
assertNotNull(result);
}
use of org.summerb.users.api.dto.AuthToken in project summerb by skarpushin.
the class AuthTokenServiceDbImplTest method testIsAuthTokenValid_blackbox_expectFalseForExpiredToken.
@Test
public void testIsAuthTokenValid_blackbox_expectFalseForExpiredToken() throws Exception {
AuthTokenServiceImpl fixture = AuthTokenServiceDbImplFactory.createAuthTokenServiceDbImpl();
AuthToken result = fixture.isAuthTokenValid(UserFactory.EXISTENT_USER_WITH_EXPIRED_TOKEN, AuthTokenFactory.AUTH_TOKEN_EXPIRED, "...");
assertNull(result);
}
use of org.summerb.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);
}
use of org.summerb.users.api.dto.AuthToken in project summerb by skarpushin.
the class AuthTokenServiceDbImplFactory method createAuthTokenServiceDbImpl.
public static AuthTokenServiceImpl createAuthTokenServiceDbImpl() {
AuthTokenServiceImpl ret = new AuthTokenServiceImpl();
ret.setPasswordService(PasswordServiceDbImplFactory.createPasswordServiceDbImpl());
ret.setUserService(UserServiceImplFactory.createUsersServiceImpl());
AuthTokenDao authTokenDao = Mockito.mock(AuthTokenDao.class);
ret.setAuthTokenDao(authTokenDao);
when(authTokenDao.findAuthTokenByUuid(AuthTokenFactory.AUTH_TOKEN_EXCEPTION)).thenThrow(new IllegalStateException("test simulate exception"));
when(authTokenDao.findAuthTokenByUuid(AuthTokenFactory.AUTH_TOKEN_EXISTENT)).thenReturn(AuthTokenFactory.createAuthTokenForExistentUser());
when(authTokenDao.findAuthTokenByUuid(AuthTokenFactory.AUTH_TOKEN_NOT_EXISTENT)).thenReturn(null);
when(authTokenDao.findAuthTokenByUuid(AuthTokenFactory.AUTH_TOKEN_EXPIRED)).thenReturn(AuthTokenFactory.createExpiredAuthToken());
List<AuthToken> expiredTokens = new LinkedList<AuthToken>();
expiredTokens.add(AuthTokenFactory.createExpiredAuthToken());
PaginatedList<AuthToken> expiredAuthTokens = new PaginatedList<AuthToken>(new PagerParams(), expiredTokens, 1);
return ret;
}
Aggregations