Search in sources :

Example 21 with ACI

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

the class RecipientIdCacheTest method if_cache_state_disagrees_returns_null.

@Test
public void if_cache_state_disagrees_returns_null() {
    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));
    RecipientId recipientId = recipientIdCache.get(aci, e164);
    assertNull(recipientId);
    assertEquals(1, logRecorder.getWarnings().size());
    assertEquals("Seen invalid RecipientIdCacheState", logRecorder.getWarnings().get(0).getMessage());
}
Also used : ACI(org.whispersystems.signalservice.api.push.ACI) Test(org.junit.Test)

Example 22 with ACI

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

the class RecipientIdCacheTest method cache_miss_by_e164_uuid_not_supplied_on_put.

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

Example 23 with ACI

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

the class RecipientIdCacheTest method cache_miss_by_uuid_e164_not_supplied_on_put.

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

Example 24 with ACI

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

the class RecipientIdCacheTest method cache_hit_by_uuid_e164_not_supplied_on_get.

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

Example 25 with ACI

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

the class RecipientIdCacheTest method cache_miss_by_uuid.

@Test
public void cache_miss_by_uuid() {
    RecipientId recipientId1 = recipientId();
    ACI aci1 = ACI.from(UUID.randomUUID());
    ACI aci2 = ACI.from(UUID.randomUUID());
    recipientIdCache.put(recipient(recipientId1, aci1, null));
    RecipientId recipientId = recipientIdCache.get(aci2, null);
    assertNull(recipientId);
}
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