commit c9d8346d40c53992062cfc98d775861b32258a8f
parent 862707f9435abfa25ce28968712f56cac2bccdae
Author: Andrew Zaborowski <andrew.zaborowski@intel.com>
Date: Fri, 30 Nov 2018 15:12:03 +0100
autotests: Test bad PSK password lengths
Diffstat:
1 file changed, 73 insertions(+), 0 deletions(-)
diff --git a/autotests/testWPA2/password_test.py b/autotests/testWPA2/password_test.py
@@ -0,0 +1,73 @@
+#!/usr/bin/python3
+
+import unittest
+import sys
+
+sys.path.append('../util')
+import iwd
+from iwd import IWD
+from iwd import PSKAgent
+from iwd import NetworkType
+import testutil
+
+class Test(unittest.TestCase):
+
+ def test_connection_success(self):
+ wd = IWD()
+
+ devices = wd.list_devices(1);
+ device = devices[0]
+
+ device.disconnect()
+ condition = 'obj.state == DeviceState.disconnected'
+ wd.wait_for_object_condition(device, condition)
+
+ condition = 'not obj.scanning'
+ wd.wait_for_object_condition(device, condition)
+
+ if not device.get_ordered_networks():
+ device.scan()
+ condition = 'obj.scanning'
+ wd.wait_for_object_condition(device, condition)
+ condition = 'not obj.scanning'
+ wd.wait_for_object_condition(device, condition)
+
+ ordered_networks = device.get_ordered_networks()
+ self.assertEqual(len(ordered_networks), 1)
+ ordered_network = ordered_networks[0]
+ self.assertEqual(ordered_network.name, "ssidCCMP")
+ self.assertEqual(ordered_network.type, NetworkType.psk)
+ network = ordered_network.network_object
+
+ # 0 chars
+ psk_agent = PSKAgent("")
+ wd.register_psk_agent(psk_agent)
+ self.assertRaises(iwd.NotSupportedEx, network.connect)
+ wd.unregister_psk_agent(psk_agent)
+
+ # 7 chars
+ psk_agent = PSKAgent("a" * 7)
+ wd.register_psk_agent(psk_agent)
+ self.assertRaises(iwd.NotSupportedEx, network.connect)
+ wd.unregister_psk_agent(psk_agent)
+
+ # 64 chars
+ psk_agent = PSKAgent("a" * 64)
+ wd.register_psk_agent(psk_agent)
+ self.assertRaises(iwd.NotSupportedEx, network.connect)
+ wd.unregister_psk_agent(psk_agent)
+
+ # 64k chars
+ psk_agent = PSKAgent("a" * 65536)
+ wd.register_psk_agent(psk_agent)
+ self.assertRaises(iwd.NotSupportedEx, network.connect)
+ wd.unregister_psk_agent(psk_agent)
+
+ del wd
+
+ @classmethod
+ def tearDownClass(cls):
+ IWD.clear_storage()
+
+if __name__ == '__main__':
+ unittest.main(exit=True)