Search in sources :

Example 1 with ACI

use of org.whispersystems.signalservice.api.push.ACI in project Signal-Android by WhisperSystems.

the class RecipientIdCacheTest method full_recipient_id_learned_by_two_puts.

@Test
public void full_recipient_id_learned_by_two_puts() {
    RecipientId recipientId1 = recipientId();
    ACI aci1 = ACI.from(UUID.randomUUID());
    String e164 = "+1555123456";
    recipientIdCache.put(recipient(recipientId1, aci1, null));
    recipientIdCache.put(recipient(recipientId1, null, e164));
    RecipientId recipientId = recipientIdCache.get(aci1, e164);
    assertEquals(recipientId1, recipientId);
}
Also used : ACI(org.whispersystems.signalservice.api.push.ACI) Test(org.junit.Test)

Example 2 with ACI

use of org.whispersystems.signalservice.api.push.ACI in project Signal-Android by WhisperSystems.

the class RecipientIdCacheTest method cache_hit_by_uuid.

@Test
public void cache_hit_by_uuid() {
    RecipientId recipientId1 = recipientId();
    ACI aci1 = ACI.from(UUID.randomUUID());
    recipientIdCache.put(recipient(recipientId1, aci1, null));
    RecipientId recipientId = recipientIdCache.get(aci1, null);
    assertEquals(recipientId1, recipientId);
}
Also used : ACI(org.whispersystems.signalservice.api.push.ACI) Test(org.junit.Test)

Example 3 with ACI

use of org.whispersystems.signalservice.api.push.ACI in project Signal-Android by WhisperSystems.

the class RecipientIdCacheTest method multiple_entries.

@Test
public void multiple_entries() {
    RecipientId recipientId1 = recipientId();
    RecipientId recipientId2 = recipientId();
    ACI aci1 = ACI.from(UUID.randomUUID());
    ACI aci2 = ACI.from(UUID.randomUUID());
    recipientIdCache.put(recipient(recipientId1, aci1, null));
    recipientIdCache.put(recipient(recipientId2, aci2, null));
    assertEquals(recipientId1, recipientIdCache.get(aci1, null));
    assertEquals(recipientId2, recipientIdCache.get(aci2, null));
}
Also used : ACI(org.whispersystems.signalservice.api.push.ACI) Test(org.junit.Test)

Example 4 with ACI

use of org.whispersystems.signalservice.api.push.ACI in project Signal-Android by WhisperSystems.

the class RecipientIdCacheTest method after_invalid_cache_hit_entries_are_cleared_up.

@Test
public void after_invalid_cache_hit_entries_are_cleared_up() {
    RecipientId recipientId1 = recipientId();
    RecipientId recipientId2 = recipientId();
    ACI aci = ACI.from(UUID.randomUUID());
    String e164 = "+1555123456";
    recipientIdCache.put(recipient(recipientId1, null, e164));
    recipientIdCache.put(recipient(recipientId2, aci, null));
    recipientIdCache.get(aci, e164);
    assertNull(recipientIdCache.get(aci, null));
    assertNull(recipientIdCache.get(null, e164));
}
Also used : ACI(org.whispersystems.signalservice.api.push.ACI) Test(org.junit.Test)

Example 5 with ACI

use of org.whispersystems.signalservice.api.push.ACI in project Signal-Android by WhisperSystems.

the class RecipientIdCacheTest method drops_oldest_when_reaches_cache_limit.

@Test
public void drops_oldest_when_reaches_cache_limit() {
    RecipientId recipientId1 = recipientId();
    ACI aci1 = ACI.from(UUID.randomUUID());
    recipientIdCache.put(recipient(recipientId1, aci1, null));
    for (int i = 0; i < TEST_CACHE_LIMIT; i++) {
        recipientIdCache.put(recipient(recipientId(), ACI.from(UUID.randomUUID()), null));
    }
    assertNull(recipientIdCache.get(aci1, null));
}
Also used : ACI(org.whispersystems.signalservice.api.push.ACI) Test(org.junit.Test)

Aggregations

ACI (org.whispersystems.signalservice.api.push.ACI)32 Test (org.junit.Test)13 IOException (java.io.IOException)7 WorkerThread (androidx.annotation.WorkerThread)6 HashMap (java.util.HashMap)5 NonNull (androidx.annotation.NonNull)4 ByteString (com.google.protobuf.ByteString)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 DataInputStream (java.io.DataInputStream)4 Map (java.util.Map)4 PNI (org.whispersystems.signalservice.api.push.PNI)4 ServiceResponse (org.whispersystems.signalservice.internal.ServiceResponse)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 SignatureException (java.security.SignatureException)3 Collections (java.util.Collections)3 HashSet (java.util.HashSet)3 List (java.util.List)3 UUID (java.util.UUID)3 RecipientDatabase (org.thoughtcrime.securesms.database.RecipientDatabase)3 UnauthenticatedResponseException (org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException)3