diff options
author | Pankaj Kanwar <pkanwar@google.com> | 2018-03-10 02:07:50 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-03-10 02:07:50 +0000 |
commit | 2a9d2d2a914174c8af18358a8821a61d51e8b015 (patch) | |
tree | 29068983d5794d2258ecae44058ee03d5894fd73 /tests | |
parent | 4250c8679d9c4e97fcbb0503d20024557fa3678e (diff) | |
parent | 00162a310f759e17356db0b785e226383b7c6e62 (diff) |
Merge "Check if Imsi encryption keys are available" into pi-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/CarrierNetworkConfigTest.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/CarrierNetworkConfigTest.java b/tests/wifitests/src/com/android/server/wifi/CarrierNetworkConfigTest.java index 13d7aaf6e..b06c8a4b9 100644 --- a/tests/wifitests/src/com/android/server/wifi/CarrierNetworkConfigTest.java +++ b/tests/wifitests/src/com/android/server/wifi/CarrierNetworkConfigTest.java @@ -28,8 +28,10 @@ import android.net.wifi.WifiEnterpriseConfig; import android.os.PersistableBundle; import android.support.test.filters.SmallTest; import android.telephony.CarrierConfigManager; +import android.telephony.ImsiEncryptionInfo; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; +import android.telephony.TelephonyManager; import android.util.Base64; import org.junit.Before; @@ -38,6 +40,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import java.security.PublicKey; import java.util.Arrays; /** @@ -57,9 +60,14 @@ public class CarrierNetworkConfigTest { @Mock Context mContext; @Mock CarrierConfigManager mCarrierConfigManager; @Mock SubscriptionManager mSubscriptionManager; + @Mock TelephonyManager mTelephonyManager; + @Mock PublicKey mPublicKey; BroadcastReceiver mBroadcastReceiver; CarrierNetworkConfig mCarrierNetworkConfig; + private ImsiEncryptionInfo mImsiEncryptionInfo = new ImsiEncryptionInfo(null, null, 0, null, + mPublicKey, null); + /** * Generate and return a carrier config for testing * @@ -86,10 +94,13 @@ public class CarrierNetworkConfigTest { .thenReturn(mCarrierConfigManager); when(mContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)) .thenReturn(mSubscriptionManager); + when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager); when(mCarrierConfigManager.getConfigForSubId(TEST_SUBSCRIPTION_ID)) .thenReturn(generateTestConfig(TEST_SSID, TEST_STANDARD_EAP_TYPE)); when(mSubscriptionManager.getActiveSubscriptionInfoList()) .thenReturn(Arrays.asList(new SubscriptionInfo[] {TEST_SUBSCRIPTION_INFO})); + when(mTelephonyManager.getCarrierInfoForImsiEncryption(TelephonyManager.KEY_TYPE_WLAN)) + .thenReturn(mImsiEncryptionInfo); mCarrierNetworkConfig = new CarrierNetworkConfig(mContext); ArgumentCaptor<BroadcastReceiver> receiver = ArgumentCaptor.forClass(BroadcastReceiver.class); @@ -113,6 +124,24 @@ public class CarrierNetworkConfigTest { } /** + * Verify that {@link CarrierNetworkConfig#isCarrierNetwork} will return false when the given + * SSID is associated with a carrier network, but IMSI encryption info is not available. + * + * @throws Exception + */ + @Test + public void getExistingCarrierNetworkInfoWhenEncryptionInfoNotAvailable() throws Exception { + when(mCarrierConfigManager.getConfigForSubId(TEST_SUBSCRIPTION_ID)) + .thenReturn(generateTestConfig(TEST_SSID, TEST_STANDARD_EAP_TYPE)); + when(mTelephonyManager.getCarrierInfoForImsiEncryption(TelephonyManager.KEY_TYPE_WLAN)) + .thenReturn(null); + mBroadcastReceiver.onReceive(mContext, + new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)); + + assertFalse(mCarrierNetworkConfig.isCarrierNetwork(TEST_SSID)); + } + + /** * Verify that {@link CarrierNetworkConfig#isCarrierNetwork} will return false and * {@link CarrierNetworkConfig#getNetworkEapType} will return -1 when the given SSID is not * associated with any carrier network. |