summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/CarrierNetworkConfigTest.java79
-rw-r--r--tests/wifitests/src/com/android/server/wifi/CarrierNetworkEvaluatorTest.java7
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java1
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java1
-rw-r--r--tests/wifitests/src/com/android/server/wifi/util/TelephonyUtilTest.java123
5 files changed, 10 insertions, 201 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..963156dc8 100644
--- a/tests/wifitests/src/com/android/server/wifi/CarrierNetworkEvaluatorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/CarrierNetworkEvaluatorTest.java
@@ -53,6 +53,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
/**
* Unit tests for CarrierNeteworkEvaluator
*/
@@ -160,8 +161,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);
@@ -259,7 +258,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 +398,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..1837acb7d 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -1027,7 +1027,6 @@ public class ClientModeImplTest {
triggerConnect();
when(mCarrierNetworkConfig.isCarrierEncryptionInfoAvailable()).thenReturn(true);
- when(mCarrierNetworkConfig.isSupportAnonymousIdentity()).thenReturn(true);
when(mWifiConfigManager.getScanDetailCacheForNetwork(FRAMEWORK_NETWORK_ID))
.thenReturn(mScanDetailCache);
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(