mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-25 19:29:54 +01:00
Improve proxy link parsing.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class SignalProxyUtilText_convertUserEnteredAddressToHost {
|
||||
|
||||
private final String input;
|
||||
private final String output;
|
||||
|
||||
@Parameterized.Parameters
|
||||
public static Collection<Object[]> data() {
|
||||
return Arrays.asList(new Object[][]{
|
||||
{ "https://signal.tube/#proxy.parker.org", "proxy.parker.org" },
|
||||
{ "https://signal.tube/#proxy.parker.org:443", "proxy.parker.org" },
|
||||
{ "sgnl://signal.tube/#proxy.parker.org", "proxy.parker.org" },
|
||||
{ "sgnl://signal.tube/#proxy.parker.org:443", "proxy.parker.org" },
|
||||
{ "proxy.parker.org", "proxy.parker.org" },
|
||||
{ "proxy.parker.org:443", "proxy.parker.org" },
|
||||
{ "x", "x" },
|
||||
{ "", "" }
|
||||
});
|
||||
}
|
||||
|
||||
public SignalProxyUtilText_convertUserEnteredAddressToHost(String input, String output) {
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parse() {
|
||||
assertEquals(output, SignalProxyUtil.convertUserEnteredAddressToHost(input));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class SignalProxyUtilText_generateProxyUrl {
|
||||
|
||||
private final String input;
|
||||
private final String output;
|
||||
|
||||
@Parameterized.Parameters
|
||||
public static Collection<Object[]> data() {
|
||||
return Arrays.asList(new Object[][]{
|
||||
{ "https://signal.tube/#proxy.parker.org", "https://signal.tube/#proxy.parker.org" },
|
||||
{ "https://signal.tube/#proxy.parker.org:443", "https://signal.tube/#proxy.parker.org" },
|
||||
{ "sgnl://signal.tube/#proxy.parker.org", "https://signal.tube/#proxy.parker.org" },
|
||||
{ "sgnl://signal.tube/#proxy.parker.org:443", "https://signal.tube/#proxy.parker.org" },
|
||||
{ "proxy.parker.org", "https://signal.tube/#proxy.parker.org" },
|
||||
{ "proxy.parker.org:443", "https://signal.tube/#proxy.parker.org" },
|
||||
{ "x", "https://signal.tube/#x" },
|
||||
{ "", "https://signal.tube/#" }
|
||||
});
|
||||
}
|
||||
|
||||
public SignalProxyUtilText_generateProxyUrl(String input, String output) {
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parse() {
|
||||
assertEquals(output, SignalProxyUtil.generateProxyUrl(input));
|
||||
}
|
||||
}
|
||||
@@ -18,16 +18,18 @@ public class SignalProxyUtilText_parseHostFromProxyDeepLink {
|
||||
@Parameterized.Parameters
|
||||
public static Collection<Object[]> data() {
|
||||
return Arrays.asList(new Object[][]{
|
||||
{ "https://signal.tube/#proxy.parker.org", "proxy.parker.org" },
|
||||
{ "sgnl://signal.tube/#proxy.parker.org", "proxy.parker.org" },
|
||||
{ "https://signal.tube/", null },
|
||||
{ "https://signal.tube/#", null },
|
||||
{ "sgnl://signal.tube/", null },
|
||||
{ "sgnl://signal.tube/#", null },
|
||||
{ "http://signal.tube/#proxy.parker.org", null },
|
||||
{ "signal.tube/#proxy.parker.org", null },
|
||||
{ "", null },
|
||||
{ null, null }
|
||||
{ "https://signal.tube/#proxy.parker.org", "proxy.parker.org" },
|
||||
{ "https://signal.tube/#proxy.parker.org:443", "proxy.parker.org" },
|
||||
{ "sgnl://signal.tube/#proxy.parker.org", "proxy.parker.org" },
|
||||
{ "sgnl://signal.tube/#proxy.parker.org:443", "proxy.parker.org" },
|
||||
{ "https://signal.tube/", null },
|
||||
{ "https://signal.tube/#", null },
|
||||
{ "sgnl://signal.tube/", null },
|
||||
{ "sgnl://signal.tube/#", null },
|
||||
{ "http://signal.tube/#proxy.parker.org", null },
|
||||
{ "signal.tube/#proxy.parker.org", null },
|
||||
{ "", null },
|
||||
{ null, null }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user