3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-28 12:39:29 +01:00

auto-t: Verify DNS entries added from DHCP/static

Add a fake resolvconf executable to verify that the right nameserver
addresses were actually committed by iwd.  Again use unique nameserver
addresses to reduce the possibility that the test succeeds by pure luck.
This commit is contained in:
Andrew Zaborowski 2022-06-16 02:02:28 +02:00 committed by Denis Kenzior
parent c4fe900a71
commit 2c0bb06d1a
7 changed files with 35 additions and 5 deletions

View File

@ -77,6 +77,14 @@ class Test(unittest.TestCase):
self.assertEqual(expected_routes4, set(testutil.get_routes4(ifname)))
self.assertEqual(expected_routes6, set(testutil.get_routes6(ifname)))
rclog = open('/tmp/resolvconf.log', 'r')
entries = rclog.readlines()
rclog.close()
expected_rclog = ['-a wlan1.dns\n', 'nameserver 192.168.1.2\n', 'nameserver 3ffe:501:ffff:100::2\n']
# Every real resolvconf -a run overwrites the previous settings. Check the last three lines
# of our log since we care about the end result here.
self.assertEqual(expected_rclog, entries[-3:])
device.disconnect()
condition = 'not obj.connected'
@ -133,6 +141,10 @@ class Test(unittest.TestCase):
config.close()
cls.radvd_pid = ctx.start_process(['radvd', '-n', '-d5', '-p', '/tmp/radvd.pid', '-C', '/tmp/radvd.conf'])
cls.orig_path = os.environ['PATH']
os.environ['PATH'] = '/tmp/test-bin:' + os.environ['PATH']
IWD.copy_to_storage('resolvconf', '/tmp/test-bin')
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
@ -142,7 +154,8 @@ class Test(unittest.TestCase):
cls.dhcpd6_pid = None
ctx.stop_process(cls.radvd_pid)
cls.radvd_pid = None
os.remove('/tmp/radvd.conf')
os.system('rm -rf /tmp/radvd.conf /tmp/resolvconf.log /tmp/test-bin')
os.environ['PATH'] = cls.orig_path
if __name__ == '__main__':
unittest.main(exit=True)

View File

@ -1,6 +1,6 @@
subnet6 3ffe:501:ffff:100::/72
{
option dhcp6.name-servers 3ffe:501:ffff:100::1;
option dhcp6.name-servers 3ffe:501:ffff:100::2;
range6 3ffe:501:ffff:100::10 3ffe:501:ffff:100::20;
range6 3ffe:501:ffff:100::100 3ffe:501:ffff:100::200;
}

View File

@ -9,7 +9,7 @@ subnet 192.168.0.0 netmask 255.255.128.0
{
option routers 192.168.1.1;
option subnet-mask 255.255.128.0;
option domain-name-servers 192.168.1.1;
option domain-name-servers 192.168.1.2;
range 192.168.1.10 192.168.1.20;
range 192.168.1.100 192.168.1.200;
}

View File

@ -3,4 +3,4 @@ EnableNetworkConfiguration=true
[Network]
EnableIPv6=true
NameResolvingService=none
NameResolvingService=resolvconf

View File

@ -0,0 +1,2 @@
#! /bin/sh
(echo "$*" ; [ "$1" = -a ] && cat) >> /tmp/resolvconf.log 2> /dev/null

View File

@ -4,11 +4,13 @@
Address=192.168.1.10
Netmask=255.255.255.128
Gateway=192.168.1.3
DNS=192.168.1.4
[IPv6]
# Use a different subnet than DHCP on purpose
Address=3ffe:501:ffff:200::10/80
Gateway=3ffe:501:ffff:200::3
DNS=3ffe:501:ffff:200::4
[Settings]
AutoConnect=false

View File

@ -72,6 +72,14 @@ class Test(unittest.TestCase):
self.assertEqual(expected_routes4, set(testutil.get_routes4(ifname)))
self.assertEqual(expected_routes6, set(testutil.get_routes6(ifname)))
rclog = open('/tmp/resolvconf.log', 'r')
entries = rclog.readlines()
rclog.close()
expected_rclog = ['-a wlan1.dns\n', 'nameserver 192.168.1.4\n', 'nameserver 3ffe:501:ffff:200::4\n']
# Every resolvconf -a run overwrites the previous settings. Check the last three lines
# of the log since we care about the end result here.
self.assertEqual(expected_rclog, entries[-3:])
ordered_network = dev2.get_ordered_network('ssidTKIP')
condition = 'not obj.connected'
@ -121,10 +129,15 @@ class Test(unittest.TestCase):
hapd.ifname], cleanup=remove_lease)
IWD.copy_to_storage('ssidTKIP.psk', '/tmp/storage')
cls.orig_path = os.environ['PATH']
os.environ['PATH'] = '/tmp/test-bin:' + os.environ['PATH']
IWD.copy_to_storage('resolvconf', '/tmp/test-bin')
@classmethod
def tearDownClass(cls):
IWD.clear_storage(storage_dir='/tmp/storage')
cls.dhcpd_pid.kill()
os.system('rm -rf /tmp/resolvconf.log /tmp/test-bin /tmp/storage')
os.environ['PATH'] = cls.orig_path
if __name__ == '__main__':
unittest.main(exit=True)