diff options
author | Roshan Pius <rpius@google.com> | 2018-05-07 15:27:53 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-05-07 15:27:53 +0000 |
commit | 0234ca3935341d612f6fbfed2cc53a743fee3bcd (patch) | |
tree | 9cd0a5374c5c50c8ea373e8b3fc8c22717621759 /tests | |
parent | 430be97a7c41bfa7538ebeec1d5667281a8edf73 (diff) | |
parent | c7b445ba6b5b5916d47daf22a77e6f67de3fc5f4 (diff) |
Merge "WifiConfigurationUtil: Validate UTF-8 ssid length correctly" into pi-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java | 14 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/util/NativeUtilTest.java | 12 |
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java index eb498e9d6..7bb24371a 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java @@ -265,6 +265,20 @@ public class WifiConfigurationUtilTest { } /** + * Verify that the validate method fails to validate WifiConfiguration with bad ssid length. + */ + @Test + public void testValidateNegativeCases_BadUtf8SsidLength() { + WifiConfiguration config = WifiConfigurationTestUtil.createOpenNetwork(); + assertTrue(WifiConfigurationUtil.validate(config, WifiConfigurationUtil.VALIDATE_FOR_ADD)); + + config.SSID = "\"가하아너너ㅓ저저ㅓ어아아다자저ㅓ더타아어어러두어\""; + assertFalse(WifiConfigurationUtil.validate(config, WifiConfigurationUtil.VALIDATE_FOR_ADD)); + config.SSID = "\"\""; + assertFalse(WifiConfigurationUtil.validate(config, WifiConfigurationUtil.VALIDATE_FOR_ADD)); + } + + /** * Verify that the validate method fails to validate WifiConfiguration with malformed ssid * string. */ diff --git a/tests/wifitests/src/com/android/server/wifi/util/NativeUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/NativeUtilTest.java index 367e6b34a..05b719cd2 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/NativeUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/NativeUtilTest.java @@ -113,6 +113,18 @@ public class NativeUtilTest { } /** + * Test that conversion of non utf-8 SSID string to bytes fail. + */ + @Test + public void testNonUtf8SsidDecodeFails() throws Exception { + try { + NativeUtil.decodeSsid("\"\ud800\""); + fail("Expected ssid decode to fail"); + } catch (IllegalArgumentException e) { + } + } + + /** * Test that conversion of ssid bytes to hex string ssid works. */ @Test |