Merge "Add test to check socket close state after vpn connects" am: 57a3054e49
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2492636 Change-Id: I8b3b1a2a104bfebf8a8d197d89ef30b47bd2f56f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1273,6 +1273,31 @@ public class VpnTest {
|
||||
assertFalse(nc.hasTransport(TRANSPORT_VPN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSocketClosed() throws Exception {
|
||||
assumeTrue(supportedHardware());
|
||||
|
||||
final FileDescriptor localFd = openSocketFd(TEST_HOST, 80, TIMEOUT_MS);
|
||||
final List<FileDescriptor> remoteFds = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < 30; i++) {
|
||||
remoteFds.add(openSocketFdInOtherApp(TEST_HOST, 80, TIMEOUT_MS));
|
||||
}
|
||||
|
||||
final String allowedApps = mRemoteSocketFactoryClient.getPackageName() + "," + mPackageName;
|
||||
startVpn(new String[] {"192.0.2.2/32", "2001:db8:1:2::ffe/128"},
|
||||
new String[] {"192.0.2.0/24", "2001:db8::/32"},
|
||||
allowedApps, "", null, null /* underlyingNetworks */, false /* isAlwaysMetered */);
|
||||
|
||||
// Socket owned by VPN uid is not closed
|
||||
assertSocketStillOpen(localFd, TEST_HOST);
|
||||
|
||||
// Sockets not owned by VPN uid are closed
|
||||
for (final FileDescriptor remoteFd: remoteFds) {
|
||||
assertSocketClosed(remoteFd, TEST_HOST);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExcludedRoutes() throws Exception {
|
||||
assumeTrue(supportedHardware());
|
||||
|
||||
@@ -51,6 +51,10 @@ public class HostsideVpnTests extends HostsideNetworkTestCase {
|
||||
runDeviceTests(TEST_PKG, TEST_PKG + ".VpnTest", "testAppDisallowed");
|
||||
}
|
||||
|
||||
public void testSocketClosed() throws Exception {
|
||||
runDeviceTests(TEST_PKG, TEST_PKG + ".VpnTest", "testSocketClosed");
|
||||
}
|
||||
|
||||
public void testGetConnectionOwnerUidSecurity() throws Exception {
|
||||
runDeviceTests(TEST_PKG, TEST_PKG + ".VpnTest", "testGetConnectionOwnerUidSecurity");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user