diff options
author | Roshan Pius <rpius@google.com> | 2017-06-23 04:33:16 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-06-23 04:33:16 +0000 |
commit | afd768be6e45c0b00650102746cfd8a357e45418 (patch) | |
tree | d73a959f590ac1960af5a4ca31b9ef8935c1689a /tests | |
parent | a41c1f922772269a121e51dd69c628f363412b23 (diff) | |
parent | 327bd4253115abc757ebaf5f1bddd9f5ad2253e4 (diff) |
WifiConfigManager: Ignore masked EAP passwords
am: 327bd42531
Change-Id: I1afde2ef3efa9beba367659603921d57b162ef16
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java | 44 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java | 1 |
2 files changed, 45 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index e85686fa7..9fa67a000 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -1381,6 +1381,50 @@ public class WifiConfigManagerTest { } /** + * Verifies that if the app sends back the masked passwords in an update, we ignore it. + */ + @Test + public void testUpdateIgnoresMaskedPasswords() { + WifiConfiguration someRandomNetworkWithAllMaskedFields = + WifiConfigurationTestUtil.createEapNetwork(); + someRandomNetworkWithAllMaskedFields.wepKeys = WifiConfigurationTestUtil.TEST_WEP_KEYS; + someRandomNetworkWithAllMaskedFields.preSharedKey = WifiConfigurationTestUtil.TEST_PSK; + someRandomNetworkWithAllMaskedFields.enterpriseConfig.setPassword( + WifiConfigurationTestUtil.TEST_EAP_PASSWORD); + + NetworkUpdateResult result = + verifyAddNetworkToWifiConfigManager(someRandomNetworkWithAllMaskedFields); + + // All of these passwords must be masked in this retrieved network config. + WifiConfiguration retrievedNetworkWithMaskedPassword = + mWifiConfigManager.getConfiguredNetwork(result.getNetworkId()); + assertPasswordsMaskedInWifiConfiguration(retrievedNetworkWithMaskedPassword); + // Ensure that the passwords are present internally. + WifiConfiguration retrievedNetworkWithPassword = + mWifiConfigManager.getConfiguredNetworkWithPassword(result.getNetworkId()); + assertEquals(someRandomNetworkWithAllMaskedFields.preSharedKey, + retrievedNetworkWithPassword.preSharedKey); + assertEquals(someRandomNetworkWithAllMaskedFields.wepKeys, + retrievedNetworkWithPassword.wepKeys); + assertEquals(someRandomNetworkWithAllMaskedFields.enterpriseConfig.getPassword(), + retrievedNetworkWithPassword.enterpriseConfig.getPassword()); + + // Now update the same network config using the masked config. + verifyUpdateNetworkToWifiConfigManager(retrievedNetworkWithMaskedPassword); + + // Retrieve the network config with password and ensure that they have not been overwritten + // with *. + retrievedNetworkWithPassword = + mWifiConfigManager.getConfiguredNetworkWithPassword(result.getNetworkId()); + assertEquals(someRandomNetworkWithAllMaskedFields.preSharedKey, + retrievedNetworkWithPassword.preSharedKey); + assertEquals(someRandomNetworkWithAllMaskedFields.wepKeys, + retrievedNetworkWithPassword.wepKeys); + assertEquals(someRandomNetworkWithAllMaskedFields.enterpriseConfig.getPassword(), + retrievedNetworkWithPassword.enterpriseConfig.getPassword()); + } + + /** * Verifies the ordering of network list generated using * {@link WifiConfigManager#retrievePnoNetworkList()}. */ diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java index b53732a91..f7bf5b022 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java @@ -65,6 +65,7 @@ public class WifiConfigurationTestUtil { public static final String[] TEST_WEP_KEYS = {"\"WifiConfigurationTestUtilWep1\"", "\"WifiConfigurationTestUtilWep2\"", "45342312ab", "45342312ab45342312ab34ac12"}; + public static final String TEST_EAP_PASSWORD = "WifiConfigurationTestUtilEapPassword"; public static final int TEST_WEP_TX_KEY_INDEX = 1; public static final String TEST_FQDN = "WifiConfigurationTestUtilFQDN"; public static final String TEST_PROVIDER_FRIENDLY_NAME = |