use of com.palantir.lock.ConjureLockRefreshToken in project atlasdb by palantir.
the class ConjureLockV1ResourceTest method multipleTokensAreTranslatedInSequence.
@Test
public void multipleTokensAreTranslatedInSequence() {
long expirationDateMs = 585L;
ConjureLockRefreshToken otherToken = ConjureLockRefreshToken.of(BigInteger.ZERO, expirationDateMs);
assertThat(ConjureLockV1Tokens.getLegacyTokens(ImmutableList.of(CONJURE_TOKEN, otherToken))).containsExactly(LEGACY_TOKEN, new LockRefreshToken(BigInteger.ZERO, expirationDateMs));
}
use of com.palantir.lock.ConjureLockRefreshToken in project atlasdb by palantir.
the class ConjureLockV1ResourceTest method multipleTokensAreTranslatedInSequence.
@Test
public void multipleTokensAreTranslatedInSequence() {
long expirationDateMs = 585L;
ConjureLockRefreshToken otherToken = ConjureLockRefreshToken.of(BigInteger.ZERO, expirationDateMs);
assertThat(ConjureLockV1Tokens.getLegacyTokens(ImmutableList.of(CONJURE_TOKEN, otherToken))).containsExactly(LEGACY_TOKEN, new LockRefreshToken(BigInteger.ZERO, expirationDateMs));
}
use of com.palantir.lock.ConjureLockRefreshToken in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method directLegacyAndConjureLockServicesInteractCorrectly.
@Test
public void directLegacyAndConjureLockServicesInteractCorrectly() throws InterruptedException {
LockRefreshToken token = client.legacyLockService().lock("tom", com.palantir.lock.LockRequest.builder(ImmutableSortedMap.<LockDescriptor, LockMode>naturalOrder().put(StringLockDescriptor.of("lock"), LockMode.WRITE).build()).build());
ConjureLockRefreshToken conjureAnalogue = ConjureLockRefreshToken.of(token.getTokenId(), token.getExpirationDateMs());
// Cannot assert equality because tokens can have different expiration dates.
assertThat(client.legacyLockService().refreshLockRefreshTokens(ImmutableList.of(token))).as("refreshing a live token should succeed").hasOnlyOneElementSatisfying(refreshed -> assertThat(refreshed.getTokenId()).isEqualTo(refreshed.getTokenId()));
AuthHeader authHeader = AuthHeader.valueOf("Bearer unused");
assertThat(client.conjureLegacyLockService().refreshLockRefreshTokens(authHeader, client.namespace(), ImmutableList.of(conjureAnalogue))).as("it is possible to refresh a live token through the conjure API").hasOnlyOneElementSatisfying(refreshed -> assertThat(refreshed.getTokenId()).isEqualTo(refreshed.getTokenId()));
ConjureSimpleHeldLocksToken conjureHeldLocksToken = ConjureSimpleHeldLocksToken.of(token.getTokenId(), 0L);
assertThat(client.conjureLegacyLockService().unlockSimple(authHeader, client.namespace(), conjureHeldLocksToken)).as("it is possible to unlock a live token through the conjure API").isTrue();
assertThat(client.conjureLegacyLockService().unlockSimple(authHeader, client.namespace(), conjureHeldLocksToken)).as("a token unlocked through the conjure API stays unlocked").isFalse();
assertThat(client.legacyLockService().unlockSimple(SimpleHeldLocksToken.fromLockRefreshToken(token))).as("a token unlocked through the conjure API stays unlocked even in the legacy API").isFalse();
}
Aggregations