Search in sources :

Example 1 with AuthenticationToken

use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.

the class CassandraTokenRepositoryTest method testSaveTokenWithBadArgs.

@Test
public void testSaveTokenWithBadArgs() throws Exception {
    assertThrows(() -> instance.saveToken(null)).isInstanceOf(InvalidArgumentException.class);
    AuthenticationToken missingTokenId = new AuthenticationToken(token);
    missingTokenId.unsetTokenId();
    assertThrows(() -> instance.saveToken(missingTokenId)).isInstanceOf(InvalidArgumentException.class);
    AuthenticationToken missingOwnerId = new AuthenticationToken(token);
    missingOwnerId.unsetOwnerId();
    assertThrows(() -> instance.saveToken(missingOwnerId)).isInstanceOf(InvalidArgumentException.class);
    AuthenticationToken missingTokenType = new AuthenticationToken(token);
    missingTokenType.unsetTokenType();
    assertThrows(() -> instance.saveToken(missingTokenType)).isInstanceOf(InvalidArgumentException.class);
}
Also used : AuthenticationToken(tech.aroma.thrift.authentication.AuthenticationToken) Test(org.junit.Test)

Example 2 with AuthenticationToken

use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.

the class CassandraTokenRepositoryTest method testGetTokenWithoutOrgId.

@Test
public void testGetTokenWithoutOrgId() throws Exception {
    token.unsetOrganizationId();
    token.unsetOrganizationName();
    instance.saveToken(token);
    AuthenticationToken result = instance.getToken(tokenId);
    assertThat(result, is(token));
}
Also used : AuthenticationToken(tech.aroma.thrift.authentication.AuthenticationToken) Test(org.junit.Test)

Example 3 with AuthenticationToken

use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.

the class CassandraTokenRepositoryIT method testGetTokenWithoutOrgId.

@Test
public void testGetTokenWithoutOrgId() throws Exception {
    token.unsetOrganizationId();
    token.unsetOrganizationName();
    instance.saveToken(token);
    AuthenticationToken result = instance.getToken(tokenId);
    assertThat(result, is(token));
}
Also used : AuthenticationToken(tech.aroma.thrift.authentication.AuthenticationToken) IntegrationTest(tech.sirwellington.alchemy.annotations.testing.IntegrationTest) Test(org.junit.Test)

Example 4 with AuthenticationToken

use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.

the class CassandraTokenRepositoryIT method testGetToken.

@Test
public void testGetToken() throws Exception {
    instance.saveToken(token);
    AuthenticationToken result = instance.getToken(tokenId);
    assertThat(result, is(token));
}
Also used : AuthenticationToken(tech.aroma.thrift.authentication.AuthenticationToken) IntegrationTest(tech.sirwellington.alchemy.annotations.testing.IntegrationTest) Test(org.junit.Test)

Example 5 with AuthenticationToken

use of tech.aroma.thrift.authentication.AuthenticationToken in project aroma-data-operations by RedRoma.

the class MemoryTokenRepositoryTest method testDeleteTokens.

@Test
public void testDeleteTokens() throws Exception {
    for (AuthenticationToken token : tokens) {
        repository.saveToken(token);
    }
    List<String> tokenIds = tokens.stream().map(AuthenticationToken::getTokenId).collect(Collectors.toList());
    for (String tokenId : tokenIds) {
        assertThat(repository.containsToken(tokenId), is(true));
    }
    repository.deleteTokens(tokenIds);
    for (String tokenId : tokenIds) {
        assertThat(repository.containsToken(tokenId), is(false));
    }
    List<AuthenticationToken> tokensBelongingTo = repository.getTokensBelongingTo(ownerId);
    assertThat(tokensBelongingTo, is(empty()));
}
Also used : AuthenticationToken(tech.aroma.thrift.authentication.AuthenticationToken) StringGenerators.hexadecimalString(tech.sirwellington.alchemy.generator.StringGenerators.hexadecimalString) Test(org.junit.Test)

Aggregations

AuthenticationToken (tech.aroma.thrift.authentication.AuthenticationToken)22 Test (org.junit.Test)14 BatchStatement (com.datastax.driver.core.BatchStatement)4 Row (com.datastax.driver.core.Row)4 Statement (com.datastax.driver.core.Statement)4 InvalidArgumentException (tech.aroma.thrift.exceptions.InvalidArgumentException)3 InvalidTokenException (tech.aroma.thrift.exceptions.InvalidTokenException)3 ResultSet (com.datastax.driver.core.ResultSet)2 TException (org.apache.thrift.TException)2 OperationFailedException (tech.aroma.thrift.exceptions.OperationFailedException)2 IntegrationTest (tech.sirwellington.alchemy.annotations.testing.IntegrationTest)2 StringAssertions.nonEmptyString (tech.sirwellington.alchemy.arguments.assertions.StringAssertions.nonEmptyString)2 StringGenerators.hexadecimalString (tech.sirwellington.alchemy.generator.StringGenerators.hexadecimalString)2 Cluster (com.datastax.driver.core.Cluster)1 Session (com.datastax.driver.core.Session)1 Map (java.util.Map)1 Set (java.util.Set)1 UUID (java.util.UUID)1 Function (java.util.function.Function)1 Collectors.toSet (java.util.stream.Collectors.toSet)1