Merge "Skip VPN filtering tests on unsupported versions"
This commit is contained in:
@@ -9505,7 +9505,7 @@ public class ConnectivityServiceTest {
|
|||||||
b2.expectBroadcast();
|
b2.expectBroadcast();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test @IgnoreUpTo(Build.VERSION_CODES.S_V2)
|
||||||
public void testLockdownSetFirewallUidRule() throws Exception {
|
public void testLockdownSetFirewallUidRule() throws Exception {
|
||||||
// For ConnectivityService#setAlwaysOnVpnPackage.
|
// For ConnectivityService#setAlwaysOnVpnPackage.
|
||||||
mServiceContext.setPermission(
|
mServiceContext.setPermission(
|
||||||
@@ -10428,7 +10428,7 @@ public class ConnectivityServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLegacyVpnSetInterfaceFilteringRuleWithWildcard() throws Exception {
|
public void testLegacyVpnInterfaceFilteringRule() throws Exception {
|
||||||
LinkProperties lp = new LinkProperties();
|
LinkProperties lp = new LinkProperties();
|
||||||
lp.setInterfaceName("tun0");
|
lp.setInterfaceName("tun0");
|
||||||
lp.addRoute(new RouteInfo(new IpPrefix(Inet6Address.ANY, 0), null));
|
lp.addRoute(new RouteInfo(new IpPrefix(Inet6Address.ANY, 0), null));
|
||||||
@@ -10438,10 +10438,11 @@ public class ConnectivityServiceTest {
|
|||||||
mMockVpn.establish(lp, Process.SYSTEM_UID, vpnRange);
|
mMockVpn.establish(lp, Process.SYSTEM_UID, vpnRange);
|
||||||
assertVpnUidRangesUpdated(true, vpnRange, Process.SYSTEM_UID);
|
assertVpnUidRangesUpdated(true, vpnRange, Process.SYSTEM_UID);
|
||||||
|
|
||||||
// A connected Legacy VPN should have interface rules with null interface.
|
if (SdkLevel.isAtLeastT()) {
|
||||||
// Null Interface is a wildcard and this accepts traffic from all the interfaces.
|
// On T and above, A connected Legacy VPN should have interface rules with null
|
||||||
// There are two expected invocations, one during the VPN initial connection,
|
// interface. Null Interface is a wildcard and this accepts traffic from all the
|
||||||
// one during the VPN LinkProperties update.
|
// interfaces. There are two expected invocations, one during the VPN initial
|
||||||
|
// connection, one during the VPN LinkProperties update.
|
||||||
ArgumentCaptor<int[]> uidCaptor = ArgumentCaptor.forClass(int[].class);
|
ArgumentCaptor<int[]> uidCaptor = ArgumentCaptor.forClass(int[].class);
|
||||||
verify(mBpfNetMaps, times(2)).addUidInterfaceRules(
|
verify(mBpfNetMaps, times(2)).addUidInterfaceRules(
|
||||||
eq(null) /* iface */, uidCaptor.capture());
|
eq(null) /* iface */, uidCaptor.capture());
|
||||||
@@ -10457,10 +10458,14 @@ public class ConnectivityServiceTest {
|
|||||||
verify(mBpfNetMaps).removeUidInterfaceRules(uidCaptor.capture());
|
verify(mBpfNetMaps).removeUidInterfaceRules(uidCaptor.capture());
|
||||||
assertContainsExactly(uidCaptor.getValue(), APP1_UID, APP2_UID, VPN_UID);
|
assertContainsExactly(uidCaptor.getValue(), APP1_UID, APP2_UID, VPN_UID);
|
||||||
assertNull(mService.mPermissionMonitor.getVpnInterfaceUidRanges(null /* iface */));
|
assertNull(mService.mPermissionMonitor.getVpnInterfaceUidRanges(null /* iface */));
|
||||||
|
} else {
|
||||||
|
// Before T, Legacy VPN should not have interface rules.
|
||||||
|
verify(mBpfNetMaps, never()).addUidInterfaceRules(any(), any());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLocalIpv4OnlyVpnSetInterfaceFilteringRuleWithWildcard() throws Exception {
|
public void testLocalIpv4OnlyVpnInterfaceFilteringRule() throws Exception {
|
||||||
LinkProperties lp = new LinkProperties();
|
LinkProperties lp = new LinkProperties();
|
||||||
lp.setInterfaceName("tun0");
|
lp.setInterfaceName("tun0");
|
||||||
lp.addRoute(new RouteInfo(new IpPrefix("192.0.2.0/24"), null, "tun0"));
|
lp.addRoute(new RouteInfo(new IpPrefix("192.0.2.0/24"), null, "tun0"));
|
||||||
@@ -10470,11 +10475,12 @@ public class ConnectivityServiceTest {
|
|||||||
mMockVpn.establish(lp, Process.SYSTEM_UID, vpnRange);
|
mMockVpn.establish(lp, Process.SYSTEM_UID, vpnRange);
|
||||||
assertVpnUidRangesUpdated(true, vpnRange, Process.SYSTEM_UID);
|
assertVpnUidRangesUpdated(true, vpnRange, Process.SYSTEM_UID);
|
||||||
|
|
||||||
|
if (SdkLevel.isAtLeastT()) {
|
||||||
// IPv6 unreachable route should not be misinterpreted as a default route
|
// IPv6 unreachable route should not be misinterpreted as a default route
|
||||||
// A connected VPN should have interface rules with null interface.
|
// On T and above, A connected VPN that does not provide a default route should have
|
||||||
// Null Interface is a wildcard and this accepts traffic from all the interfaces.
|
// interface rules with null interface. Null Interface is a wildcard and this accepts
|
||||||
// There are two expected invocations, one during the VPN initial connection,
|
// traffic from all the interfaces. There are two expected invocations, one during the
|
||||||
// one during the VPN LinkProperties update.
|
// VPN initial connection, one during the VPN LinkProperties update.
|
||||||
ArgumentCaptor<int[]> uidCaptor = ArgumentCaptor.forClass(int[].class);
|
ArgumentCaptor<int[]> uidCaptor = ArgumentCaptor.forClass(int[].class);
|
||||||
verify(mBpfNetMaps, times(2)).addUidInterfaceRules(
|
verify(mBpfNetMaps, times(2)).addUidInterfaceRules(
|
||||||
eq(null) /* iface */, uidCaptor.capture());
|
eq(null) /* iface */, uidCaptor.capture());
|
||||||
@@ -10490,6 +10496,10 @@ public class ConnectivityServiceTest {
|
|||||||
verify(mBpfNetMaps).removeUidInterfaceRules(uidCaptor.capture());
|
verify(mBpfNetMaps).removeUidInterfaceRules(uidCaptor.capture());
|
||||||
assertContainsExactly(uidCaptor.getValue(), APP1_UID, APP2_UID, VPN_UID);
|
assertContainsExactly(uidCaptor.getValue(), APP1_UID, APP2_UID, VPN_UID);
|
||||||
assertNull(mService.mPermissionMonitor.getVpnInterfaceUidRanges(null /* iface */));
|
assertNull(mService.mPermissionMonitor.getVpnInterfaceUidRanges(null /* iface */));
|
||||||
|
} else {
|
||||||
|
// Before T, VPN with IPv6 unreachable route should not have interface rules.
|
||||||
|
verify(mBpfNetMaps, never()).addUidInterfaceRules(any(), any());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user