summaryrefslogtreecommitdiffstats
path: root/tests/wifitests/src/com/android/server
diff options
context:
space:
mode:
authorHai Shalom <haishalom@google.com>2019-06-07 13:48:33 -0700
committerHai Shalom <haishalom@google.com>2019-06-10 21:12:25 +0000
commit724f5ef108fb3f3aec0ede58b77610000f6bc0c1 (patch)
treeb08dcd69198b30c937a3ff8637fe55ef179a3c8b /tests/wifitests/src/com/android/server
parent79f854d422a916afec071337b29ba3c71c0ed4e8 (diff)
downloadandroid_frameworks_opt_net_wifi-724f5ef108fb3f3aec0ede58b77610000f6bc0c1.tar.gz
android_frameworks_opt_net_wifi-724f5ef108fb3f3aec0ede58b77610000f6bc0c1.tar.bz2
android_frameworks_opt_net_wifi-724f5ef108fb3f3aec0ede58b77610000f6bc0c1.zip
[Encrypted IMSI] Use the pseudonym if available
Update the logic to save the pseudonym, in case a real pseudonym is provided by the EAP server. This will allow the framework to use it in subsequent connections, instead of sending anonymous@<realm> and encrypting the IMSI each time. Bug: 134775152 Test: Auto-connect to Carrier Wi-Fi Test: atest ClientModeImplTest Change-Id: Ie5696f419bc3f5cbc75a39e8a3c0cfa8bfde7021
Diffstat (limited to 'tests/wifitests/src/com/android/server')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java65
1 files changed, 60 insertions, 5 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index b64bf3de5..a26582c5c 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -1033,10 +1033,10 @@ public class ClientModeImplTest {
/**
* Tests anonymous identity is set again whenever a connection is established for the carrier
- * that supports encrypted IMSI and anonymous identity.
+ * that supports encrypted IMSI and anonymous identity and no real pseudonym was provided.
*/
@Test
- public void testSetAnonymousIdentityWhenConnectionIsEstablished() throws Exception {
+ public void testSetAnonymousIdentityWhenConnectionIsEstablishedNoPseudonym() throws Exception {
mConnectedNetwork = spy(WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE));
when(mDataTelephonyManager.getSimOperator()).thenReturn("123456");
@@ -1059,16 +1059,71 @@ public class ClientModeImplTest {
getGoogleGuestScanDetail(TEST_RSSI, sBSSID, sFreq));
when(mScanDetailCache.getScanResult(sBSSID)).thenReturn(
getGoogleGuestScanDetail(TEST_RSSI, sBSSID, sFreq).getScanResult());
+ when(mWifiNative.getEapAnonymousIdentity(anyString()))
+ .thenReturn(expectedAnonymousIdentity);
mCmi.sendMessage(WifiMonitor.NETWORK_CONNECTION_EVENT, 0, 0, sBSSID);
mLooper.dispatchAll();
- // verify that WifiNative#getEapAnonymousIdentity() was never called since we are using
- // encrypted IMSI full authentication and not using pseudonym identity.
- verify(mWifiNative, never()).getEapAnonymousIdentity(any());
+ verify(mWifiNative).getEapAnonymousIdentity(any());
// check that the anonymous identity remains anonymous@<realm> for subsequent connections.
assertEquals(expectedAnonymousIdentity,
mConnectedNetwork.enterpriseConfig.getAnonymousIdentity());
+ // verify that WifiConfigManager#addOrUpdateNetwork() was never called if there is no
+ // real pseudonym to be stored. i.e. Encrypted IMSI will be always used
+ // Note: This test will fail if future logic will have additional conditions that would
+ // trigger "add or update network" operation. The test needs to be updated to account for
+ // this change.
+ verify(mWifiConfigManager, never()).addOrUpdateNetwork(any(), anyInt());
+ }
+
+ /**
+ * Tests anonymous identity is set again whenever a connection is established for the carrier
+ * that supports encrypted IMSI and anonymous identity but real pseudonym was provided for
+ * subsequent connections.
+ */
+ @Test
+ public void testSetAnonymousIdentityWhenConnectionIsEstablishedWithPseudonym()
+ throws Exception {
+ mConnectedNetwork = spy(WifiConfigurationTestUtil.createEapNetwork(
+ WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE));
+ when(mDataTelephonyManager.getSimOperator()).thenReturn("123456");
+ when(mDataTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_READY);
+ mConnectedNetwork.enterpriseConfig.setAnonymousIdentity("");
+
+ String expectedAnonymousIdentity = "anonymous@wlan.mnc456.mcc123.3gppnetwork.org";
+ String pseudonym = "83bcca9384fca@wlan.mnc456.mcc123.3gppnetwork.org";
+
+ when(mCarrierNetworkConfig.isCarrierEncryptionInfoAvailable()).thenReturn(true);
+
+ triggerConnect();
+
+ // CMD_START_CONNECT should have set anonymousIdentity to anonymous@<realm>
+ assertEquals(expectedAnonymousIdentity,
+ mConnectedNetwork.enterpriseConfig.getAnonymousIdentity());
+
+ when(mWifiConfigManager.getScanDetailCacheForNetwork(FRAMEWORK_NETWORK_ID))
+ .thenReturn(mScanDetailCache);
+ when(mScanDetailCache.getScanDetail(sBSSID)).thenReturn(
+ getGoogleGuestScanDetail(TEST_RSSI, sBSSID, sFreq));
+ when(mScanDetailCache.getScanResult(sBSSID)).thenReturn(
+ getGoogleGuestScanDetail(TEST_RSSI, sBSSID, sFreq).getScanResult());
+ when(mWifiNative.getEapAnonymousIdentity(anyString()))
+ .thenReturn(pseudonym);
+
+ mCmi.sendMessage(WifiMonitor.NETWORK_CONNECTION_EVENT, 0, 0, sBSSID);
+ mLooper.dispatchAll();
+
+ verify(mWifiNative).getEapAnonymousIdentity(any());
+ assertEquals(pseudonym,
+ mConnectedNetwork.enterpriseConfig.getAnonymousIdentity());
+ // Verify that WifiConfigManager#addOrUpdateNetwork() was called if there we received a
+ // real pseudonym to be stored. i.e. Encrypted IMSI will be used once, followed by
+ // pseudonym usage in all subsequent connections.
+ // Note: This test will fail if future logic will have additional conditions that would
+ // trigger "add or update network" operation. The test needs to be updated to account for
+ // this change.
+ verify(mWifiConfigManager).addOrUpdateNetwork(any(), anyInt());
}
/**