Search in sources :

Example 41 with VpnProfile

use of com.android.internal.net.VpnProfile in project android_packages_apps_Settings by DirtyUnicorns.

the class PreferenceListTest method testConnectedLegacyVpnShownExactlyOnce.

@SmallTest
public void testConnectedLegacyVpnShownExactlyOnce() {
    final VpnProfile vpnProfile = new VpnProfile("test-no-duplicates");
    final LegacyVpnInfo connectedLegacyVpn = new LegacyVpnInfo();
    connectedLegacyVpn.key = new String(vpnProfile.key);
    final VpnSettings.UpdatePreferences updater = new VpnSettings.UpdatePreferences(mSettings);
    updater.legacyVpns(/* vpnProfiles */
    Collections.<VpnProfile>singletonList(vpnProfile), /* connectedLegacyVpns */
    new HashMap<String, LegacyVpnInfo>() {

        {
            put(connectedLegacyVpn.key, connectedLegacyVpn);
        }
    }, /* lockdownVpnKey */
    null);
    updater.run();
    final ArgumentMatcher<VpnProfile> equalsFake = new ArgumentMatcher<VpnProfile>() {

        @Override
        public boolean matchesObject(final Object arg) {
            if (arg == vpnProfile)
                return true;
            if (arg == null)
                return false;
            return TextUtils.equals(((VpnProfile) arg).key, vpnProfile.key);
        }
    };
    // The VPN profile should have been used to create a preference and set up at laest once
    // with update=true to fill in all the fields.
    verify(mSettings, atLeast(1)).findOrCreatePreference(argThat(equalsFake), eq(true));
    // ...But no other VPN profile key should ever have been passed in.
    verify(mSettings, never()).findOrCreatePreference(not(argThat(equalsFake)), anyBoolean());
    // And so we should still have exactly 1 preference created.
    assertEquals(1, mLegacyMocks.size());
    assertEquals(0, mAppMocks.size());
}
Also used : VpnProfile(com.android.internal.net.VpnProfile) ArgumentMatcher(org.mockito.compat.ArgumentMatcher) LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) VpnSettings(com.android.settings.vpn2.VpnSettings) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 42 with VpnProfile

use of com.android.internal.net.VpnProfile in project android_packages_apps_Settings by crdroidandroid.

the class VpnTests method testIpsecXauthPskConnection.

/**
 * Test IPSec Xauth PSK VPN connection
 */
@LargeTest
public void testIpsecXauthPskConnection() throws Exception {
    VpnInfo curVpnInfo = mVpnInfoPool.get(VpnProfile.TYPE_IPSEC_XAUTH_PSK);
    VpnProfile vpnProfile = curVpnInfo.getVpnProfile();
    if (DEBUG) {
        printVpnProfile(vpnProfile);
    }
    connect(vpnProfile);
    validateVpnConnection(vpnProfile, true);
}
Also used : VpnProfile(com.android.internal.net.VpnProfile) LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 43 with VpnProfile

use of com.android.internal.net.VpnProfile in project android_packages_apps_Settings by crdroidandroid.

the class VpnTests method testPPTPConnection.

/**
 * Test PPTP VPN connection
 */
@LargeTest
public void testPPTPConnection() throws Exception {
    mPreviousIpAddress = getIpAddress();
    VpnInfo curVpnInfo = mVpnInfoPool.get(VpnProfile.TYPE_PPTP);
    VpnProfile vpnProfile = curVpnInfo.getVpnProfile();
    connect(vpnProfile);
    validateVpnConnection(vpnProfile);
}
Also used : VpnProfile(com.android.internal.net.VpnProfile) LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 44 with VpnProfile

use of com.android.internal.net.VpnProfile in project platform_packages_apps_Settings by BlissRoms.

the class PreferenceListTest method testDisconnectedLegacyVpnShown.

@SmallTest
public void testDisconnectedLegacyVpnShown() {
    final VpnProfile vpnProfile = new VpnProfile("test-disconnected");
    final VpnSettings.UpdatePreferences updater = new VpnSettings.UpdatePreferences(mSettings);
    updater.legacyVpns(/* vpnProfiles */
    Collections.<VpnProfile>singletonList(vpnProfile), /* connectedLegacyVpns */
    Collections.<String, LegacyVpnInfo>emptyMap(), /* lockdownVpnKey */
    null);
    updater.run();
    verify(mSettings, times(1)).findOrCreatePreference(any(VpnProfile.class), eq(true));
    assertEquals(1, mLegacyMocks.size());
    assertEquals(0, mAppMocks.size());
}
Also used : VpnProfile(com.android.internal.net.VpnProfile) VpnSettings(com.android.settings.vpn2.VpnSettings) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 45 with VpnProfile

use of com.android.internal.net.VpnProfile in project platform_packages_apps_Settings by BlissRoms.

the class PreferenceListTest method testConnectedLegacyVpnShownIfDeleted.

@SmallTest
public void testConnectedLegacyVpnShownIfDeleted() {
    final LegacyVpnInfo connectedLegacyVpn = new LegacyVpnInfo();
    connectedLegacyVpn.key = "test-connected";
    final VpnSettings.UpdatePreferences updater = new VpnSettings.UpdatePreferences(mSettings);
    updater.legacyVpns(/* vpnProfiles */
    Collections.<VpnProfile>emptyList(), /* connectedLegacyVpns */
    new HashMap<String, LegacyVpnInfo>() {

        {
            put(connectedLegacyVpn.key, connectedLegacyVpn);
        }
    }, /* lockdownVpnKey */
    null);
    updater.run();
    verify(mSettings, times(1)).findOrCreatePreference(any(VpnProfile.class), eq(false));
    assertEquals(1, mLegacyMocks.size());
    assertEquals(0, mAppMocks.size());
}
Also used : VpnProfile(com.android.internal.net.VpnProfile) LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) VpnSettings(com.android.settings.vpn2.VpnSettings) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

VpnProfile (com.android.internal.net.VpnProfile)118 LegacyVpnInfo (com.android.internal.net.LegacyVpnInfo)63 LargeTest (android.test.suitebuilder.annotation.LargeTest)42 SmallTest (android.test.suitebuilder.annotation.SmallTest)21 VpnSettings (com.android.settings.vpn2.VpnSettings)18 Context (android.content.Context)14 Bundle (android.os.Bundle)14 RemoteException (android.os.RemoteException)14 WorkerThread (android.annotation.WorkerThread)7 Activity (android.app.Activity)7 Dialog (android.app.Dialog)7 Intent (android.content.Intent)7 PackageInfo (android.content.pm.PackageInfo)7 PackageManager (android.content.pm.PackageManager)7 UserHandle (android.os.UserHandle)7 KeyStore (android.security.KeyStore)7 AlertDialog (android.app.AlertDialog)6 LockdownVpnTracker (com.android.server.net.LockdownVpnTracker)6 ArgumentMatcher (org.mockito.compat.ArgumentMatcher)6 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)5