diff options
author | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-03-04 06:47:50 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-03-04 06:47:50 +0000 |
commit | 8d09985a39b9202804453c62a623fe0ba25afbea (patch) | |
tree | c764a4b60c72849c752e122da33f7eb60a73522b /wifi/tests | |
parent | 341fefcc34404ea6bd940eafe6f5057a31853811 (diff) | |
parent | 96a9e48520fc2359a3cdd6b3513bf158d6844365 (diff) |
Create different KeyId for saved and suggestion network am: 96a9e48520
Change-Id: I8cb4a11ca9ccf6b6516fd76e93dfe0795276f788
Diffstat (limited to 'wifi/tests')
-rw-r--r-- | wifi/tests/src/android/net/wifi/WifiConfigurationTest.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/wifi/tests/src/android/net/wifi/WifiConfigurationTest.java b/wifi/tests/src/android/net/wifi/WifiConfigurationTest.java index f3e8351587bc..f9bd6bb4e230 100644 --- a/wifi/tests/src/android/net/wifi/WifiConfigurationTest.java +++ b/wifi/tests/src/android/net/wifi/WifiConfigurationTest.java @@ -352,6 +352,67 @@ public class WifiConfigurationTest { } /** + * Verifies that getKeyIdForCredentials returns the expected string for Suggestion Enterprise + * networks + * @throws Exception + */ + @Test + public void testGetKeyIdForCredentialsForSuggestion() throws Exception { + WifiConfiguration config = new WifiConfiguration(); + final String mSsid = "TestAP"; + final String packageName = "TestApp"; + final String bSsid = MacAddress.createRandomUnicastAddress().toString(); + String suggestionSuffix = "_" + bSsid + "_" + packageName; + config.SSID = mSsid; + config.fromWifiNetworkSuggestion = true; + config.creatorName = packageName; + config.BSSID = bSsid; + + // Test various combinations + // EAP with TLS + config.allowedKeyManagement.set(KeyMgmt.WPA_EAP); + config.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TLS); + config.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.NONE); + String keyId = config.getKeyIdForCredentials(config); + assertEquals(keyId, mSsid + "_WPA_EAP_TLS_NULL" + suggestionSuffix); + + // EAP with TTLS & MSCHAPv2 + config.allowedKeyManagement.set(KeyMgmt.WPA_EAP); + config.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TTLS); + config.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.MSCHAPV2); + keyId = config.getKeyIdForCredentials(config); + assertEquals(keyId, mSsid + "_WPA_EAP_TTLS_MSCHAPV2" + suggestionSuffix); + + // Suite-B 192 with PWD & GTC + config.allowedKeyManagement.clear(); + config.allowedKeyManagement.set(KeyMgmt.SUITE_B_192); + config.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.PWD); + config.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.GTC); + keyId = config.getKeyIdForCredentials(config); + assertEquals(keyId, mSsid + "_SUITE_B_192_PWD_GTC" + suggestionSuffix); + + // IEEE8021X with SIM + config.allowedKeyManagement.clear(); + config.allowedKeyManagement.set(KeyMgmt.IEEE8021X); + config.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.SIM); + config.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.NONE); + keyId = config.getKeyIdForCredentials(config); + assertEquals(keyId, mSsid + "_IEEE8021X_SIM_NULL" + suggestionSuffix); + + // Try calling this method with non-Enterprise network, expect an exception + boolean exceptionThrown = false; + try { + config.allowedKeyManagement.clear(); + config.allowedKeyManagement.set(KeyMgmt.WPA2_PSK); + config.preSharedKey = "TestPsk"; + keyId = config.getKeyIdForCredentials(config); + } catch (IllegalStateException e) { + exceptionThrown = true; + } + assertTrue(exceptionThrown); + } + + /** * Verifies that getSsidAndSecurityTypeString returns the correct String for networks of * various different security types */ |