From 5b640551fdff979275b49965801ad438938fb067 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Wed, 30 Sep 2020 20:45:10 +0200 Subject: wireguard: T2939: bugfix when removing individual peers When individual peers that have been removed got determined they have been added to the config dict as list instead of string - which broke the system plumbing commands as they can not handle a Python list. --- smoketest/scripts/cli/test_interfaces_wireguard.py | 38 +++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'smoketest/scripts') diff --git a/smoketest/scripts/cli/test_interfaces_wireguard.py b/smoketest/scripts/cli/test_interfaces_wireguard.py index 0c32a4696..726405780 100755 --- a/smoketest/scripts/cli/test_interfaces_wireguard.py +++ b/smoketest/scripts/cli/test_interfaces_wireguard.py @@ -38,10 +38,8 @@ class WireGuardInterfaceTest(unittest.TestCase): self.session.commit() del self.session - def test_peer_setup(self): - """ - Create WireGuard interfaces with associated peers - """ + def test_peer(self): + """ Create WireGuard interfaces with associated peers """ for intf in self._interfaces: peer = 'foo-' + intf psk = 'u2xdA70hkz0S1CG0dZlOh0aq2orwFXRIVrKo4DCvHgM=' @@ -64,5 +62,37 @@ class WireGuardInterfaceTest(unittest.TestCase): self.assertTrue(os.path.isdir(f'/sys/class/net/{intf}')) + + def test_add_remove_peer(self): + """ Create WireGuard interfaces with associated peers. Remove one of + the configured peers. Bug reported as T2939 """ + interface = 'wg0' + port = '12345' + pubkey_1 = 'n1CUsmR0M2LUUsyicBd6blZICwUqqWWHbu4ifZ2/9gk=' + pubkey_2 = 'ebFx/1G0ti8tvuZd94sEIosAZZIznX+dBAKG/8DFm0I=' + + self.session.set(base_path + [interface, 'address', '172.16.0.1/24']) + + self.session.set(base_path + [interface, 'peer', 'PEER01', 'pubkey', pubkey_1]) + self.session.set(base_path + [interface, 'peer', 'PEER01', 'port', port]) + self.session.set(base_path + [interface, 'peer', 'PEER01', 'allowed-ips', '10.205.212.10/32']) + self.session.set(base_path + [interface, 'peer', 'PEER01', 'address', '192.0.2.1']) + + self.session.set(base_path + [interface, 'peer', 'PEER02', 'pubkey', pubkey_2]) + self.session.set(base_path + [interface, 'peer', 'PEER02', 'port', port]) + self.session.set(base_path + [interface, 'peer', 'PEER02', 'allowed-ips', '10.205.212.11/32']) + self.session.set(base_path + [interface, 'peer', 'PEER02', 'address', '192.0.2.2']) + + # Commit peers + self.session.commit() + + self.assertTrue(os.path.isdir(f'/sys/class/net/{interface}')) + + # Delete second peer + self.session.delete(base_path + [interface, 'peer', 'PEER01']) + self.session.commit() + + + if __name__ == '__main__': unittest.main() -- cgit v1.2.3