Verify the update of shouldLongLivedTcpExcluded in VpnTransportInfo
Bug: 273422889 Test: atest FrameworksNetTests Change-Id: I5e25d1b8b1f86dc4474cef1616cb16668119240a
This commit is contained in:
@@ -48,6 +48,7 @@ import static android.telephony.CarrierConfigManager.KEY_PREFERRED_IKE_PROTOCOL_
|
|||||||
|
|
||||||
import static com.android.net.module.util.NetworkStackConstants.IPV6_MIN_MTU;
|
import static com.android.net.module.util.NetworkStackConstants.IPV6_MIN_MTU;
|
||||||
import static com.android.server.connectivity.Vpn.AUTOMATIC_KEEPALIVE_DELAY_SECONDS;
|
import static com.android.server.connectivity.Vpn.AUTOMATIC_KEEPALIVE_DELAY_SECONDS;
|
||||||
|
import static com.android.server.connectivity.Vpn.DEFAULT_LONG_LIVED_TCP_CONNS_EXPENSIVE_TIMEOUT_SEC;
|
||||||
import static com.android.server.connectivity.Vpn.DEFAULT_UDP_PORT_4500_NAT_TIMEOUT_SEC_INT;
|
import static com.android.server.connectivity.Vpn.DEFAULT_UDP_PORT_4500_NAT_TIMEOUT_SEC_INT;
|
||||||
import static com.android.server.connectivity.Vpn.PREFERRED_IKE_PROTOCOL_AUTO;
|
import static com.android.server.connectivity.Vpn.PREFERRED_IKE_PROTOCOL_AUTO;
|
||||||
import static com.android.server.connectivity.Vpn.PREFERRED_IKE_PROTOCOL_IPV4_UDP;
|
import static com.android.server.connectivity.Vpn.PREFERRED_IKE_PROTOCOL_IPV4_UDP;
|
||||||
@@ -1860,6 +1861,13 @@ public class VpnTest extends VpnTestBase {
|
|||||||
|
|
||||||
private PlatformVpnSnapshot verifySetupPlatformVpn(VpnProfile vpnProfile,
|
private PlatformVpnSnapshot verifySetupPlatformVpn(VpnProfile vpnProfile,
|
||||||
IkeSessionConfiguration ikeConfig, boolean mtuSupportsIpv6) throws Exception {
|
IkeSessionConfiguration ikeConfig, boolean mtuSupportsIpv6) throws Exception {
|
||||||
|
return verifySetupPlatformVpn(vpnProfile, ikeConfig, mtuSupportsIpv6,
|
||||||
|
false /* areLongLivedTcpConnectionsExpensive */);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PlatformVpnSnapshot verifySetupPlatformVpn(VpnProfile vpnProfile,
|
||||||
|
IkeSessionConfiguration ikeConfig, boolean mtuSupportsIpv6,
|
||||||
|
boolean areLongLivedTcpConnectionsExpensive) throws Exception {
|
||||||
if (!mtuSupportsIpv6) {
|
if (!mtuSupportsIpv6) {
|
||||||
doReturn(IPV6_MIN_MTU - 1).when(mTestDeps).calculateVpnMtu(any(), anyInt(), anyInt(),
|
doReturn(IPV6_MIN_MTU - 1).when(mTestDeps).calculateVpnMtu(any(), anyInt(), anyInt(),
|
||||||
anyBoolean());
|
anyBoolean());
|
||||||
@@ -1942,8 +1950,10 @@ public class VpnTest extends VpnTestBase {
|
|||||||
|
|
||||||
// Check if allowBypass is set or not.
|
// Check if allowBypass is set or not.
|
||||||
assertTrue(nacCaptor.getValue().isBypassableVpn());
|
assertTrue(nacCaptor.getValue().isBypassableVpn());
|
||||||
assertTrue(((VpnTransportInfo) ncCaptor.getValue().getTransportInfo()).isBypassable());
|
final VpnTransportInfo info = (VpnTransportInfo) ncCaptor.getValue().getTransportInfo();
|
||||||
|
assertTrue(info.isBypassable());
|
||||||
|
assertEquals(areLongLivedTcpConnectionsExpensive,
|
||||||
|
info.areLongLivedTcpConnectionsExpensive());
|
||||||
return new PlatformVpnSnapshot(vpn, nwCb, ikeCb, childCb);
|
return new PlatformVpnSnapshot(vpn, nwCb, ikeCb, childCb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2069,7 +2079,8 @@ public class VpnTest extends VpnTestBase {
|
|||||||
final PlatformVpnSnapshot vpnSnapShot =
|
final PlatformVpnSnapshot vpnSnapShot =
|
||||||
verifySetupPlatformVpn(profile,
|
verifySetupPlatformVpn(profile,
|
||||||
createIkeConfig(createIkeConnectInfo(), true /* isMobikeEnabled */),
|
createIkeConfig(createIkeConnectInfo(), true /* isMobikeEnabled */),
|
||||||
false /* mtuSupportsIpv6 */);
|
false /* mtuSupportsIpv6 */,
|
||||||
|
expectedKeepalive < DEFAULT_LONG_LIVED_TCP_CONNS_EXPENSIVE_TIMEOUT_SEC);
|
||||||
// Simulate a new network coming up
|
// Simulate a new network coming up
|
||||||
vpnSnapShot.nwCb.onAvailable(TEST_NETWORK_2);
|
vpnSnapShot.nwCb.onAvailable(TEST_NETWORK_2);
|
||||||
verify(mIkeSessionWrapper, never()).setNetwork(any(), anyInt(), anyInt(), anyInt());
|
verify(mIkeSessionWrapper, never()).setNetwork(any(), anyInt(), anyInt(), anyInt());
|
||||||
@@ -2116,7 +2127,9 @@ public class VpnTest extends VpnTestBase {
|
|||||||
PREFERRED_IKE_PROTOCOL_IPV4_UDP,
|
PREFERRED_IKE_PROTOCOL_IPV4_UDP,
|
||||||
AUTOMATIC_KEEPALIVE_DELAY_SECONDS /* expectedKeepaliveTimer */,
|
AUTOMATIC_KEEPALIVE_DELAY_SECONDS /* expectedKeepaliveTimer */,
|
||||||
ESP_IP_VERSION_AUTO /* expectedIpVersion */,
|
ESP_IP_VERSION_AUTO /* expectedIpVersion */,
|
||||||
ESP_ENCAP_TYPE_AUTO /* expectedEncapType */);
|
ESP_ENCAP_TYPE_AUTO /* expectedEncapType */,
|
||||||
|
false /* expectedReadFromCarrierConfig*/,
|
||||||
|
true /* areLongLivedTcpConnectionsExpensive */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -2126,7 +2139,9 @@ public class VpnTest extends VpnTestBase {
|
|||||||
PREFERRED_IKE_PROTOCOL_IPV4_UDP,
|
PREFERRED_IKE_PROTOCOL_IPV4_UDP,
|
||||||
AUTOMATIC_KEEPALIVE_DELAY_SECONDS /* expectedKeepaliveTimer */,
|
AUTOMATIC_KEEPALIVE_DELAY_SECONDS /* expectedKeepaliveTimer */,
|
||||||
ESP_IP_VERSION_AUTO /* expectedIpVersion */,
|
ESP_IP_VERSION_AUTO /* expectedIpVersion */,
|
||||||
ESP_ENCAP_TYPE_AUTO /* expectedEncapType */);
|
ESP_ENCAP_TYPE_AUTO /* expectedEncapType */,
|
||||||
|
false /* expectedReadFromCarrierConfig*/,
|
||||||
|
true /* areLongLivedTcpConnectionsExpensive */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -2136,7 +2151,9 @@ public class VpnTest extends VpnTestBase {
|
|||||||
PREFERRED_IKE_PROTOCOL_AUTO,
|
PREFERRED_IKE_PROTOCOL_AUTO,
|
||||||
TEST_KEEPALIVE_TIMER /* expectedKeepaliveTimer */,
|
TEST_KEEPALIVE_TIMER /* expectedKeepaliveTimer */,
|
||||||
ESP_IP_VERSION_AUTO /* expectedIpVersion */,
|
ESP_IP_VERSION_AUTO /* expectedIpVersion */,
|
||||||
ESP_ENCAP_TYPE_AUTO /* expectedEncapType */);
|
ESP_ENCAP_TYPE_AUTO /* expectedEncapType */,
|
||||||
|
true /* expectedReadFromCarrierConfig*/,
|
||||||
|
false /* areLongLivedTcpConnectionsExpensive */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -2150,7 +2167,9 @@ public class VpnTest extends VpnTestBase {
|
|||||||
PREFERRED_IKE_PROTOCOL_IPV4_UDP,
|
PREFERRED_IKE_PROTOCOL_IPV4_UDP,
|
||||||
AUTOMATIC_KEEPALIVE_DELAY_SECONDS /* expectedKeepaliveTimer */,
|
AUTOMATIC_KEEPALIVE_DELAY_SECONDS /* expectedKeepaliveTimer */,
|
||||||
ESP_IP_VERSION_AUTO /* expectedIpVersion */,
|
ESP_IP_VERSION_AUTO /* expectedIpVersion */,
|
||||||
ESP_ENCAP_TYPE_AUTO /* expectedEncapType */);
|
ESP_ENCAP_TYPE_AUTO /* expectedEncapType */,
|
||||||
|
false /* expectedReadFromCarrierConfig*/,
|
||||||
|
true /* areLongLivedTcpConnectionsExpensive */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -2160,7 +2179,9 @@ public class VpnTest extends VpnTestBase {
|
|||||||
PREFERRED_IKE_PROTOCOL_IPV4_UDP,
|
PREFERRED_IKE_PROTOCOL_IPV4_UDP,
|
||||||
TEST_KEEPALIVE_TIMER /* expectedKeepaliveTimer */,
|
TEST_KEEPALIVE_TIMER /* expectedKeepaliveTimer */,
|
||||||
ESP_IP_VERSION_IPV4 /* expectedIpVersion */,
|
ESP_IP_VERSION_IPV4 /* expectedIpVersion */,
|
||||||
ESP_ENCAP_TYPE_UDP /* expectedEncapType */);
|
ESP_ENCAP_TYPE_UDP /* expectedEncapType */,
|
||||||
|
true /* expectedReadFromCarrierConfig*/,
|
||||||
|
false /* areLongLivedTcpConnectionsExpensive */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -2170,7 +2191,9 @@ public class VpnTest extends VpnTestBase {
|
|||||||
PREFERRED_IKE_PROTOCOL_IPV6_ESP,
|
PREFERRED_IKE_PROTOCOL_IPV6_ESP,
|
||||||
TEST_KEEPALIVE_TIMER /* expectedKeepaliveTimer */,
|
TEST_KEEPALIVE_TIMER /* expectedKeepaliveTimer */,
|
||||||
ESP_IP_VERSION_IPV6 /* expectedIpVersion */,
|
ESP_IP_VERSION_IPV6 /* expectedIpVersion */,
|
||||||
ESP_ENCAP_TYPE_NONE /* expectedEncapType */);
|
ESP_ENCAP_TYPE_NONE /* expectedEncapType */,
|
||||||
|
true /* expectedReadFromCarrierConfig*/,
|
||||||
|
false /* areLongLivedTcpConnectionsExpensive */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -2180,7 +2203,9 @@ public class VpnTest extends VpnTestBase {
|
|||||||
PREFERRED_IKE_PROTOCOL_IPV6_UDP,
|
PREFERRED_IKE_PROTOCOL_IPV6_UDP,
|
||||||
TEST_KEEPALIVE_TIMER /* expectedKeepaliveTimer */,
|
TEST_KEEPALIVE_TIMER /* expectedKeepaliveTimer */,
|
||||||
ESP_IP_VERSION_IPV6 /* expectedIpVersion */,
|
ESP_IP_VERSION_IPV6 /* expectedIpVersion */,
|
||||||
ESP_ENCAP_TYPE_UDP /* expectedEncapType */);
|
ESP_ENCAP_TYPE_UDP /* expectedEncapType */,
|
||||||
|
true /* expectedReadFromCarrierConfig*/,
|
||||||
|
false /* areLongLivedTcpConnectionsExpensive */);
|
||||||
}
|
}
|
||||||
|
|
||||||
private NetworkCapabilities createTestCellNc() {
|
private NetworkCapabilities createTestCellNc() {
|
||||||
@@ -2193,7 +2218,9 @@ public class VpnTest extends VpnTestBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void doTestReadCarrierConfig(NetworkCapabilities nc, int simState, int preferredIpProto,
|
private void doTestReadCarrierConfig(NetworkCapabilities nc, int simState, int preferredIpProto,
|
||||||
int expectedKeepaliveTimer, int expectedIpVersion, int expectedEncapType)
|
int expectedKeepaliveTimer, int expectedIpVersion, int expectedEncapType,
|
||||||
|
boolean expectedReadFromCarrierConfig,
|
||||||
|
boolean areLongLivedTcpConnectionsExpensive)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
final Ikev2VpnProfile ikeProfile =
|
final Ikev2VpnProfile ikeProfile =
|
||||||
new Ikev2VpnProfile.Builder(TEST_VPN_SERVER, TEST_VPN_IDENTITY)
|
new Ikev2VpnProfile.Builder(TEST_VPN_SERVER, TEST_VPN_IDENTITY)
|
||||||
@@ -2206,7 +2233,8 @@ public class VpnTest extends VpnTestBase {
|
|||||||
final PlatformVpnSnapshot vpnSnapShot =
|
final PlatformVpnSnapshot vpnSnapShot =
|
||||||
verifySetupPlatformVpn(ikeProfile.toVpnProfile(),
|
verifySetupPlatformVpn(ikeProfile.toVpnProfile(),
|
||||||
createIkeConfig(createIkeConnectInfo(), true /* isMobikeEnabled */),
|
createIkeConfig(createIkeConnectInfo(), true /* isMobikeEnabled */),
|
||||||
false /* mtuSupportsIpv6 */);
|
false /* mtuSupportsIpv6 */,
|
||||||
|
true /* areLongLivedTcpConnectionsExpensive */);
|
||||||
|
|
||||||
final CarrierConfigManager.CarrierConfigChangeListener listener =
|
final CarrierConfigManager.CarrierConfigChangeListener listener =
|
||||||
getCarrierConfigListener();
|
getCarrierConfigListener();
|
||||||
@@ -2221,15 +2249,31 @@ public class VpnTest extends VpnTestBase {
|
|||||||
vpnSnapShot.nwCb.onCapabilitiesChanged(TEST_NETWORK_2, nc);
|
vpnSnapShot.nwCb.onCapabilitiesChanged(TEST_NETWORK_2, nc);
|
||||||
verify(mIkeSessionWrapper).setNetwork(TEST_NETWORK_2,
|
verify(mIkeSessionWrapper).setNetwork(TEST_NETWORK_2,
|
||||||
expectedIpVersion, expectedEncapType, expectedKeepaliveTimer);
|
expectedIpVersion, expectedEncapType, expectedKeepaliveTimer);
|
||||||
|
if (expectedReadFromCarrierConfig) {
|
||||||
|
final ArgumentCaptor<NetworkCapabilities> ncCaptor =
|
||||||
|
ArgumentCaptor.forClass(NetworkCapabilities.class);
|
||||||
|
verify(mMockNetworkAgent).doSendNetworkCapabilities(ncCaptor.capture());
|
||||||
|
|
||||||
|
final VpnTransportInfo info =
|
||||||
|
(VpnTransportInfo) ncCaptor.getValue().getTransportInfo();
|
||||||
|
assertEquals(areLongLivedTcpConnectionsExpensive,
|
||||||
|
info.areLongLivedTcpConnectionsExpensive());
|
||||||
|
} else {
|
||||||
|
verify(mMockNetworkAgent, never()).doSendNetworkCapabilities(any());
|
||||||
|
}
|
||||||
|
|
||||||
reset(mExecutor);
|
reset(mExecutor);
|
||||||
reset(mIkeSessionWrapper);
|
reset(mIkeSessionWrapper);
|
||||||
|
reset(mMockNetworkAgent);
|
||||||
|
|
||||||
// Trigger carrier config change
|
// Trigger carrier config change
|
||||||
listener.onCarrierConfigChanged(1 /* logicalSlotIndex */, TEST_SUB_ID,
|
listener.onCarrierConfigChanged(1 /* logicalSlotIndex */, TEST_SUB_ID,
|
||||||
-1 /* carrierId */, -1 /* specificCarrierId */);
|
-1 /* carrierId */, -1 /* specificCarrierId */);
|
||||||
verify(mIkeSessionWrapper).setNetwork(TEST_NETWORK_2,
|
verify(mIkeSessionWrapper).setNetwork(TEST_NETWORK_2,
|
||||||
expectedIpVersion, expectedEncapType, expectedKeepaliveTimer);
|
expectedIpVersion, expectedEncapType, expectedKeepaliveTimer);
|
||||||
|
// Expect no NetworkCapabilities change.
|
||||||
|
// Call to doSendNetworkCapabilities() will not be triggered.
|
||||||
|
verify(mMockNetworkAgent, never()).doSendNetworkCapabilities(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user