2018-07-17 23:16:06 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
from time import sleep
|
|
|
|
|
|
|
|
sys.path.append('../util')
|
|
|
|
import iwd
|
|
|
|
from iwd import IWD
|
|
|
|
import testutil
|
|
|
|
|
|
|
|
class Test(unittest.TestCase):
|
|
|
|
|
2019-03-15 22:48:56 +01:00
|
|
|
def validate_connection(self, wd):
|
2018-07-17 23:16:06 +02:00
|
|
|
dev1, dev2 = wd.list_devices(2)
|
|
|
|
|
|
|
|
self.assertIsNotNone(dev1)
|
|
|
|
self.assertIsNotNone(dev2)
|
|
|
|
|
|
|
|
dev1.start_adhoc("AdHocNetwork", "secret123")
|
|
|
|
sleep(1)
|
|
|
|
dev2.start_adhoc("AdHocNetwork", "InvalidPassword")
|
2019-03-15 22:48:56 +01:00
|
|
|
#TODO: This test is unfinished.
|
2018-07-17 23:16:06 +02:00
|
|
|
|
|
|
|
# dev1.adhoc_wait_for_connected(dev2.address)
|
|
|
|
# dev2.adhoc_wait_for_connected(dev1.address)
|
|
|
|
|
|
|
|
# testutil.test_iface_operstate(dev1.name)
|
|
|
|
# testutil.test_iface_operstate(dev2.name)
|
|
|
|
# testutil.test_ifaces_connected(dev1.name, dev2.name)
|
|
|
|
|
2019-03-15 22:48:56 +01:00
|
|
|
def test_connection_failure(self):
|
|
|
|
wd = IWD(True)
|
|
|
|
|
2019-04-20 22:29:05 +02:00
|
|
|
self.validate_connection(wd)
|
2018-10-19 20:39:38 +02:00
|
|
|
|
2018-07-17 23:16:06 +02:00
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
IWD.clear_storage()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main(exit=True)
|