Test VpnProfile is not modified in startLegacyVpn
The profile is modified within startLegacyVpnPrivileged(), e.g. ipsecCaCert, ipsecUserCert. This causes subsequent calls from callers such as LockdownVpnTracker to fail. Add a new test to ensure the VpnProfile is not modified in startLegacyVpn. Add testClone in VpnProfileTest. Bug: 190572822 Bug: 309591931 Test: atest FrameworksNetTests, test before and after fix. Test: Manual test Change-Id: Id090e0dd3b9e74a7461ae90e68c41e802b458744
This commit is contained in:
@@ -26,6 +26,7 @@ import static com.android.testutils.ParcelUtils.assertParcelSane;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -311,4 +312,12 @@ public class VpnProfileTest {
|
||||
decoded.password = profile.password;
|
||||
assertEquals(profile, decoded);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClone() {
|
||||
final VpnProfile profile = getSampleIkev2Profile(DUMMY_PROFILE_KEY);
|
||||
final VpnProfile clone = profile.clone();
|
||||
assertEquals(profile, clone);
|
||||
assertNotSame(profile, clone);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3131,6 +3131,20 @@ public class VpnTest extends VpnTestBase {
|
||||
startPptp(false /* useMppe */);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartLegacyVpnModifyProfile_TypePSK() throws Exception {
|
||||
setMockedUsers(PRIMARY_USER);
|
||||
final Vpn vpn = createVpn(PRIMARY_USER.id);
|
||||
final Ikev2VpnProfile ikev2VpnProfile =
|
||||
new Ikev2VpnProfile.Builder(TEST_VPN_SERVER, TEST_VPN_IDENTITY)
|
||||
.setAuthPsk(TEST_VPN_PSK)
|
||||
.build();
|
||||
final VpnProfile profile = ikev2VpnProfile.toVpnProfile();
|
||||
|
||||
startLegacyVpn(vpn, profile);
|
||||
assertEquals(profile, ikev2VpnProfile.toVpnProfile());
|
||||
}
|
||||
|
||||
private void assertTransportInfoMatches(NetworkCapabilities nc, int type) {
|
||||
assertNotNull(nc);
|
||||
VpnTransportInfo ti = (VpnTransportInfo) nc.getTransportInfo();
|
||||
|
||||
Reference in New Issue
Block a user