Search in sources :

Example 66 with AccessToken

use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.

the class UserServiceTest method testInvalidateAccessToken.

@Test
public void testInvalidateAccessToken() {
    ByteBuffer username = getAcceptableUsername();
    ByteBuffer password = getSecurePassword();
    service.create(username, password, Role.ADMIN);
    AccessToken token = service.tokens.issue(username);
    service.tokens.expire(token);
    Assert.assertFalse(service.tokens.isValid(token));
}
Also used : AccessToken(com.cinchapi.concourse.thrift.AccessToken) ByteBuffer(java.nio.ByteBuffer) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest) Test(org.junit.Test)

Example 67 with AccessToken

use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.

the class UserServiceTest method testChangingPasswordInvalidatesAllAccessTokens.

@Test
public void testChangingPasswordInvalidatesAllAccessTokens() {
    ByteBuffer username = getAcceptableUsername();
    ByteBuffer password = getSecurePassword();
    service.create(username, password, Role.ADMIN);
    List<AccessToken> tokens = Lists.newArrayList();
    for (int i = 0; i < TestData.getScaleCount(); i++) {
        tokens.add(service.tokens.issue(username));
    }
    service.setPassword(username, getSecurePassword());
    for (AccessToken token : tokens) {
        Assert.assertFalse(service.tokens.isValid(token));
    }
}
Also used : AccessToken(com.cinchapi.concourse.thrift.AccessToken) ByteBuffer(java.nio.ByteBuffer) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest) Test(org.junit.Test)

Example 68 with AccessToken

use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.

the class UserServiceTest method testServerTokenNotAutoExpire.

@Test
public void testServerTokenNotAutoExpire() {
    service = UserService.createForTesting(current, 100, TimeUnit.MILLISECONDS);
    AccessToken token = service.tokens.issueServiceToken();
    Threads.sleep(100);
    Assert.assertTrue(service.tokens.isValid(token));
}
Also used : AccessToken(com.cinchapi.concourse.thrift.AccessToken) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest) Test(org.junit.Test)

Example 69 with AccessToken

use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.

the class UserServiceTest method testCanCreateAccessTokenForValidUser.

@Test
public void testCanCreateAccessTokenForValidUser() {
    ByteBuffer username = getAcceptableUsername();
    ByteBuffer password = getSecurePassword();
    service.create(username, password, Role.ADMIN);
    AccessToken token = service.tokens.issue(username);
    Assert.assertTrue(service.tokens.isValid(token));
}
Also used : AccessToken(com.cinchapi.concourse.thrift.AccessToken) ByteBuffer(java.nio.ByteBuffer) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest) Test(org.junit.Test)

Example 70 with AccessToken

use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.

the class ConcurrentMapsTest method testWaitAndRemoveAfterDelay.

@Test
public void testWaitAndRemoveAfterDelay() throws InterruptedException {
    int sleep = ConcurrentMaps.SPIN_THRESHOLD_IN_MILLIS;
    ConcurrentMaps.SPIN_THRESHOLD_IN_MILLIS = 100;
    try {
        final ConcurrentMap<AccessToken, String> map = Maps.newConcurrentMap();
        String username = Random.getString();
        long salt = Random.getLong();
        long timestamp = Time.now();
        final AccessToken token0 = createAccessToken(username, salt, timestamp);
        final AtomicReference<String> actual = new AtomicReference<String>(null);
        final AtomicBoolean done = new AtomicBoolean(false);
        Thread waiter = new Thread(new Runnable() {

            @Override
            public void run() {
                actual.set(ConcurrentMaps.waitAndRemove(map, token0));
                done.set(true);
            }
        });
        waiter.start();
        AccessToken token = createAccessToken(username, salt, timestamp);
        Assert.assertNotSame(token0, token);
        String expected = Random.getString();
        Thread.sleep(101);
        ConcurrentMaps.putAndSignal(map, token, expected);
        while (!done.get()) {
            continue;
        }
        Assert.assertEquals(expected, actual.get());
    } finally {
        ConcurrentMaps.SPIN_THRESHOLD_IN_MILLIS = sleep;
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AccessToken(com.cinchapi.concourse.thrift.AccessToken) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.Test)

Aggregations

AccessToken (com.cinchapi.concourse.thrift.AccessToken)96 ByteBuffer (java.nio.ByteBuffer)72 TransactionToken (com.cinchapi.concourse.thrift.TransactionToken)60 TException (org.apache.thrift.TException)60 AtomicReference (java.util.concurrent.atomic.AtomicReference)56 AnyStrings (com.cinchapi.common.base.AnyStrings)55 CheckedExceptions (com.cinchapi.common.base.CheckedExceptions)55 Reflection (com.cinchapi.common.reflect.Reflection)55 Permission (com.cinchapi.concourse.security.Permission)55 Role (com.cinchapi.concourse.security.Role)55 Internal (com.cinchapi.concourse.server.aop.Internal)55 VerifyAccessToken (com.cinchapi.concourse.server.aop.VerifyAccessToken)55 VerifyReadPermission (com.cinchapi.concourse.server.aop.VerifyReadPermission)55 VerifyWritePermission (com.cinchapi.concourse.server.aop.VerifyWritePermission)55 FileSystem (com.cinchapi.concourse.server.io.FileSystem)55 ConcourseManagementService (com.cinchapi.concourse.server.management.ConcourseManagementService)55 PluginManager (com.cinchapi.concourse.server.plugin.PluginManager)55 AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)28 NaturalLanguage (com.cinchapi.ccl.util.NaturalLanguage)28 Array (com.cinchapi.common.base.Array)28