use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.
the class MemoryTokenRepository method deleteToken.
@Override
public void deleteToken(String tokenId) throws TException {
checkThat(tokenId).usingMessage("missing tokenId").throwing(InvalidArgumentException.class).is(nonEmptyString());
synchronized (tokens) {
AuthenticationToken token = tokens.remove(tokenId);
if (token == null) {
return;
}
deleteTokenFromOwner(token);
}
}
use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.
the class MemoryTokenRepository method deleteTokenFromOwner.
private void deleteTokenFromOwner(AuthenticationToken token) {
String ownerId = token.ownerId;
synchronized (tokens) {
List<AuthenticationToken> ownerTokens = tokensByOwner.getOrDefault(ownerId, Lists.emptyList());
ownerTokens = ownerTokens.stream().filter(t -> !Objects.equals(t.tokenId, token.tokenId)).collect(toList());
this.tokensByOwner.put(ownerId, ownerTokens);
}
}
use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.
the class RequestAssertionsTest method testTokenContainingOwnerIdWithBadArgs.
@Test
public void testTokenContainingOwnerIdWithBadArgs() {
AlchemyAssertion<AuthenticationToken> assertion = RequestAssertions.tokenContainingOwnerId();
assertThat(assertion, notNullValue());
assertThrows(() -> assertion.check(null)).isInstanceOf(FailedAssertionException.class);
AuthenticationToken emptyToken = new AuthenticationToken();
assertThrows(() -> assertion.check(emptyToken)).isInstanceOf(FailedAssertionException.class);
}
use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.
the class CassandraTokenRepositoryTest method testGetToken.
@Test
public void testGetToken() throws Exception {
AuthenticationToken result = instance.getToken(tokenId);
assertThat(result, is(token));
}
use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.
the class CassandraTokenRepositoryTest method testGetTokensBelongingTo.
@Test
public void testGetTokensBelongingTo() throws Exception {
AlchemyGenerator<AuthenticationToken> generator = pojos(AuthenticationToken.class);
Set<AuthenticationToken> expected = listOf(generator).stream().map(t -> t.setOwnerId(ownerId)).map(t -> t.setTokenId(one(uuids))).map(t -> t.setOrganizationId(one(uuids))).collect(toSet());
Map<AuthenticationToken, Row> rows = Maps.create();
for (AuthenticationToken t : expected) {
Row mockRow = mock(Row.class);
when(tokenMapper.apply(mockRow)).thenReturn(t);
rows.put(t, mockRow);
}
when(results.iterator()).thenReturn(rows.values().iterator());
Set<AuthenticationToken> result = Sets.toSet(instance.getTokensBelongingTo(ownerId));
assertThat(result, is(expected));
}
Aggregations