Search in sources :

Example 1 with ConjureLockRefreshToken

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));
}
Also used : ConjureLockRefreshToken(com.palantir.lock.ConjureLockRefreshToken) ConjureLockRefreshToken(com.palantir.lock.ConjureLockRefreshToken) LockRefreshToken(com.palantir.lock.LockRefreshToken) Test(org.junit.Test)

Example 2 with ConjureLockRefreshToken

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));
}
Also used : ConjureLockRefreshToken(com.palantir.lock.ConjureLockRefreshToken) ConjureLockRefreshToken(com.palantir.lock.ConjureLockRefreshToken) LockRefreshToken(com.palantir.lock.LockRefreshToken) Test(org.junit.Test)

Example 3 with ConjureLockRefreshToken

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();
}
Also used : AuthHeader(com.palantir.tokens.auth.AuthHeader) ConjureSimpleHeldLocksToken(com.palantir.lock.ConjureSimpleHeldLocksToken) ConjureLockRefreshToken(com.palantir.lock.ConjureLockRefreshToken) ConjureLockRefreshToken(com.palantir.lock.ConjureLockRefreshToken) LockRefreshToken(com.palantir.lock.LockRefreshToken) Test(org.junit.Test)

Aggregations

ConjureLockRefreshToken (com.palantir.lock.ConjureLockRefreshToken)3 LockRefreshToken (com.palantir.lock.LockRefreshToken)3 Test (org.junit.Test)3 ConjureSimpleHeldLocksToken (com.palantir.lock.ConjureSimpleHeldLocksToken)1 AuthHeader (com.palantir.tokens.auth.AuthHeader)1