Merge ~danilogondolfo/network-manager/+git/network-manager:new_autopkgtests into ~slyon/network-manager:netplan-integration

Proposed by Danilo Egea Gondolfo
Status: Superseded
Proposed branch: ~danilogondolfo/network-manager/+git/network-manager:new_autopkgtests
Merge into: ~slyon/network-manager:netplan-integration
Diff against target: 106 lines (+63/-4)
1 file modified
debian/tests/nm_netplan.py (+63/-4)
Reviewer Review Type Date Requested Status
Lukas Märdian Approve
Review via email: mp+442688@code.launchpad.net

This proposal has been superseded by a proposal from 2023-05-16.

To post a comment you must log in.
Revision history for this message
Lukas Märdian (slyon) wrote :

Thank you! LGTM. I left one little (non-blocking) inline comment, which you could consider fixing.

This MP depends on some fixes in libnetplan, so we should hold it back until those fixed landed in Mantic. Once that's done (and the new autopkgtests PASS), we should rebase this MP against https://code.launchpad.net/~network-manager/network-manager/+git/ubuntu/+ref/ubuntu/master and get it landed via the offical NetworkManager package.

review: Approve

Unmerged commits

16d5862... by Danilo Egea Gondolfo

d/t/nm_netplan.py: add new test cases

    - Test case for LP: #2016473: change an existing tunnel originally
      created with Netplan with nmcli and check if it worked.
    - Test case for LP: #2016625: add a wifi connection using 802.1x and
      check if nmcli finished successfully.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/tests/nm_netplan.py b/debian/tests/nm_netplan.py
2index cc86bcf..b36b2f2 100644
3--- a/debian/tests/nm_netplan.py
4+++ b/debian/tests/nm_netplan.py
5@@ -124,7 +124,7 @@ class TestNetplan(unittest.TestCase):
6
7 def _nmcli(self, parameters):
8 cmd = ['nmcli'] + parameters
9- subprocess.call(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
10+ return subprocess.call(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
11
12 def _bridge_show(self, bridge):
13 cmd = ['bridge', '-j', 'link', 'show', bridge]
14@@ -536,7 +536,7 @@ class TestNetplan(unittest.TestCase):
15 with open('/etc/netplan/10-test.yaml', 'w') as f:
16 f.write(netplan_yaml)
17
18- self._netplan_generate();
19+ self._netplan_generate()
20 self._nmcli_con_reload()
21 self.nmclient = NM.Client.new()
22
23@@ -565,7 +565,7 @@ class TestNetplan(unittest.TestCase):
24 with open('/etc/netplan/10-test.yaml', 'w') as f:
25 f.write(netplan_yaml)
26
27- self._netplan_generate();
28+ self._netplan_generate()
29 self._nmcli_con_reload()
30 self.nmclient = NM.Client.new()
31
32@@ -607,7 +607,7 @@ class TestNetplan(unittest.TestCase):
33 with open('/etc/netplan/10-test.yaml', 'w') as f:
34 f.write(netplan_yaml)
35
36- self._netplan_generate();
37+ self._netplan_generate()
38 self._nmcli_con_reload()
39 self._nmcli(['con', 'mod', 'netplan-eth123', 'ipv4.method', 'auto'])
40
41@@ -711,6 +711,65 @@ EASYRSA_BATCH=1 /usr/share/easy-rsa/easyrsa build-client-full client nopass
42 self.assertEqual(self._get_number_of_yaml_files(), 2,
43 msg='More than expected YAML files were found after stopping the OpenVPN server')
44
45+ def test_migrate_existing_tunnel_with_nmcli(self):
46+ """
47+ Change an existing tunnel defined in Netplan with nmcli so it will be "imported"
48+ to NM. See LP: #2016473.
49+ """
50+
51+ netplan_yaml = '''network:
52+ renderer: NetworkManager
53+ tunnels:
54+ wg0:
55+ mode: wireguard
56+ port: 51821
57+ key: YCNQCAes1OTbD2ynY+aBlaA5x4ZFJhsc4co+XHpZ4FU=
58+ addresses:
59+ - 172.17.0.1/24
60+ peers:
61+ - allowed-ips: [172.17.0.0/24]
62+ endpoint: 4.4.4.4:51821
63+ keys:
64+ public: cwkb7k0xDgLSnunZpFIjLJw4u+mJDDr+aBR5DqzpmgI='''
65+
66+ with open('/etc/netplan/10-test.yaml', 'w') as f:
67+ f.write(netplan_yaml)
68+
69+ self._netplan_generate()
70+ self._nmcli_con_reload()
71+ self._nmcli(['con', 'mod', 'netplan-wg0', 'con-name', 'netplan-wireguard-wg0'])
72+
73+ # After being processed by NM (and libnetplan) the new file shouldn't
74+ # redefine the interface type. If it does, "netplan get" will fail when it tries to load the
75+ # YAML hierarchy with the error below.
76+ out = subprocess.check_output(['sh', '-c', 'netplan get ; exit 0'],
77+ universal_newlines=True,
78+ stderr=subprocess.STDOUT)
79+ self.assertNotIn("Updated definition 'wg0' changes device type", out)
80+
81+ def test_create_wifi_connection_with_8021x(self):
82+ """
83+ See LP: #2016625.
84+ """
85+
86+ openssl_cmd = [
87+ 'openssl', 'req', '-new', '-newkey', 'rsa:2048',
88+ '-nodes', '-x509', '-subj',
89+ '/C=US/ST=A/L=B/O=C/CN=www.a.com', '-keyout',
90+ '/etc/netplan/a.key', '-out', '/etc/netplan/a.crt']
91+
92+ subprocess.check_output(openssl_cmd, universal_newlines=True)
93+
94+ ret = self._nmcli(['con', 'add', 'con-name', 'eduroam',
95+ 'type', 'wifi', 'ssid', 'eduroam',
96+ 'wifi-sec.key-mgmt', 'wpa-eap', '802-1x.eap',
97+ 'peap', '802-1x.identity', 'user@example.org',
98+ '802-1x.password', 'testing123',
99+ '802-1x.phase2-auth', 'mschapv2',
100+ '802-1x.ca-cert', '/etc/netplan/a.crt'])
101+
102+ self.assertEqual(ret, 0, 'nmcli failed to add connection')
103+
104
105 if __name__ == '__main__':
106 runner = unittest.TextTestRunner(stream=sys.stdout, verbosity=2)

Subscribers

People subscribed via source and target branches