summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-03-07 09:22:00 -0800
committerRoshan Pius <rpius@google.com>2017-03-08 08:04:43 -0800
commita63ab49c1d20d7a698537b5253d172a8dffc235f (patch)
tree86506f54c8dfae08b572a6f62be97d3c2fe17fe8 /tests
parentf50550926a7bddc24adf822876f35812d7d8c7be (diff)
WifiConfigManager: Add quotes back for psk
For user's who lost the quotes around their ASCII psk passphrase, add them back to be backward compatible. Bug: 36008106 Test: Unit tests Test: Verified manually updating a device which had previously lost it's quotes around psk. Change-Id: I6ef8ea2059ff044ba9e57d46bb50aa5ee7dcad9b
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java41
1 files changed, 41 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 4a2c4c288..a00458726 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -2497,6 +2497,47 @@ public class WifiConfigManagerTest {
}
/**
+ * Verifies the loading of networks using {@link WifiConfigManager#loadFromStore()}:
+ * - Adds quotes around unquoted ascii PSKs when loading form store.
+ * - Loads asciis quoted PSKs as they are.
+ * - Loads base64 encoded as they are.
+ */
+ @Test
+ public void testUnquotedAsciiPassphraseLoadFromStore() throws Exception {
+ WifiConfiguration pskNetworkWithNoQuotes = WifiConfigurationTestUtil.createPskNetwork();
+ pskNetworkWithNoQuotes.preSharedKey = "pskWithNoQuotes";
+ WifiConfiguration pskNetworkWithQuotes = WifiConfigurationTestUtil.createPskNetwork();
+ pskNetworkWithQuotes.preSharedKey = "\"pskWithQuotes\"";
+ WifiConfiguration pskNetworkWithHexString = WifiConfigurationTestUtil.createPskNetwork();
+ pskNetworkWithHexString.preSharedKey =
+ "945ef00c463c2a7c2496376b13263d1531366b46377179a4b17b393687450779";
+
+ List<WifiConfiguration> sharedNetworks = new ArrayList<WifiConfiguration>() {{
+ add(new WifiConfiguration(pskNetworkWithQuotes));
+ add(new WifiConfiguration(pskNetworkWithNoQuotes));
+ add(new WifiConfiguration(pskNetworkWithHexString));
+ }};
+ setupStoreDataForRead(sharedNetworks, new ArrayList<>(), new HashSet<String>());
+ assertTrue(mWifiConfigManager.loadFromStore());
+
+ verify(mWifiConfigStore).read();
+ verify(mWifiConfigStoreLegacy, never()).read();
+
+ List<WifiConfiguration> retrievedNetworks =
+ mWifiConfigManager.getConfiguredNetworksWithPasswords();
+
+ // The network with no quotes should now have quotes, the others should remain the same.
+ pskNetworkWithNoQuotes.preSharedKey = "\"pskWithNoQuotes\"";
+ List<WifiConfiguration> expectedNetworks = new ArrayList<WifiConfiguration>() {{
+ add(pskNetworkWithQuotes);
+ add(pskNetworkWithNoQuotes);
+ add(pskNetworkWithHexString);
+ }};
+ WifiConfigurationTestUtil.assertConfigurationsEqualForConfigStore(
+ expectedNetworks, retrievedNetworks);
+ }
+
+ /**
* Verifies that the last user selected network parameter is set when
* {@link WifiConfigManager#enableNetwork(int, boolean, int)} with disableOthers flag is set
* to true and cleared when either {@link WifiConfigManager#disableNetwork(int, int)} or