Add test for snowflake parameters.

This commit is contained in:
akwizgran
2022-09-28 16:18:08 +01:00
parent 32205ca6d3
commit b424d6f98e
2 changed files with 25 additions and 3 deletions

View File

@@ -94,7 +94,9 @@ class CircumventionProviderImpl implements CircumventionProvider {
return bridges;
}
private String getSnowflakeParams(String countryCode, boolean letsEncrypt) {
// Package access for testing
@SuppressWarnings("WeakerAccess")
String getSnowflakeParams(String countryCode, boolean letsEncrypt) {
Map<String, String> params = loadSnowflakeParams();
if (countryCode.isEmpty()) countryCode = DEFAULT_COUNTRY_CODE;
// If we have parameters for this country code, return them

View File

@@ -18,11 +18,13 @@ import static org.briarproject.bramble.plugin.tor.CircumventionProvider.DEFAULT_
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.DPI_BRIDGES;
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.NON_DEFAULT_BRIDGES;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
public class CircumventionProviderTest extends BrambleTestCase {
public class CircumventionProviderImplTest extends BrambleTestCase {
private final CircumventionProvider provider =
private final CircumventionProviderImpl provider =
new CircumventionProviderImpl();
@Test
@@ -64,6 +66,24 @@ public class CircumventionProviderTest extends BrambleTestCase {
provider.getSuitableBridgeTypes("ZZ"));
}
@Test
public void testHasSnowflakeParamsWithLetsEncrypt() {
testHasSnowflakeParams(true);
}
@Test
public void testHasSnowflakeParamsWithoutLetsEncrypt() {
testHasSnowflakeParams(false);
}
private void testHasSnowflakeParams(boolean letsEncrypt) {
String tmParams = provider.getSnowflakeParams("TM", letsEncrypt);
String defaultParams = provider.getSnowflakeParams("ZZ", letsEncrypt);
assertFalse(tmParams.isEmpty());
assertFalse(defaultParams.isEmpty());
assertNotEquals(defaultParams, tmParams);
}
private <T> void assertEmptyIntersection(Set<T> a, Set<T> b) {
Set<T> intersection = new HashSet<>(a);
intersection.retainAll(b);