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));
}
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));
}
}
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));
}
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));
}
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;
}
}
Aggregations