summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHai Shalom <haishalom@google.com>2019-12-26 16:12:08 -0800
committerHai Shalom <haishalom@google.com>2019-12-27 10:14:07 -0800
commitecd58085c1e1c53560144d0c8232fb23c1561371 (patch)
treee0d45c71cdc27254bec5eefa8c1da6ed8e51d39e /tests
parent9859a4b6d2455f2aabd6a15f9b8f9cd2ba6d9337 (diff)
[Encrypted IMSI] Add support for EAP Method prefix
Add support for EAP method prefix in the anonymous identity used during EAP-SIM/AKA/AKA' authentication when encrypted IMSI is used. Added a new boolean field enable_eap_method_prefix_bool in CarrierConfig, set to False as default. Bug: 142915637 Test: atest TelephonyUtilTest Change-Id: I29d4302a684857b5c4de984b8a3e7f222c0b9ebc
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/util/TelephonyUtilTest.java76
1 files changed, 74 insertions, 2 deletions
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 bd540805e..0ac7b6a2c 100644
--- a/tests/wifitests/src/com/android/server/wifi/util/TelephonyUtilTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/util/TelephonyUtilTest.java
@@ -93,7 +93,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
private static final String DATA_OPERATOR_NUMERIC = "123456";
private static final String NON_DATA_OPERATOR_NUMERIC = "123456";
private static final String NO_MATCH_OPERATOR_NUMERIC = "654321";
- private static final String TEST_SSID = "Test SSID";
+ private static final String ANONYMOUS_IDENTITY = "anonymous@wlan.mnc456.mcc123.3gppnetwork.org";
@Mock
CarrierConfigManager mCarrierConfigManager;
@@ -192,6 +192,15 @@ public class TelephonyUtilTest extends WifiBaseTest {
return bundle;
}
+ private PersistableBundle generateTestCarrierConfig(boolean requiresImsiEncryption,
+ boolean requiresEapMethodPrefix) {
+ PersistableBundle bundle = generateTestCarrierConfig(requiresImsiEncryption);
+ if (requiresEapMethodPrefix) {
+ bundle.putBoolean(CarrierConfigManager.ENABLE_EAP_METHOD_PREFIX_BOOL, true);
+ }
+ return bundle;
+ }
+
/**
* Verify getting value about that if the IMSI encryption is required or not when
* {@link CarrierConfigManager#ACTION_CARRIER_CONFIG_CHANGED} intent is received.
@@ -818,7 +827,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
@Test
public void getAnonymousIdentityWithSim() {
String mccmnc = "123456";
- String expectedIdentity = "anonymous@wlan.mnc456.mcc123.3gppnetwork.org";
+ String expectedIdentity = ANONYMOUS_IDENTITY;
when(mDataTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_READY);
when(mDataTelephonyManager.getSimOperator()).thenReturn(mccmnc);
WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
@@ -1255,4 +1264,67 @@ public class TelephonyUtilTest extends WifiBaseTest {
assertFalse(mTelephonyUtil.tryUpdateCarrierIdForPasspoint(spyConfig));
}
+
+ private void testIdentityWithSimAndEapAkaMethodPrefix(int method, String methodStr)
+ throws Exception {
+ when(mCarrierConfigManager.getConfigForSubId(DATA_SUBID))
+ .thenReturn(generateTestCarrierConfig(true, true));
+ when(mCarrierConfigManager.getConfigForSubId(NON_DATA_SUBID))
+ .thenReturn(generateTestCarrierConfig(false));
+ ArgumentCaptor<BroadcastReceiver> receiver =
+ ArgumentCaptor.forClass(BroadcastReceiver.class);
+ verify(mContext).registerReceiver(receiver.capture(), any(IntentFilter.class));
+
+ receiver.getValue().onReceive(mContext,
+ new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
+
+ assertTrue(mTelephonyUtil.requiresImsiEncryption(DATA_SUBID));
+
+ String mccmnc = "123456";
+ String expectedIdentity = methodStr + ANONYMOUS_IDENTITY;
+ when(mDataTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_READY);
+ when(mDataTelephonyManager.getSimOperator()).thenReturn(mccmnc);
+ WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
+ method, WifiEnterpriseConfig.Phase2.NONE);
+
+ assertEquals(expectedIdentity,
+ mTelephonyUtil.getAnonymousIdentityWith3GppRealm(config));
+ }
+
+ /**
+ * Verify that EAP Method prefix is added to the anonymous identity when required
+ */
+ @Test
+ public void getAnonymousIdentityWithSimAndEapAkaMethodPrefix() throws Exception {
+ testIdentityWithSimAndEapAkaMethodPrefix(WifiEnterpriseConfig.Eap.AKA, "0");
+ }
+
+ /**
+ * Verify that EAP Method prefix is added to the anonymous identity when required
+ */
+ @Test
+ public void getAnonymousIdentityWithSimAndEapSimMethodPrefix() throws Exception {
+ testIdentityWithSimAndEapAkaMethodPrefix(WifiEnterpriseConfig.Eap.SIM, "1");
+ }
+
+ /**
+ * Verify that EAP Method prefix is added to the anonymous identity when required
+ */
+ @Test
+ public void getAnonymousIdentityWithSimAndEapAkaPrimeMethodPrefix() throws Exception {
+ testIdentityWithSimAndEapAkaMethodPrefix(WifiEnterpriseConfig.Eap.AKA_PRIME, "6");
+ }
+
+ /**
+ * Verify that isAnonymousAtRealmIdentity works as expected for anonymous identities with and
+ * without a prefix.
+ */
+ @Test
+ public void testIsAnonymousAtRealmIdentity() throws Exception {
+ assertTrue(mTelephonyUtil.isAnonymousAtRealmIdentity(ANONYMOUS_IDENTITY));
+ assertTrue(mTelephonyUtil.isAnonymousAtRealmIdentity("0" + ANONYMOUS_IDENTITY));
+ assertTrue(mTelephonyUtil.isAnonymousAtRealmIdentity("1" + ANONYMOUS_IDENTITY));
+ assertTrue(mTelephonyUtil.isAnonymousAtRealmIdentity("6" + ANONYMOUS_IDENTITY));
+ assertFalse(mTelephonyUtil.isAnonymousAtRealmIdentity("AKA" + ANONYMOUS_IDENTITY));
+ }
}