mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-09 16:30:19 +00:00
Remove call log permissions, use SMS Retriever API during registration.
This is to adhere to the Play Store policy updates. See: https://play.google.com/about/privacy-security-deception/permissions/
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
package org.thoughtcrime.securesms.service;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.thoughtcrime.securesms.BaseUnitTest;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.contains;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class SmsListenerTest extends BaseUnitTest {
|
||||
public class VerificationCodeParserTest extends BaseUnitTest {
|
||||
private static Map<String, String> CHALLENGES = new HashMap<String,String>() {{
|
||||
put("Your TextSecure verification code: 337-337", "337337");
|
||||
put("XXX\nYour TextSecure verification code: 1337-1337", "13371337");
|
||||
@@ -34,25 +34,28 @@ public class SmsListenerTest extends BaseUnitTest {
|
||||
put("XXXYour Signal verification code: 1337-1337", "13371337");
|
||||
put("Your Signal verification code: 1337-1337XXX", "13371337");
|
||||
put("Your Signal verification code 1337-1337", "13371337");
|
||||
}};
|
||||
|
||||
private SmsListener listener;
|
||||
put("<#>Your Signal verification code: 1337-1337 aAbBcCdDeEf", "13371337");
|
||||
put("<#> Your Signal verification code: 1337-1337 aAbBcCdDeEf", "13371337");
|
||||
put("<#>Your Signal verification code: 1337-1337\naAbBcCdDeEf", "13371337");
|
||||
put("<#> Your Signal verification code: 1337-1337\naAbBcCdDeEf", "13371337");
|
||||
put("<#> Your Signal verification code: 1337-1337\n\naAbBcCdDeEf", "13371337");
|
||||
}};
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
listener = new SmsListener();
|
||||
when(sharedPreferences.getBoolean(contains("pref_verifying"), anyBoolean())).thenReturn(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChallenges() throws Exception {
|
||||
public void testChallenges() {
|
||||
for (Entry<String,String> challenge : CHALLENGES.entrySet()) {
|
||||
if (!listener.isChallenge(context, challenge.getKey())) {
|
||||
throw new AssertionFailedError("SmsListener didn't recognize body as a challenge.");
|
||||
}
|
||||
assertEquals(listener.parseChallenge(challenge.getKey()), challenge.getValue());
|
||||
Optional<String> result = VerificationCodeParser.parse(context, challenge.getKey());
|
||||
|
||||
assertTrue(result.isPresent());
|
||||
assertEquals(result.get(), challenge.getValue());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user