diff options
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 c49f406e1..6996a5825 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -1400,6 +1400,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 d58b1f953..b9afce47f 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java @@ -66,6 +66,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 = |