diff options
author | Etan Cohen <etancohen@google.com> | 2019-05-30 17:34:24 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-05-30 17:34:24 +0000 |
commit | d347f084ac4b935a376425e322b0fc8000e61d29 (patch) | |
tree | f53faf771cc229628274d6b3185e01e7341993dc /tests | |
parent | d730fef342daccb305f4cc20576c98601d05e44b (diff) | |
parent | 84641ba60a4c3518e6b60cf7d44a09fc1e5b5f69 (diff) |
Merge changes from topic "encrypted_imsi_cleanup" into qt-dev
* changes:
Fixed code setting anonymous_identity to anonymous@<realm>
Modify Encrypted IMSI, remove deprecated protocols
Diffstat (limited to 'tests')
5 files changed, 21 insertions, 203 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/CarrierNetworkConfigTest.java b/tests/wifitests/src/com/android/server/wifi/CarrierNetworkConfigTest.java index 9ff5be97d..d89358df0 100644 --- a/tests/wifitests/src/com/android/server/wifi/CarrierNetworkConfigTest.java +++ b/tests/wifitests/src/com/android/server/wifi/CarrierNetworkConfigTest.java @@ -82,19 +82,14 @@ public class CarrierNetworkConfigTest { * * @param ssid The SSID of the carrier network * @param eapType The EAP type of the carrier network - * @param encodingMethod base64 encoding method - * @param eapIdentitySequence eap identity sequence * @return {@link PersistableBundle} containing carrier config */ - private PersistableBundle generateTestConfig(String ssid, int eapType, int encodingMethod, - int eapIdentitySequence) { + private PersistableBundle generateTestConfig(String ssid, int eapType) { PersistableBundle bundle = new PersistableBundle(); String networkConfig = new String(Base64.encode(ssid.getBytes(), Base64.DEFAULT)) + "," + eapType; bundle.putStringArray(CarrierConfigManager.KEY_CARRIER_WIFI_STRING_ARRAY, new String[]{networkConfig}); - bundle.putInt(CarrierConfigManager.KEY_IMSI_ENCODING_METHOD_INT, encodingMethod); - bundle.putInt(CarrierConfigManager.KEY_EAP_IDENTITY_SEQUENCE_INT, eapIdentitySequence); return bundle; } @@ -111,9 +106,7 @@ public class CarrierNetworkConfigTest { when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager); when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mDataTelephonyManager); when(mCarrierConfigManager.getConfigForSubId(TEST_SUBSCRIPTION_ID)) - .thenReturn(generateTestConfig(TEST_SSID, TEST_STANDARD_EAP_TYPE, - CarrierNetworkConfig.ENCODING_METHOD_RFC_2045, - CarrierNetworkConfig.IDENTITY_SEQUENCE_IMSI_V1_0)); + .thenReturn(generateTestConfig(TEST_SSID, TEST_STANDARD_EAP_TYPE)); when(mSubscriptionManager.getActiveSubscriptionInfoList()) .thenReturn(Arrays.asList(new SubscriptionInfo[] {TEST_SUBSCRIPTION_INFO})); when(mDataTelephonyManager.getCarrierInfoForImsiEncryption(TelephonyManager.KEY_TYPE_WLAN)) @@ -145,9 +138,6 @@ public class CarrierNetworkConfigTest { assertTrue(mCarrierNetworkConfig.isCarrierNetwork(TEST_SSID)); assertEquals(TEST_INTERNAL_EAP_TYPE, mCarrierNetworkConfig.getNetworkEapType(TEST_SSID)); assertEquals(TEST_CARRIER_NAME, mCarrierNetworkConfig.getCarrierName(TEST_SSID)); - assertEquals(Base64.DEFAULT, mCarrierNetworkConfig.getBase64EncodingFlag()); - assertEquals(CarrierNetworkConfig.IDENTITY_SEQUENCE_IMSI_V1_0, - mCarrierNetworkConfig.getEapIdentitySequence()); } /** @@ -157,9 +147,7 @@ public class CarrierNetworkConfigTest { @Test public void getExistingCarrierNetworkInfo_nullDisplayName_shouldNotThrowNpe() { when(mCarrierConfigManager.getConfigForSubId(TEST_SUBSCRIPTION_ID)) - .thenReturn(generateTestConfig(TEST_SSID, TEST_STANDARD_EAP_TYPE, - CarrierNetworkConfig.ENCODING_METHOD_RFC_2045, - CarrierNetworkConfig.IDENTITY_SEQUENCE_IMSI_V1_0)); + .thenReturn(generateTestConfig(TEST_SSID, TEST_STANDARD_EAP_TYPE)); SubscriptionInfo testSubscriptionInfoNullDisplayName = new SubscriptionInfo( TEST_SUBSCRIPTION_ID, null, 0, null, null, 0, 0, null, 0, null, "0", "0", null, false, null, null); @@ -233,9 +221,7 @@ public class CarrierNetworkConfigTest { when(mSubscriptionManager.getActiveSubscriptionInfoList()) .thenReturn(Arrays.asList(new SubscriptionInfo[] {updatedSubscriptionInfo})); when(mCarrierConfigManager.getConfigForSubId(TEST_SUBSCRIPTION_ID)) - .thenReturn(generateTestConfig(updatedSsid, updatedStandardEapType, - CarrierNetworkConfig.ENCODING_METHOD_RFC_2045, - CarrierNetworkConfig.IDENTITY_SEQUENCE_IMSI_V1_0)); + .thenReturn(generateTestConfig(updatedSsid, updatedStandardEapType)); mBroadcastReceiver.onReceive(mContext, new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)); @@ -243,17 +229,11 @@ public class CarrierNetworkConfigTest { assertFalse(mCarrierNetworkConfig.isCarrierNetwork(TEST_SSID)); assertEquals(-1, mCarrierNetworkConfig.getNetworkEapType(TEST_SSID)); assertEquals(null, mCarrierNetworkConfig.getCarrierName(TEST_SSID)); - assertEquals(Base64.DEFAULT, mCarrierNetworkConfig.getBase64EncodingFlag()); - assertEquals(CarrierNetworkConfig.IDENTITY_SEQUENCE_IMSI_V1_0, - mCarrierNetworkConfig.getEapIdentitySequence()); // Verify that updated SSID is associated with a carrier network. assertTrue(mCarrierNetworkConfig.isCarrierNetwork(updatedSsid)); assertEquals(updatedInternalEapType, mCarrierNetworkConfig.getNetworkEapType(updatedSsid)); assertEquals(updatedCarrierName, mCarrierNetworkConfig.getCarrierName(updatedSsid)); - assertEquals(Base64.DEFAULT, mCarrierNetworkConfig.getBase64EncodingFlag()); - assertEquals(CarrierNetworkConfig.IDENTITY_SEQUENCE_IMSI_V1_0, - mCarrierNetworkConfig.getEapIdentitySequence()); } /** @@ -285,55 +265,4 @@ public class CarrierNetworkConfigTest { mContentObserver.onChange(false); assertTrue(mCarrierNetworkConfig.isCarrierEncryptionInfoAvailable()); } - - /** - * Verify that base64Encoding type should be {@link Base64#NO_WRAP} when carrier configuration - * defines RFC4648 for encoding method. - */ - @Test - public void verifyBase64EncodingTypeWithRfc4648() { - when(mCarrierConfigManager.getConfigForSubId(TEST_SUBSCRIPTION_ID)) - .thenReturn(generateTestConfig(TEST_SSID, TEST_STANDARD_EAP_TYPE, - CarrierNetworkConfig.ENCODING_METHOD_RFC_4648, - CarrierNetworkConfig.IDENTITY_SEQUENCE_IMSI_V1_0)); - mBroadcastReceiver.onReceive(mContext, - new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)); - assertEquals(Base64.NO_WRAP, mCarrierNetworkConfig.getBase64EncodingFlag()); - } - - /** - * Verify that carrier network config is not generated when carrier configuration defines - * unsupported encoding method. - */ - @Test - public void verifyBase64EncodingTypeWithUnsupportedEncodingMethod() { - String ssid = "invalid carrier AP"; - when(mCarrierConfigManager.getConfigForSubId(TEST_SUBSCRIPTION_ID)) - .thenReturn(generateTestConfig(ssid, TEST_STANDARD_EAP_TYPE, 123, - CarrierNetworkConfig.IDENTITY_SEQUENCE_IMSI_V1_0)); - mBroadcastReceiver.onReceive(mContext, - new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)); - - assertFalse(mCarrierNetworkConfig.isCarrierNetwork(ssid)); - assertEquals(-1, mCarrierNetworkConfig.getNetworkEapType(ssid)); - assertEquals(null, mCarrierNetworkConfig.getCarrierName(ssid)); - assertEquals(Base64.DEFAULT, mCarrierNetworkConfig.getBase64EncodingFlag()); - } - - /** - * Verify that anonymous identity should be supported when carrier configuration is configured - * to support anonymous followed by encrypted IMSI for eap identity. - */ - @Test - public void verifyEapIdentitySequenceWithAnonymous() { - when(mCarrierConfigManager.getConfigForSubId(TEST_SUBSCRIPTION_ID)) - .thenReturn(generateTestConfig(TEST_SSID, TEST_STANDARD_EAP_TYPE, - CarrierNetworkConfig.ENCODING_METHOD_RFC_2045, - CarrierNetworkConfig.IDENTITY_SEQUENCE_ANONYMOUS_THEN_IMSI_V1_0)); - mBroadcastReceiver.onReceive(mContext, - new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)); - - assertEquals(CarrierNetworkConfig.IDENTITY_SEQUENCE_ANONYMOUS_THEN_IMSI_V1_0, - mCarrierNetworkConfig.getEapIdentitySequence()); - } } diff --git a/tests/wifitests/src/com/android/server/wifi/CarrierNetworkEvaluatorTest.java b/tests/wifitests/src/com/android/server/wifi/CarrierNetworkEvaluatorTest.java index 650b9ee8b..57a40dc8f 100644 --- a/tests/wifitests/src/com/android/server/wifi/CarrierNetworkEvaluatorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/CarrierNetworkEvaluatorTest.java @@ -17,7 +17,6 @@ package com.android.server.wifi; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; @@ -53,6 +52,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + /** * Unit tests for CarrierNeteworkEvaluator */ @@ -116,6 +116,8 @@ public class CarrierNetworkEvaluatorTest { Integer networkId = mConfigs.get(config.configKey()); if (networkId == null) return null; + when(mWifiConfigManager.getConfiguredNetwork(networkId)).thenReturn(config); + NetworkUpdateResult networkUpdateResult = mock(NetworkUpdateResult.class); when(networkUpdateResult.isSuccess()).thenReturn(true); when(networkUpdateResult.getNetworkId()).thenReturn(networkId); @@ -160,8 +162,6 @@ public class CarrierNetworkEvaluatorTest { when(mDataTelephonyManager.getSimOperator()).thenReturn(TEST_MCC_MNC); when(mDataTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_READY); when(mCarrierNetworkConfig.isCarrierEncryptionInfoAvailable()).thenReturn(true); - when(mCarrierNetworkConfig.getEapIdentitySequence()).thenReturn( - CarrierNetworkConfig.IDENTITY_SEQUENCE_IMSI_V1_0); when(mCarrierNetworkConfig.isCarrierNetwork(eq(CARRIER1_SSID.replace("\"", "")))) .thenReturn(true); @@ -251,7 +251,8 @@ public class CarrierNetworkEvaluatorTest { assertTrue(config2.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.WPA_EAP)); WifiConfiguration config3 = mWifiConfigCaptor.getAllValues().get(2); assertEquals(CARRIER_SAVED_SSID, config3.SSID); - assertFalse(config3.isEphemeral()); + // all configs returned by CarrierNetworkEvaluator are ephemeral. + assertTrue(config3.isEphemeral()); assertTrue(config3.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.WPA_EAP)); WifiConfiguration config4 = mWifiConfigCaptor.getAllValues().get(3); assertEquals(CARRIER_SAVED_EPH_SSID, config4.SSID); @@ -259,7 +260,8 @@ public class CarrierNetworkEvaluatorTest { assertTrue(config4.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.WPA_EAP)); assertEquals(config2.configKey(), selected.configKey()); // SSID2 has the highest RSSI - assertEquals("", selected.enterpriseConfig.getAnonymousIdentity()); + assertEquals("anonymous@wlan.mnc456.mcc123.3gppnetwork.org", + selected.enterpriseConfig.getAnonymousIdentity()); } /** @@ -398,7 +400,6 @@ public class CarrierNetworkEvaluatorTest { int[] levels = {10}; String expectedAnonymousIdentity = "anonymous@wlan.mnc456.mcc123.3gppnetwork.org"; when(mCarrierNetworkConfig.isCarrierEncryptionInfoAvailable()).thenReturn(true); - when(mCarrierNetworkConfig.isSupportAnonymousIdentity()).thenReturn(true); List<ScanDetail> scanDetails = WifiNetworkSelectorTestUtil.buildScanDetails(ssids, bssids, freqs, caps, levels, mClock); WifiConfiguration carrierConfig = configureNewSsid(CARRIER1_NET_ID, scanDetails.get(0), diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 0fd040c7e..597ccae7b 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -1024,10 +1024,12 @@ public class ClientModeImplTest { when(mDataTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_READY); String expectedAnonymousIdentity = TelephonyUtil.getAnonymousIdentityWith3GppRealm( mTelephonyManager); + // we are using anonymous@<realm> as our anonymous identity before connection + mConnectedNetwork.enterpriseConfig.setAnonymousIdentity(expectedAnonymousIdentity); + triggerConnect(); when(mCarrierNetworkConfig.isCarrierEncryptionInfoAvailable()).thenReturn(true); - when(mCarrierNetworkConfig.isSupportAnonymousIdentity()).thenReturn(true); when(mWifiConfigManager.getScanDetailCacheForNetwork(FRAMEWORK_NETWORK_ID)) .thenReturn(mScanDetailCache); @@ -1039,6 +1041,10 @@ public class ClientModeImplTest { 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()); + // check that the anonymous identity remains anonymous@<realm> for subsequent connections. assertEquals(expectedAnonymousIdentity, mConnectedNetwork.enterpriseConfig.getAnonymousIdentity()); } diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java index 3048abae0..ef019b416 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java @@ -421,7 +421,6 @@ public class PasspointNetworkEvaluatorTest { // SIM is present when(mSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[1]); when(mCarrierNetworkConfig.isCarrierEncryptionInfoAvailable()).thenReturn(true); - when(mCarrierNetworkConfig.isSupportAnonymousIdentity()).thenReturn(true); when(mWifiConfigManager.addOrUpdateNetwork(any(WifiConfiguration.class), anyInt())) .thenReturn(new NetworkUpdateResult(TEST_NETWORK_ID)); when(mWifiConfigManager.getConfiguredNetwork(TEST_NETWORK_ID)).thenReturn(config); diff --git a/tests/wifitests/src/com/android/server/wifi/util/TelephonyUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/TelephonyUtilTest.java index 490cdfef2..531673f0e 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/TelephonyUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/TelephonyUtilTest.java @@ -16,8 +16,6 @@ package com.android.server.wifi.util; -import static com.android.server.wifi.CarrierNetworkConfig.IDENTITY_SEQUENCE_IMSI_V1_0; - import static org.junit.Assert.*; import static org.mockito.Mockito.*; @@ -64,9 +62,6 @@ public class TelephonyUtilTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - when(mCarrierNetworkConfig.getBase64EncodingFlag()).thenReturn(Base64.DEFAULT); - when(mCarrierNetworkConfig.getEapIdentitySequence()).thenReturn( - IDENTITY_SEQUENCE_IMSI_V1_0); mTelephonyUtil = new TelephonyUtil(); when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mDataTelephonyManager); } @@ -133,59 +128,17 @@ public class TelephonyUtilTest { } /** - * Verify that an expected identity is returned when using the encrypted identity for V1.0 - * encoded by RFC4648. - */ - @Test - public void getEncryptedIdentity_V_1_0_WithRfc4648() throws Exception { - Cipher cipher = mock(Cipher.class); - PublicKey key = null; - int flag = Base64.NO_WRAP; - String imsi = "3214561234567890"; - String encryptedImsi = Base64.encodeToString(imsi.getBytes(), 0, imsi.getBytes().length, - flag); - String encryptedIdentity = "\0" + encryptedImsi + "@wlan.mnc456.mcc321.3gppnetwork.org"; - final Pair<String, String> expectedIdentity = Pair.create( - "03214561234567890@wlan.mnc456.mcc321.3gppnetwork.org", encryptedIdentity); - - // static mocking - MockitoSession session = ExtendedMockito.mockitoSession().mockStatic( - Cipher.class).startMocking(); - try { - when(Cipher.getInstance(anyString())).thenReturn(cipher); - when(cipher.doFinal(any(byte[].class))).thenReturn(imsi.getBytes()); - when(mDataTelephonyManager.getSubscriberId()).thenReturn(imsi); - when(mDataTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_READY); - when(mDataTelephonyManager.getSimOperator()).thenReturn("321456"); - ImsiEncryptionInfo info = new ImsiEncryptionInfo("321", "456", - TelephonyManager.KEY_TYPE_WLAN, null, key, null); - when(mDataTelephonyManager.getCarrierInfoForImsiEncryption( - eq(TelephonyManager.KEY_TYPE_WLAN))) - .thenReturn(info); - when(mCarrierNetworkConfig.getBase64EncodingFlag()).thenReturn(flag); - - assertEquals(expectedIdentity, - TelephonyUtil.getSimIdentity(mTelephonyManager, mTelephonyUtil, - WifiConfigurationTestUtil.createEapNetwork(WifiEnterpriseConfig.Eap.AKA, - WifiEnterpriseConfig.Phase2.NONE), mCarrierNetworkConfig)); - } finally { - session.finishMocking(); - } - } - - /** - * Verify that an expected identity is returned when using the encrypted identity for V1.6 + * Verify that an expected identity is returned when using the encrypted identity * encoded by RFC4648. */ @Test - public void getEncryptedIdentity_V_1_6_WithRfc4648() throws Exception { + public void getEncryptedIdentity_WithRfc4648() throws Exception { Cipher cipher = mock(Cipher.class); PublicKey key = null; - int flag = Base64.NO_WRAP; String imsi = "3214561234567890"; String permanentIdentity = "03214561234567890@wlan.mnc456.mcc321.3gppnetwork.org"; String encryptedImsi = Base64.encodeToString(permanentIdentity.getBytes(), 0, - permanentIdentity.getBytes().length, flag); + permanentIdentity.getBytes().length, Base64.NO_WRAP); String encryptedIdentity = "\0" + encryptedImsi; final Pair<String, String> expectedIdentity = Pair.create(permanentIdentity, encryptedIdentity); @@ -204,52 +157,6 @@ public class TelephonyUtilTest { when(mDataTelephonyManager.getCarrierInfoForImsiEncryption( eq(TelephonyManager.KEY_TYPE_WLAN))) .thenReturn(info); - when(mCarrierNetworkConfig.getBase64EncodingFlag()).thenReturn(flag); - when(mCarrierNetworkConfig.getEapIdentitySequence()).thenReturn( - CarrierNetworkConfig.IDENTITY_SEQUENCE_ANONYMOUS_THEN_IMSI_V1_6); - - assertEquals(expectedIdentity, - TelephonyUtil.getSimIdentity(mTelephonyManager, mTelephonyUtil, - WifiConfigurationTestUtil.createEapNetwork(WifiEnterpriseConfig.Eap.AKA, - WifiEnterpriseConfig.Phase2.NONE), mCarrierNetworkConfig)); - } finally { - session.finishMocking(); - } - } - - /** - * Verify that an expected identity is returned when using the encrypted IMSI encoded by RFC2045 - * with key identifier. - */ - @Test - public void getEncryptedIdentityKeyIdentifierWithRfc2045() throws Exception { - Cipher cipher = mock(Cipher.class); - int flag = Base64.DEFAULT; - PublicKey key = null; - String keyIdentifier = "key=testKey"; - String imsi = "3214561234567890"; - String encryptedImsi = Base64.encodeToString(imsi.getBytes(), 0, imsi.getBytes().length, - flag); - String encryptedIdentity = "\0" + encryptedImsi + "@wlan.mnc456.mcc321.3gppnetwork.org," - + keyIdentifier; - final Pair<String, String> expectedIdentity = Pair.create( - "03214561234567890@wlan.mnc456.mcc321.3gppnetwork.org", encryptedIdentity); - - // static mocking - MockitoSession session = ExtendedMockito.mockitoSession().mockStatic( - Cipher.class).startMocking(); - try { - when(Cipher.getInstance(anyString())).thenReturn(cipher); - when(cipher.doFinal(any(byte[].class))).thenReturn(imsi.getBytes()); - when(mDataTelephonyManager.getSubscriberId()).thenReturn(imsi); - when(mDataTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_READY); - when(mDataTelephonyManager.getSimOperator()).thenReturn("321456"); - ImsiEncryptionInfo info = new ImsiEncryptionInfo("321", "456", - TelephonyManager.KEY_TYPE_WLAN, keyIdentifier, key, null); - when(mDataTelephonyManager.getCarrierInfoForImsiEncryption( - eq(TelephonyManager.KEY_TYPE_WLAN))) - .thenReturn(info); - when(mCarrierNetworkConfig.getBase64EncodingFlag()).thenReturn(flag); assertEquals(expectedIdentity, TelephonyUtil.getSimIdentity(mTelephonyManager, mTelephonyUtil, @@ -293,30 +200,6 @@ public class TelephonyUtilTest { } } - /** - * Verify that {@code null} will be returned when IMSI encryption failed because - * the sequence of EAP identity is not valid. - */ - @Test - public void getEncryptedIdentityFailedWithInvalidEapIdentitySequence() throws Exception { - final Pair<String, String> expectedIdentity = Pair.create( - "03214561234567890@wlan.mnc456.mcc321.3gppnetwork.org", ""); - - when(mDataTelephonyManager.getSubscriberId()).thenReturn("3214561234567890"); - when(mDataTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_READY); - when(mDataTelephonyManager.getSimOperator()).thenReturn("321456"); - ImsiEncryptionInfo info = new ImsiEncryptionInfo("321", "456", - TelephonyManager.KEY_TYPE_WLAN, null, (PublicKey) null, null); - when(mDataTelephonyManager.getCarrierInfoForImsiEncryption( - eq(TelephonyManager.KEY_TYPE_WLAN))) - .thenReturn(info); - when(mCarrierNetworkConfig.getEapIdentitySequence()).thenReturn(-1); - - assertNull(TelephonyUtil.getSimIdentity(mTelephonyManager, mTelephonyUtil, - WifiConfigurationTestUtil.createEapNetwork(WifiEnterpriseConfig.Eap.AKA, - WifiEnterpriseConfig.Phase2.NONE), mCarrierNetworkConfig)); - } - @Test public void getSimIdentity2DigitMnc() { final Pair<String, String> expectedIdentity = Pair.create( |