diff options
author | Peter Qiu <zqiu@google.com> | 2017-04-10 20:35:50 +0900 |
---|---|---|
committer | Peter Qiu <zqiu@google.com> | 2017-05-23 09:50:17 -0700 |
commit | e7dfd69fbe21902b89124b99d914ed3c90ba8baf (patch) | |
tree | 018055837d786362456c1e0428178e875d535c3e /tests | |
parent | a37ddaead71747d1efe44504efd4ebaebe3a825c (diff) |
Avoid selecting EAP-SIM/AKA/AKA' networks when SIM is not ready
Avoid continuous authentication failure caused by selecting
EAP-SIM/AKA/AKA' networks when SIM card is not ready.
Should check SIM card status before selecting EAP networks.
Bug: 38357575
Test: Manual
Change-Id: I2358ce89dabdad8d3fc8eb363fb0ff653739bdc9
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java | 26 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java | 65 |
2 files changed, 91 insertions, 0 deletions
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 2224486ba..9f61ca09c 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java @@ -333,4 +333,30 @@ public class PasspointNetworkEvaluatorTest { assertEquals(ScanResultUtil.createQuotedSSID(TEST_SSID2), config.SSID); assertEquals(TEST_NETWORK_ID, config.networkId); } + + /** + * Verify that null will be returned when matching a SIM credential provider without SIM + * card installed. + * + * @throws Exception + */ + @Test + public void evaluateScanMatchingSIMProviderWithoutSIMCard() throws Exception { + // Setup ScanDetail and match providers. + List<ScanDetail> scanDetails = Arrays.asList(new ScanDetail[] { + generateScanDetail(TEST_SSID1)}); + PasspointProvider testProvider = mock(PasspointProvider.class); + Pair<PasspointProvider, PasspointMatch> homeProvider = Pair.create( + testProvider, PasspointMatch.HomeProvider); + + List<Pair<ScanDetail, WifiConfiguration>> connectableNetworks = new ArrayList<>(); + when(mPasspointManager.matchProvider(any(ScanResult.class))).thenReturn(homeProvider); + when(testProvider.isSimCredential()).thenReturn(true); + when(mWifiConfigManager.isSimPresent()).thenReturn(false); + assertEquals(null, mEvaluator.evaluateNetworks( + scanDetails, null, null, false, false, connectableNetworks)); + assertTrue(connectableNetworks.isEmpty()); + verify(testProvider, never()).getWifiConfig(); + + } } diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java index c416a961a..15f8471e0 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java @@ -898,4 +898,69 @@ public class PasspointProviderTest { assertEquals(passpointConfig, PasspointProvider.convertFromWifiConfig(wifiConfig)); } + /** + * Verify that {@link PasspointProvider#isSimCredential} will return true for provider that's + * backed by a SIM credential. + * + * @throws Exception + */ + @Test + public void providerBackedBySimCredential() throws Exception { + // Test data. + String fqdn = "test.com"; + String friendlyName = "Friendly Name"; + long[] rcOIs = new long[] {0x1234L, 0x2345L}; + String realm = "realm.com"; + String imsi = "1234*"; + + // Create provider with SIM credential. + PasspointConfiguration config = new PasspointConfiguration(); + HomeSp homeSp = new HomeSp(); + homeSp.setFqdn(fqdn); + homeSp.setFriendlyName(friendlyName); + homeSp.setRoamingConsortiumOis(rcOIs); + config.setHomeSp(homeSp); + Credential credential = new Credential(); + credential.setRealm(realm); + Credential.SimCredential simCredential = new Credential.SimCredential(); + simCredential.setImsi(imsi); + simCredential.setEapType(EAPConstants.EAP_SIM); + credential.setSimCredential(simCredential); + config.setCredential(credential); + mProvider = createProvider(config); + + assertTrue(mProvider.isSimCredential()); + } + + /** + * Verify that {@link PasspointProvider#isSimCredential} will return false for provider that's + * not backed by a SIM credential. + * + * @throws Exception + */ + @Test + public void providerNotBackedBySimCredential() throws Exception { + // Test data. + String fqdn = "test.com"; + String friendlyName = "Friendly Name"; + long[] rcOIs = new long[] {0x1234L, 0x2345L}; + String realm = "realm.com"; + + // Create provider with certificate credential. + PasspointConfiguration config = new PasspointConfiguration(); + HomeSp homeSp = new HomeSp(); + homeSp.setFqdn(fqdn); + homeSp.setFriendlyName(friendlyName); + homeSp.setRoamingConsortiumOis(rcOIs); + config.setHomeSp(homeSp); + Credential credential = new Credential(); + Credential.CertificateCredential certCredential = new Credential.CertificateCredential(); + certCredential.setCertType(Credential.CertificateCredential.CERT_TYPE_X509V3); + credential.setCertCredential(certCredential); + credential.setRealm(realm); + config.setCredential(credential); + mProvider = createProvider(config); + + assertFalse(mProvider.isSimCredential()); + } } |