Merge "Skip unreachable route when estimating VPN destinations" am: e26fb9d574 am: fab8b096c3

am: dcdc2174af

Change-Id: Id81038035eddf98d0c4546ddb25c8f6ed5736ad6
This commit is contained in:
Rubin Xu
2019-02-20 04:35:38 -08:00
committed by android-build-merger

View File

@@ -28,6 +28,7 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING;
import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
import static android.net.NetworkCapabilities.TRANSPORT_VPN;
import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
import static android.net.RouteInfo.RTN_UNREACHABLE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -89,6 +90,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -775,6 +777,16 @@ public class VpnTest {
// V4 does not, but V6 has sufficient coverage again
lp.addRoute(new RouteInfo(new IpPrefix("::/1")));
assertTrue(Vpn.providesRoutesToMostDestinations(lp));
lp.clear();
// V4-unreachable route should not be treated as sufficient coverage
lp.addRoute(new RouteInfo(new IpPrefix(Inet4Address.ANY, 0), RTN_UNREACHABLE));
assertFalse(Vpn.providesRoutesToMostDestinations(lp));
lp.clear();
// V6-unreachable route should not be treated as sufficient coverage
lp.addRoute(new RouteInfo(new IpPrefix(Inet6Address.ANY, 0), RTN_UNREACHABLE));
assertFalse(Vpn.providesRoutesToMostDestinations(lp));
}
@Test