From: Yu Watanabe Date: Mon, 22 Feb 2021 07:39:58 +0000 (+0900) Subject: test-network: test wireguard peer in drop-in config X-Git-Tag: v248-rc1~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=84d32bf59bb1a13162aae08022d115290bc8eb91;p=thirdparty%2Fsystemd.git test-network: test wireguard peer in drop-in config Closes #18241. --- diff --git a/test/test-network/conf/25-wireguard.netdev b/test/test-network/conf/25-wireguard.netdev index 4866c31ccac..a95ae205d71 100644 --- a/test/test-network/conf/25-wireguard.netdev +++ b/test/test-network/conf/25-wireguard.netdev @@ -3,7 +3,6 @@ Name=wg99 Kind=wireguard [WireGuard] -PrivateKey=EEGlnEPYJV//kbvvIqxKkQwOiS+UENyPncC4bF46ong= ListenPort=51820 FwMark=1234 diff --git a/test/test-network/conf/25-wireguard.netdev.d/peer1.conf b/test/test-network/conf/25-wireguard.netdev.d/peer1.conf new file mode 100644 index 00000000000..47848fcde76 --- /dev/null +++ b/test/test-network/conf/25-wireguard.netdev.d/peer1.conf @@ -0,0 +1,5 @@ +[WireGuardPeer] +PublicKey=TTiCUpCxS7zDn/ax4p5W6Evg41r8hOrnWQw2Sq6Nh10= +PresharedKey=it7nd33chCT/tKT2ZZWfYyp43Zs+6oif72hexnSNMqA= + +AllowedIPs=192.168.124.2 diff --git a/test/test-network/conf/25-wireguard.netdev.d/peer2.conf b/test/test-network/conf/25-wireguard.netdev.d/peer2.conf new file mode 100644 index 00000000000..bf99a5ab0f8 --- /dev/null +++ b/test/test-network/conf/25-wireguard.netdev.d/peer2.conf @@ -0,0 +1,5 @@ +[WireGuardPeer] +PublicKey=9uioxkGzjvGjkse3V35I9AhorWfIjBcrf3UPMS0bw2c= +PresharedKey=6Fsg8XN0DE6aPQgAX4r2oazEYJOGqyHUz3QRH/jCB+I= + +AllowedIPs=192.168.124.3 diff --git a/test/test-network/conf/25-wireguard.netdev.d/private-key.conf b/test/test-network/conf/25-wireguard.netdev.d/private-key.conf new file mode 100644 index 00000000000..9b04cf72a2c --- /dev/null +++ b/test/test-network/conf/25-wireguard.netdev.d/private-key.conf @@ -0,0 +1,2 @@ +[WireGuard] +PrivateKey=EEGlnEPYJV//kbvvIqxKkQwOiS+UENyPncC4bF46ong= diff --git a/test/test-network/conf/25-wireguard.network b/test/test-network/conf/25-wireguard.network index ab305239151..163a56ff294 100644 --- a/test/test-network/conf/25-wireguard.network +++ b/test/test-network/conf/25-wireguard.network @@ -1,2 +1,5 @@ [Match] Name=wg99 + +[Network] +Address=192.168.124.1/24 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 38480e1ce58..2effa42e16d 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -1218,7 +1218,11 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities): '25-wireguard-preshared-key.txt', '25-wireguard-private-key.txt', '25-wireguard-no-peer.netdev', '25-wireguard-no-peer.network') start_networkd() - self.wait_online(['wg99:carrier', 'wg98:routable', 'wg97:carrier']) + self.wait_online(['wg99:routable', 'wg98:routable', 'wg97:carrier']) + + output = check_output('ip -4 address show dev wg99') + print(output) + self.assertIn('inet 192.168.124.1/24 scope global wg99', output) output = check_output('ip -4 address show dev wg98') print(output) @@ -1232,29 +1236,39 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities): call('wg') output = check_output('wg show wg99 listen-port') - self.assertRegex(output, '51820') + self.assertEqual(output, '51820') output = check_output('wg show wg99 fwmark') - self.assertRegex(output, '0x4d2') + self.assertEqual(output, '0x4d2') + output = check_output('wg show wg99 private-key') + self.assertEqual(output, 'EEGlnEPYJV//kbvvIqxKkQwOiS+UENyPncC4bF46ong=') output = check_output('wg show wg99 allowed-ips') - self.assertRegex(output, r'RDf\+LSpeEre7YEIKaxg\+wbpsNV7du\+ktR99uBEtIiCA=\t192.168.26.0/24 fd31:bf08:57cb::/48') - self.assertRegex(output, r'lsDtM3AbjxNlauRKzHEPfgS1Zp7cp/VX5Use/P4PQSc=\tfdbc:bae2:7871:e1fe:793:8636::/96 fdbc:bae2:7871:500:e1fe:793:8636:dad1/128') + self.assertIn('9uioxkGzjvGjkse3V35I9AhorWfIjBcrf3UPMS0bw2c=\t192.168.124.3/32', output) + self.assertIn('TTiCUpCxS7zDn/ax4p5W6Evg41r8hOrnWQw2Sq6Nh10=\t192.168.124.2/32', output) + self.assertIn('lsDtM3AbjxNlauRKzHEPfgS1Zp7cp/VX5Use/P4PQSc=\tfdbc:bae2:7871:e1fe:793:8636::/96 fdbc:bae2:7871:500:e1fe:793:8636:dad1/128', output) + self.assertIn('RDf+LSpeEre7YEIKaxg+wbpsNV7du+ktR99uBEtIiCA=\t192.168.26.0/24 fd31:bf08:57cb::/48', output) output = check_output('wg show wg99 persistent-keepalive') - self.assertRegex(output, r'RDf\+LSpeEre7YEIKaxg\+wbpsNV7du\+ktR99uBEtIiCA=\t20') + self.assertIn('9uioxkGzjvGjkse3V35I9AhorWfIjBcrf3UPMS0bw2c=\toff', output) + self.assertIn('TTiCUpCxS7zDn/ax4p5W6Evg41r8hOrnWQw2Sq6Nh10=\toff', output) + self.assertIn('lsDtM3AbjxNlauRKzHEPfgS1Zp7cp/VX5Use/P4PQSc=\toff', output) + self.assertIn('RDf+LSpeEre7YEIKaxg+wbpsNV7du+ktR99uBEtIiCA=\t20', output) output = check_output('wg show wg99 endpoints') - self.assertRegex(output, r'RDf\+LSpeEre7YEIKaxg\+wbpsNV7du\+ktR99uBEtIiCA=\t192.168.27.3:51820') - output = check_output('wg show wg99 private-key') - self.assertRegex(output, r'EEGlnEPYJV//kbvvIqxKkQwOiS\+UENyPncC4bF46ong=') + self.assertIn('9uioxkGzjvGjkse3V35I9AhorWfIjBcrf3UPMS0bw2c=\t(none)', output) + self.assertIn('TTiCUpCxS7zDn/ax4p5W6Evg41r8hOrnWQw2Sq6Nh10=\t(none)', output) + self.assertIn('lsDtM3AbjxNlauRKzHEPfgS1Zp7cp/VX5Use/P4PQSc=\t(none)', output) + self.assertIn('RDf+LSpeEre7YEIKaxg+wbpsNV7du+ktR99uBEtIiCA=\t192.168.27.3:51820', output) output = check_output('wg show wg99 preshared-keys') - self.assertRegex(output, r'RDf\+LSpeEre7YEIKaxg\+wbpsNV7du\+ktR99uBEtIiCA= IIWIV17wutHv7t4cR6pOT91z6NSz/T8Arh0yaywhw3M=') - self.assertRegex(output, r'lsDtM3AbjxNlauRKzHEPfgS1Zp7cp/VX5Use/P4PQSc= cPLOy1YUrEI0EMMIycPJmOo0aTu3RZnw8bL5meVD6m0=') + self.assertIn('9uioxkGzjvGjkse3V35I9AhorWfIjBcrf3UPMS0bw2c=\t6Fsg8XN0DE6aPQgAX4r2oazEYJOGqyHUz3QRH/jCB+I=', output) + self.assertIn('TTiCUpCxS7zDn/ax4p5W6Evg41r8hOrnWQw2Sq6Nh10=\tit7nd33chCT/tKT2ZZWfYyp43Zs+6oif72hexnSNMqA=', output) + self.assertIn('lsDtM3AbjxNlauRKzHEPfgS1Zp7cp/VX5Use/P4PQSc=\tcPLOy1YUrEI0EMMIycPJmOo0aTu3RZnw8bL5meVD6m0=', output) + self.assertIn('RDf+LSpeEre7YEIKaxg+wbpsNV7du+ktR99uBEtIiCA=\tIIWIV17wutHv7t4cR6pOT91z6NSz/T8Arh0yaywhw3M=', output) output = check_output('wg show wg98 private-key') - self.assertRegex(output, r'CJQUtcS9emY2fLYqDlpSZiE/QJyHkPWr\+WHtZLZ90FU=') + self.assertEqual(output, 'CJQUtcS9emY2fLYqDlpSZiE/QJyHkPWr+WHtZLZ90FU=') output = check_output('wg show wg97 listen-port') - self.assertRegex(output, '51821') + self.assertEqual(output, '51821') output = check_output('wg show wg97 fwmark') - self.assertRegex(output, '0x4d3') + self.assertEqual(output, '0x4d3') def test_geneve(self): copy_unit_to_networkd_unit_path('25-geneve.netdev', 'netdev-link-local-addressing-yes.network')