use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.
the class MemoryTokenRepositoryTest method testSaveToken.
@Test
public void testSaveToken() throws Exception {
repository.saveToken(token);
AuthenticationToken result = repository.getToken(tokenId);
assertThat(result, is(token));
}
use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.
the class MemoryTokenRepositoryTest method testGetTokensWhenNoneExistForOwner.
@Test
public void testGetTokensWhenNoneExistForOwner() throws Exception {
String ownerId = one(hexadecimalString(10));
List<AuthenticationToken> result = repository.getTokensBelongingTo(ownerId);
assertThat(result, notNullValue());
assertThat(result.isEmpty(), is(true));
}
use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.
the class AuthenticationAssertionsTest method testCompleteToken.
@Test
public void testCompleteToken() {
AlchemyAssertion<AuthenticationToken> instance = AuthenticationAssertions.completeToken();
assertThat(instance, notNullValue());
instance.check(token);
AuthenticationToken tokenWithoutTokenId = new AuthenticationToken(token);
tokenWithoutTokenId.unsetTokenId();
assertThrows(() -> instance.check(tokenWithoutTokenId)).isInstanceOf(FailedAssertionException.class);
AuthenticationToken tokenWithoutOwnerId = new AuthenticationToken(token);
tokenWithoutOwnerId.unsetOwnerId();
assertThrows(() -> instance.check(tokenWithoutOwnerId)).isInstanceOf(FailedAssertionException.class);
AuthenticationToken tokenWithoutTokenType = new AuthenticationToken(token);
tokenWithoutTokenType.unsetTokenType();
assertThrows(() -> instance.check(tokenWithoutTokenType)).isInstanceOf(FailedAssertionException.class);
}
use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.
the class CassandraTokenRepository method getTokensBelongingTo.
@Override
public List<AuthenticationToken> getTokensBelongingTo(String ownerId) throws TException {
checkThat(ownerId).throwing(InvalidArgumentException.class).usingMessage("ownerId missing").is(nonEmptyString()).usingMessage("ownerId must be a UUID type").is(validUUID());
Statement query = createQueryToGetTokensOwnedBy(ownerId);
ResultSet results = tryToGetResultSetFrom(query);
List<AuthenticationToken> tokens = Lists.create();
for (Row row : results) {
AuthenticationToken token = tryToConvertRowToToken(row);
tokens.add(token);
}
LOG.debug("Found {} tokens owned by {}", tokens.size(), ownerId);
return tokens;
}
use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.
the class CassandraTokenRepository method getToken.
@Override
public AuthenticationToken getToken(String tokenId) throws TException, InvalidTokenException {
checkTokenId(tokenId);
Statement query = createQueryToGetToken(tokenId);
Row row = tryToGetOneRowFrom(query);
AuthenticationToken token = tryToConvertRowToToken(row);
return token;
}
Aggregations