Test if underlying networks are the same as what VpnService sets
If VpnService set null as the underlying networks, then the underlying networks will be set as system defeult network. If VpnService set an empty array as the underlying networks, then the underlying networks of VPN will not be set to any networks. If VpnService set a network which is not null or an empty array, then the underlying networks of VPN should be the same as this one. Bug: 191918368 Test: atest CtsHostsideNetworkTests:HostsideVpnTests Change-Id: Ib2d54e53960e5f899cb8d4cfaa6705ca676354ca
This commit is contained in:
parent
d2de904def
commit
cacd5b0d2a
1 changed files with 42 additions and 0 deletions
|
|
@ -785,6 +785,15 @@ public class VpnTest {
|
|||
maybeExpectVpnTransportInfo(vpnNetwork);
|
||||
assertEquals(TYPE_VPN, mCM.getNetworkInfo(vpnNetwork).getType());
|
||||
|
||||
if (SdkLevel.isAtLeastT()) {
|
||||
runWithShellPermissionIdentity(() -> {
|
||||
final NetworkCapabilities nc = mCM.getNetworkCapabilities(vpnNetwork);
|
||||
assertNotNull(nc);
|
||||
assertNotNull(nc.getUnderlyingNetworks());
|
||||
assertEquals(defaultNetwork, new ArrayList<>(nc.getUnderlyingNetworks()).get(0));
|
||||
}, NETWORK_SETTINGS);
|
||||
}
|
||||
|
||||
if (SdkLevel.isAtLeastS()) {
|
||||
// Check that system default network callback has not seen any network changes, even
|
||||
// though the app's default network changed. Also check that otherUidCallback saw no
|
||||
|
|
@ -1017,6 +1026,15 @@ public class VpnTest {
|
|||
assertTrue(mCM.isActiveNetworkMetered());
|
||||
|
||||
maybeExpectVpnTransportInfo(mCM.getActiveNetwork());
|
||||
|
||||
if (SdkLevel.isAtLeastT()) {
|
||||
runWithShellPermissionIdentity(() -> {
|
||||
final NetworkCapabilities nc = mCM.getNetworkCapabilities(mNetwork);
|
||||
assertNotNull(nc);
|
||||
assertNotNull(nc.getUnderlyingNetworks());
|
||||
assertEquals(underlyingNetworks, new ArrayList<>(nc.getUnderlyingNetworks()));
|
||||
}, NETWORK_SETTINGS);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1076,6 +1094,18 @@ public class VpnTest {
|
|||
assertEquals(isNetworkMetered(mNetwork), mCM.isActiveNetworkMetered());
|
||||
|
||||
maybeExpectVpnTransportInfo(mCM.getActiveNetwork());
|
||||
|
||||
if (SdkLevel.isAtLeastT()) {
|
||||
final Network vpnNetwork = mCM.getActiveNetwork();
|
||||
assertNotEqual(underlyingNetwork, vpnNetwork);
|
||||
runWithShellPermissionIdentity(() -> {
|
||||
final NetworkCapabilities nc = mCM.getNetworkCapabilities(vpnNetwork);
|
||||
assertNotNull(nc);
|
||||
assertNotNull(nc.getUnderlyingNetworks());
|
||||
final List<Network> underlying = nc.getUnderlyingNetworks();
|
||||
assertEquals(underlyingNetwork, underlying.get(0));
|
||||
}, NETWORK_SETTINGS);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1131,6 +1161,18 @@ public class VpnTest {
|
|||
assertTrue(mCM.isActiveNetworkMetered());
|
||||
|
||||
maybeExpectVpnTransportInfo(mCM.getActiveNetwork());
|
||||
|
||||
if (SdkLevel.isAtLeastT()) {
|
||||
final Network vpnNetwork = mCM.getActiveNetwork();
|
||||
assertNotEqual(underlyingNetwork, vpnNetwork);
|
||||
runWithShellPermissionIdentity(() -> {
|
||||
final NetworkCapabilities nc = mCM.getNetworkCapabilities(vpnNetwork);
|
||||
assertNotNull(nc);
|
||||
assertNotNull(nc.getUnderlyingNetworks());
|
||||
final List<Network> underlying = nc.getUnderlyingNetworks();
|
||||
assertEquals(underlyingNetwork, underlying.get(0));
|
||||
}, NETWORK_SETTINGS);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in a new issue