summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/util/NativeUtilTest.java31
1 files changed, 31 insertions, 0 deletions
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 79dcccfcc..d4bcb479e 100644
--- a/tests/wifitests/src/com/android/server/wifi/util/NativeUtilTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/util/NativeUtilTest.java
@@ -128,6 +128,18 @@ public class NativeUtilTest {
}
/**
+ * Test that conversion of SSID string with len > 32 to bytes fail.
+ */
+ @Test
+ public void testLargeSsidDecodeFails() throws Exception {
+ try {
+ NativeUtil.decodeSsid("\"asdrewqdfgyuiopldsqwertyuiolhdergcv\"");
+ fail("Expected ssid decode to fail");
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ /**
* Test that conversion of ssid bytes to hex string ssid works.
*/
@Test
@@ -178,6 +190,25 @@ public class NativeUtilTest {
}
/**
+ * Test that conversion of SSID bytes with len > 32 to string fail.
+ */
+ @Test
+ public void testLargeSsidEncodeFails() throws Exception {
+ try {
+ NativeUtil.encodeSsid(new ArrayList<>(
+ Arrays.asList((byte) 0xf5, (byte) 0xe4, (byte) 0xab, (byte) 0x78, (byte) 0x78,
+ (byte) 0xab, (byte) 0x34, (byte) 0x32, (byte) 0x43, (byte) 0x9a,
+ (byte) 0xab, (byte) 0x34, (byte) 0x32, (byte) 0x43, (byte) 0x9a,
+ (byte) 0xab, (byte) 0x34, (byte) 0x32, (byte) 0x43, (byte) 0x9a,
+ (byte) 0xab, (byte) 0x34, (byte) 0x32, (byte) 0x43, (byte) 0x9a,
+ (byte) 0xab, (byte) 0x34, (byte) 0x32, (byte) 0x43, (byte) 0x9a,
+ (byte) 0xab, (byte) 0x34, (byte) 0x32, (byte) 0x43, (byte) 0x9a)));
+ fail("Expected ssid encode to fail");
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ /**
* Test that parsing of quoted SSID to byte array and vice versa works.
*/
@Test