diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2018-03-20 15:17:49 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-03-20 15:17:49 +0000 |
commit | d97b21167d22a9f01bbdfdce62e523896fcf0e52 (patch) | |
tree | 1f43fa68247fe50ac5baccdff3b5961c1add3cc7 /tests | |
parent | 81d6513f9cdea919940ca372fdc393d0a74c2746 (diff) | |
parent | e7df893234345aefd8efb25e45aa02c39644fcb2 (diff) |
Merge "WifiBackupRestore: Ignore unkown bitset values from backup" into pi-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java index aa99829b6..d6cce6250 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java @@ -83,6 +83,44 @@ public class WifiBackupRestoreTest { + "</NetworkList>" + "</WifiBackupData>"; + // |AllowedKeyMgmt|, |AllowedProtocols|, |AllowedAuthAlgorithms|, |AllowedGroupCiphers| and + // |AllowedPairwiseCiphers| fields have invalid values in them. + private static final String WIFI_BACKUP_DATA_WITH_UNSUPPORTED_VALUES_IN_BITSETS = + "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>" + + "<WifiBackupData>" + + "<int name=\"Version\" value=\"1\" />" + + "<NetworkList>" + + "<Network>" + + "<WifiConfiguration>" + + "<string name=\"ConfigKey\">"GoogleGuest-Legacy"NONE</string>" + + "<string name=\"SSID\">"GoogleGuest-Legacy"</string>" + + "<null name=\"BSSID\" />" + + "<null name=\"PreSharedKey\" />" + + "<null name=\"WEPKeys\" />" + + "<int name=\"WEPTxKeyIndex\" value=\"0\" />" + + "<boolean name=\"HiddenSSID\" value=\"false\" />" + + "<boolean name=\"RequirePMF\" value=\"false\" />" + // Valid Value: 01 + + "<byte-array name=\"AllowedKeyMgmt\" num=\"2\">0101</byte-array>" + // Valid Value: 03 + + "<byte-array name=\"AllowedProtocols\" num=\"1\">0b</byte-array>" + // Valid Value: 01 + + "<byte-array name=\"AllowedAuthAlgos\" num=\"1\">09</byte-array>" + // Valid Value: 0f + + "<byte-array name=\"AllowedGroupCiphers\" num=\"1\">2f</byte-array>" + // Valid Value: 06 + + "<byte-array name=\"AllowedPairwiseCiphers\" num=\"1\">0e</byte-array>" + + "<boolean name=\"Shared\" value=\"true\" />" + + "<null name=\"SimSlot\" />" + + "</WifiConfiguration>" + + "<IpConfiguration>" + + "<string name=\"IpAssignment\">DHCP</string>" + + "<string name=\"ProxySettings\">NONE</string>" + + "</IpConfiguration>" + + "</Network>" + + "</NetworkList>" + + "</WifiBackupData>"; + @Mock WifiPermissionsUtil mWifiPermissionsUtil; private WifiBackupRestore mWifiBackupRestore; private boolean mCheckDump = true; @@ -258,6 +296,59 @@ public class WifiBackupRestoreTest { } /** + * Verify that restoring of configuration that contains unsupported values in bitsets works + * correctly (unsupported values are ignored). + */ + @Test + public void testConfigurationWithUnsupportedValuesInBitsetsRestore() { + List<WifiConfiguration> configurations = new ArrayList<>(); + configurations.add(createNetworkForConfigurationWithUnsupportedValuesInBitsetsInRestore()); + + byte[] backupData = WIFI_BACKUP_DATA_WITH_UNSUPPORTED_VALUES_IN_BITSETS.getBytes(); + List<WifiConfiguration> retrievedConfigurations = + mWifiBackupRestore.retrieveConfigurationsFromBackupData(backupData); + WifiConfigurationTestUtil.assertConfigurationsEqualForBackup( + configurations, retrievedConfigurations); + + // No valid data to check in dump. + mCheckDump = false; + } + + /** + * Creates correct WiFiConfiguration that should be parsed out of + * {@link #WIFI_BACKUP_DATA_WITH_UNSUPPORTED_VALUES_IN_BITSETS} configuration which contains + * unsupported values. + * |AllowedKeyMgmt|, |AllowedProtocols|, |AllowedAuthAlgorithms|, |AllowedGroupCiphers| and + * |AllowedPairwiseCiphers| fields have invalid values in them. + */ + private static WifiConfiguration + createNetworkForConfigurationWithUnsupportedValuesInBitsetsInRestore() { + final WifiConfiguration config = new WifiConfiguration(); + config.SSID = "\"GoogleGuest-Legacy\""; + config.wepTxKeyIndex = 0; + config.hiddenSSID = false; + config.requirePMF = false; + config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); + config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); + config.allowedProtocols.set(WifiConfiguration.Protocol.RSN); + config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); + config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); + config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); + config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); + config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); + config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); + config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); + config.shared = true; + + IpConfiguration ipConfiguration = new IpConfiguration(); + ipConfiguration.setIpAssignment(IpConfiguration.IpAssignment.DHCP); + ipConfiguration.setProxySettings(IpConfiguration.ProxySettings.NONE); + config.setIpConfiguration(ipConfiguration); + + return config; + } + + /** * Verify that a single WEP network configuration with only 1 key is serialized & deserialized * correctly. */ |