test-network: add more checks in NetworkdNetDevTests.test_wireguard
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 28 Jan 2019 09:09:22 +0000 (10:09 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 28 Jan 2019 09:10:15 +0000 (10:10 +0100)
test/test-network/conf/25-wireguard.netdev
test/test-network/systemd-networkd-tests.py

index 01c5f2a..4866c31 100644 (file)
@@ -10,6 +10,7 @@ FwMark=1234
 [WireGuardPeer]
 PublicKey=RDf+LSpeEre7YEIKaxg+wbpsNV7du+ktR99uBEtIiCA=
 AllowedIPs=fd31:bf08:57cb::/48,192.168.26.0/24
-Endpoint=wireguard.example.com:51820
+#Endpoint=wireguard.example.com:51820
+Endpoint=192.168.27.3:51820
 PresharedKey=IIWIV17wutHv7t4cR6pOT91z6NSz/T8Arh0yaywhw3M=
 PersistentKeepalive=20
index 9e72d35..08ceb2d 100755 (executable)
@@ -390,6 +390,16 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
 
         if shutil.which('wg'):
             subprocess.call('wg')
+            output = subprocess.check_output(['wg', 'show', 'wg99', 'listen-port']).rstrip().decode('utf-8')
+            self.assertTrue(output, '51820')
+            output = subprocess.check_output(['wg', 'show', 'wg99', 'fwmark']).rstrip().decode('utf-8')
+            self.assertTrue(output, '0x4d2')
+            output = subprocess.check_output(['wg', 'show', 'wg99', 'allowed-ips']).rstrip().decode('utf-8')
+            self.assertTrue(output, 'RDf+LSpeEre7YEIKaxg+wbpsNV7du+ktR99uBEtIiCA=\t192.168.26.0/24 fd31:bf08:57cb::/48')
+            output = subprocess.check_output(['wg', 'show', 'wg99', 'persistent-keepalive']).rstrip().decode('utf-8')
+            self.assertTrue(output, 'RDf+LSpeEre7YEIKaxg+wbpsNV7du+ktR99uBEtIiCA=\t20')
+            output = subprocess.check_output(['wg', 'show', 'wg99', 'endpoints']).rstrip().decode('utf-8')
+            self.assertTrue(output, 'RDf+LSpeEre7YEIKaxg+wbpsNV7du+ktR99uBEtIiCA=\t192.168.27.3:51820')
 
         self.assertTrue(self.link_exits('wg99'))