summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-06-23 12:22:54 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-06-23 12:22:54 +0000
commit0ff336df32d1a657e5578ede99ade1e1f126a97a (patch)
treeaf1bca8dc1173ca401cd90d2db794d70c569be76 /tests
parentcf26794139d7166550bdfb9f7d0d06be2a14ac6e (diff)
parent327bd4253115abc757ebaf5f1bddd9f5ad2253e4 (diff)
WifiConfigManager: Ignore masked EAP passwords
am: 327bd42531 Change-Id: I634165bae53faab3a777fa0dafcbb48ed3e21db4
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java44
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java1
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 =