aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Prestwood <prestwoj@gmail.com>2020-03-19 15:59:02 -0700
committerDenis Kenzior <denkenz@gmail.com>2020-03-18 18:15:16 -0500
commite7a9a434109337ea1d5be69e7d1682b3371cf6bb (patch)
tree2798ead64c3019b3a1f76420914736b1fb38d768
parente10c6ada1203abe144830830f2314d1c9d870126 (diff)
downloadiwd-e7a9a434109337ea1d5be69e7d1682b3371cf6bb.tar.gz
auto-t: add test for AddressRandomization option
Tests all cases of AddressRandomization=network 1. Deterministic generation per-network (default) 2. Full randomization per-network 3. Address override per-network
-rw-r--r--autotests/testAddressRandomization/connection_test.py86
-rw-r--r--autotests/testAddressRandomization/full_random.psk6
-rw-r--r--autotests/testAddressRandomization/hw.conf7
-rw-r--r--autotests/testAddressRandomization/main.conf2
-rw-r--r--autotests/testAddressRandomization/override.psk6
-rw-r--r--autotests/testAddressRandomization/pernetwork.psk5
-rw-r--r--autotests/testAddressRandomization/ssidCCMP.conf7
7 files changed, 119 insertions, 0 deletions
diff --git a/autotests/testAddressRandomization/connection_test.py b/autotests/testAddressRandomization/connection_test.py
new file mode 100644
index 000000000..fab8fea9f
--- /dev/null
+++ b/autotests/testAddressRandomization/connection_test.py
@@ -0,0 +1,86 @@
+#!/usr/bin/python3
+
+import unittest
+import sys
+import os
+
+sys.path.append('../util')
+import iwd
+from iwd import IWD
+from iwd import NetworkType
+import testutil
+
+class Test(unittest.TestCase):
+ def try_connection(self, wd):
+ devices = wd.list_devices(1)
+ device = devices[0]
+
+ ordered_network = device.get_ordered_network('ssidCCMP')
+
+ self.assertEqual(ordered_network.type, NetworkType.psk)
+
+ condition = 'not obj.connected'
+ wd.wait_for_object_condition(ordered_network.network_object, condition)
+
+ ordered_network.network_object.connect()
+
+ condition = 'obj.connected'
+ wd.wait_for_object_condition(ordered_network.network_object, condition)
+
+ testutil.test_iface_operstate()
+ testutil.test_ifaces_connected()
+
+ device.disconnect()
+
+ condition = 'not obj.connected'
+ wd.wait_for_object_condition(ordered_network.network_object, condition)
+
+ return device.address
+
+ def test_connection_success(self):
+ wd = IWD(True)
+
+ devices = wd.list_devices(1)
+ device = devices[0]
+
+ perm_addr = device.address
+
+ condition = 'not obj.scanning'
+ wd.wait_for_object_condition(device, condition)
+
+ device.scan()
+
+ condition = 'not obj.scanning'
+ wd.wait_for_object_condition(device, condition)
+
+ # 1. Test per-network deterministic MAC generation
+ os.system('cat pernetwork.psk > /var/lib/iwd/ssidCCMP.psk')
+ new_addr = self.try_connection(wd)
+ self.assertNotEqual(perm_addr, new_addr)
+ # try again to ensure the generation was deterministic
+ new_addr2 = self.try_connection(wd)
+ self.assertEqual(new_addr, new_addr2)
+
+ # 2. Test FullAddressRandomization
+ os.system('cat full_random.psk > /var/lib/iwd/ssidCCMP.psk')
+ new_addr = self.try_connection(wd)
+ self.assertNotEqual(perm_addr, new_addr)
+ # try again to make sure the generation was random
+ new_addr2 = self.try_connection(wd)
+ self.assertNotEqual(new_addr, new_addr2)
+
+ # 3. Test AddressOverride
+ os.system('cat override.psk > /var/lib/iwd/ssidCCMP.psk')
+ new_addr = self.try_connection(wd)
+ self.assertEqual(new_addr, 'e6:f6:38:a9:02:02')
+
+ @classmethod
+ def setUpClass(cls):
+ pass
+
+ @classmethod
+ def tearDownClass(cls):
+ IWD.clear_storage()
+
+if __name__ == '__main__':
+ unittest.main(exit=True)
diff --git a/autotests/testAddressRandomization/full_random.psk b/autotests/testAddressRandomization/full_random.psk
new file mode 100644
index 000000000..579342874
--- /dev/null
+++ b/autotests/testAddressRandomization/full_random.psk
@@ -0,0 +1,6 @@
+[Security]
+Passphrase=secret123
+
+[Settings]
+AlwaysRandomizeAddress=true
+AutoConnect=false
diff --git a/autotests/testAddressRandomization/hw.conf b/autotests/testAddressRandomization/hw.conf
new file mode 100644
index 000000000..fa46c8b82
--- /dev/null
+++ b/autotests/testAddressRandomization/hw.conf
@@ -0,0 +1,7 @@
+[SETUP]
+num_radios=2
+start_iwd=0
+tmpfs_extra_stuff=main.conf
+
+[HOSTAPD]
+rad0=ssidCCMP.conf
diff --git a/autotests/testAddressRandomization/main.conf b/autotests/testAddressRandomization/main.conf
new file mode 100644
index 000000000..1b66d3380
--- /dev/null
+++ b/autotests/testAddressRandomization/main.conf
@@ -0,0 +1,2 @@
+[General]
+AddressRandomization=network
diff --git a/autotests/testAddressRandomization/override.psk b/autotests/testAddressRandomization/override.psk
new file mode 100644
index 000000000..ecce36165
--- /dev/null
+++ b/autotests/testAddressRandomization/override.psk
@@ -0,0 +1,6 @@
+[Security]
+Passphrase=secret123
+
+[Settings]
+AddressOverride=e6:f6:38:a9:02:02
+AutoConnect=false
diff --git a/autotests/testAddressRandomization/pernetwork.psk b/autotests/testAddressRandomization/pernetwork.psk
new file mode 100644
index 000000000..1150ba8c9
--- /dev/null
+++ b/autotests/testAddressRandomization/pernetwork.psk
@@ -0,0 +1,5 @@
+[Security]
+Passphrase=secret123
+
+[Settings]
+AutoConnect=false
diff --git a/autotests/testAddressRandomization/ssidCCMP.conf b/autotests/testAddressRandomization/ssidCCMP.conf
new file mode 100644
index 000000000..074e82283
--- /dev/null
+++ b/autotests/testAddressRandomization/ssidCCMP.conf
@@ -0,0 +1,7 @@
+hw_mode=g
+channel=1
+ssid=ssidCCMP
+
+wpa=2
+wpa_pairwise=CCMP
+wpa_passphrase=secret123