Merge changes from topic "vpn-api-fixes"
* changes: Test getProvisionedVpnProfileState Make test networks not be VPNs
This commit is contained in:
@@ -231,6 +231,7 @@ class TestNetworkService extends ITestNetworkManager.Stub {
|
||||
nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED);
|
||||
nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
|
||||
nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED);
|
||||
nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN);
|
||||
nc.setNetworkSpecifier(new TestNetworkSpecifier(iface));
|
||||
nc.setAdministratorUids(administratorUids);
|
||||
if (!isMetered) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import static com.android.testutils.TestableNetworkCallbackKt.anyNetwork;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -59,6 +60,7 @@ import android.text.TextUtils;
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
|
||||
import com.android.internal.util.HexDump;
|
||||
import com.android.networkstack.apishim.ConstantsShim;
|
||||
import com.android.networkstack.apishim.Ikev2VpnProfileBuilderShimImpl;
|
||||
import com.android.networkstack.apishim.Ikev2VpnProfileShimImpl;
|
||||
import com.android.networkstack.apishim.VpnManagerShimImpl;
|
||||
@@ -66,6 +68,7 @@ import com.android.networkstack.apishim.common.Ikev2VpnProfileBuilderShim;
|
||||
import com.android.networkstack.apishim.common.Ikev2VpnProfileShim;
|
||||
import com.android.networkstack.apishim.common.UnsupportedApiLevelException;
|
||||
import com.android.networkstack.apishim.common.VpnManagerShim;
|
||||
import com.android.networkstack.apishim.common.VpnProfileStateShim;
|
||||
import com.android.testutils.DevSdkIgnoreRule;
|
||||
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
|
||||
import com.android.testutils.DevSdkIgnoreRunner;
|
||||
@@ -486,7 +489,14 @@ public class Ikev2VpnTest {
|
||||
if (testSessionKey) {
|
||||
// testSessionKey will never be true if running on <T
|
||||
// startProvisionedVpnProfileSession() should return a non-null & non-empty random UUID.
|
||||
assertFalse(TextUtils.isEmpty(mVmShim.startProvisionedVpnProfileSession()));
|
||||
final String sessionId = mVmShim.startProvisionedVpnProfileSession();
|
||||
assertFalse(TextUtils.isEmpty(sessionId));
|
||||
final VpnProfileStateShim profileState = mVmShim.getProvisionedVpnProfileState();
|
||||
assertNotNull(profileState);
|
||||
assertEquals(ConstantsShim.VPN_PROFILE_STATE_CONNECTING, profileState.getState());
|
||||
assertEquals(sessionId, profileState.getSessionId());
|
||||
assertFalse(profileState.isAlwaysOn());
|
||||
assertFalse(profileState.isLockdownEnabled());
|
||||
} else {
|
||||
sVpnMgr.startProvisionedVpnProfile();
|
||||
}
|
||||
@@ -502,6 +512,14 @@ public class Ikev2VpnTest {
|
||||
final Network vpnNetwork = cb.expectCallback(CallbackEntry.AVAILABLE, anyNetwork())
|
||||
.getNetwork();
|
||||
|
||||
if (testSessionKey) {
|
||||
final VpnProfileStateShim profileState = mVmShim.getProvisionedVpnProfileState();
|
||||
assertNotNull(profileState);
|
||||
assertEquals(ConstantsShim.VPN_PROFILE_STATE_CONNECTED, profileState.getState());
|
||||
assertFalse(profileState.isAlwaysOn());
|
||||
assertFalse(profileState.isLockdownEnabled());
|
||||
}
|
||||
|
||||
cb.expectCapabilitiesThat(vpnNetwork, TIMEOUT_MS, caps -> caps.hasTransport(TRANSPORT_VPN)
|
||||
&& caps.hasCapability(NET_CAPABILITY_INTERNET)
|
||||
&& !caps.hasCapability(NET_CAPABILITY_VALIDATED)
|
||||
|
||||
Reference in New Issue
Block a user