diff options
author | Randy Pan <zpan@google.com> | 2016-02-02 16:27:52 -0800 |
---|---|---|
committer | Randy Pan <zpan@google.com> | 2016-02-09 11:11:14 -0800 |
commit | 3571366ac36c70746b9f013ec2b54482861c9292 (patch) | |
tree | 2f21536a99c97793c08b92d176e71fba507963db /tests | |
parent | 5f38b29b5f4b891e59e8c20b210fa9e0e0a28440 (diff) |
Build 'capabilities' string for gscan results
Populate the WiFi beacon capability information from gscan to
WifiNative. Build ScanResult 'capabilities' string based on this
value and the information elements.
Add unit tests.
Bug: 26908033
Bug: 26908558
Change-Id: I661bb501a09d3e79ee0b0a8e141e7e47c72687f7
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java index 33ba3d1a6..c7b5752e3 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java @@ -27,6 +27,7 @@ import org.junit.Test; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Arrays; +import java.util.BitSet; /** * Unit tests for {@link com.android.server.wifi.util.InformationElementUtil}. @@ -236,4 +237,109 @@ public class InformationElementUtilTest { assertEquals("First result should have data set to 0x00", invalidLengthTagWithSSIDBytes[2], results[0].bytes[0]); } + + /** + * Test Capabilities.buildCapabilities() with a RSN IE. + * Expect the function to return a string with the proper security information. + * + */ + @Test + public void buildCapabilities_rsnElement() { + InformationElement ie = new InformationElement(); + ie.id = InformationElement.EID_RSN; + ie.bytes = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x0F, + (byte) 0xAC, (byte) 0x02, (byte) 0x02, (byte) 0x00, + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x04, + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x02, + (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x0F, + (byte) 0xAC, (byte) 0x02, (byte) 0x00, (byte) 0x00 }; + + InformationElement[] ies = new InformationElement[] { ie }; + + BitSet beaconCap = new BitSet(16); + beaconCap.set(4); + + String result = InformationElementUtil.Capabilities.buildCapabilities(ies, beaconCap); + + assertEquals("[WPA2-PSK]", result); + } + + /** + * Test Capabilities.buildCapabilities() with a WPA type 1 IE. + * Expect the function to return a string with the proper security information. + * + */ + @Test + public void buildCapabilities_wpa1Element() { + InformationElement ie = new InformationElement(); + ie.id = InformationElement.EID_VSA; + ie.bytes = new byte[] { (byte) 0x00, (byte) 0x50, (byte) 0xF2, (byte) 0x01, + (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x50, + (byte) 0xF2, (byte) 0x02, (byte) 0x02, (byte) 0x00, + (byte) 0x00, (byte) 0x50, (byte) 0xF2, (byte) 0x04, + (byte) 0x00, (byte) 0x50, (byte) 0xF2, (byte) 0x02, + (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x50, + (byte) 0xF2, (byte) 0x02, (byte) 0x00, (byte) 0x00 }; + + InformationElement[] ies = new InformationElement[] { ie }; + + BitSet beaconCap = new BitSet(16); + beaconCap.set(4); + + String result = InformationElementUtil.Capabilities.buildCapabilities(ies, beaconCap); + + assertEquals("[WPA-PSK]", result); + } + + /** + * Test Capabilities.buildCapabilities() with a vendor specific element which + * is not WPA type 1 however. Beacon Capability Information field has the Privacy + * bit set. + * + * Expect the function to return a string with the proper security information. + * + */ + @Test + public void buildCapabilities_nonRsnWpa1Element_privacySet() { + InformationElement ie = new InformationElement(); + ie.id = InformationElement.EID_VSA; + ie.bytes = new byte[] { (byte) 0x00, (byte) 0x04, (byte) 0x0E, (byte) 0x01, + (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x00, + (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }; + + InformationElement[] ies = new InformationElement[] { ie }; + + BitSet beaconCap = new BitSet(16); + beaconCap.set(4); + + String result = InformationElementUtil.Capabilities.buildCapabilities(ies, beaconCap); + + assertEquals("[WEP]", result); + } + + /** + * Test Capabilities.buildCapabilities() with a vendor specific element which + * is not WPA type 1 however. Beacon Capability Information field doesn't have the + * Privacy bit set. + * + * Expect the function to return a string with the proper security information. + * + */ + @Test + public void buildCapabilities_nonRsnWpa1Element_privacyClear() { + InformationElement ie = new InformationElement(); + ie.id = InformationElement.EID_VSA; + ie.bytes = new byte[] { (byte) 0x00, (byte) 0x04, (byte) 0x0E, (byte) 0x01, + (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x00, + (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }; + + InformationElement[] ies = new InformationElement[] { ie }; + + BitSet beaconCap = new BitSet(16); + beaconCap.clear(4); + + String result = InformationElementUtil.Capabilities.buildCapabilities(ies, beaconCap); + + assertEquals("", result); + } } |