3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 14:49:24 +01:00

auto-t: add profile based DHCP test

This commit is contained in:
James Prestwood 2020-11-04 08:48:10 -08:00 committed by Denis Kenzior
parent 2d45461dfd
commit da6b818a53
2 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1,10 @@
[Security]
Passphrase=password123
[IPv4]
Address=192.168.1.1
Gateway=192.168.1.1
Netmask=255.255.255.0
DNSList=192.168.1.1,192.168.1.2
LeaseTime=10
IPRange=192.168.1.3,192.168.1.100

View File

@ -0,0 +1,79 @@
#! /usr/bin/python3
import unittest
import sys, os
import iwd
from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
from config import ctx
import testutil
class Test(unittest.TestCase):
def test_connection_success(self):
# Using main.conf containing APRanges. The APConfig SSID should override
# this range.
wd = IWD(True, '/tmp/dhcp')
dev1, dev2 = wd.list_devices(2)
dev1.start_ap('APConfig')
try:
condition = 'not obj.scanning'
wd.wait_for_object_condition(dev2, condition)
dev2.scan()
condition = 'obj.scanning'
wd.wait_for_object_condition(dev2, condition)
condition = 'not obj.scanning'
wd.wait_for_object_condition(dev2, condition)
ordered_networks = dev2.get_ordered_networks()
networks = { n.name: n for n in ordered_networks }
self.assertEqual(networks['APConfig'].type, NetworkType.psk)
psk_agent = PSKAgent('password123')
wd.register_psk_agent(psk_agent)
try:
dev2.disconnect()
condition = 'not obj.connected'
wd.wait_for_object_condition(dev2, condition)
except:
pass
networks['APConfig'].network_object.connect()
condition = 'obj.state == DeviceState.connected'
wd.wait_for_object_condition(dev2, condition)
testutil.test_iface_operstate(dev2.name)
testutil.test_ifaces_connected(dev1.name, dev2.name, group=False)
testutil.test_ip_address_match(dev1.name, "192.168.1.1")
testutil.test_ip_address_match(dev2.name, "192.168.1.3")
wd.unregister_psk_agent(psk_agent)
dev2.disconnect()
condition = 'not obj.connected'
wd.wait_for_object_condition(networks['APConfig'].network_object,
condition)
finally:
dev1.stop_ap()
@classmethod
def setUpClass(cls):
IWD.copy_to_ap('dhcp/APConfig.ap')
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
if __name__ == '__main__':
unittest.main(exit=True)