summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorJames Falcon <TheRealFalcon@users.noreply.github.com>2021-03-29 10:24:58 -0500
committerGitHub <noreply@github.com>2021-03-29 11:24:58 -0400
commit3b7e2e82310d417c0d59b268a6f47bc8f7996cab (patch)
tree56988ba156db603d847e1bb529b12d60b8e1e1fa /tests/unittests
parent13606a12054f4fcf1494ea3068db0640ae6cc3a3 (diff)
downloadvyos-cloud-init-3b7e2e82310d417c0d59b268a6f47bc8f7996cab.tar.gz
vyos-cloud-init-3b7e2e82310d417c0d59b268a6f47bc8f7996cab.zip
Fix mis-detecting network configuration in initramfs cmdline (#844)
klibc initramfs in debian allows the 'iscsi_target_ip=' cmdline parameter to specify an iscsi device attachment. This can cause cloud-init to mis-detect the cmdline paramter as a networking config. LP: #1919188
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test_net.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index cb636f41..2bd50e72 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -4387,6 +4387,56 @@ class TestCmdlineKlibcNetworkConfigSource(FilesystemMockingTestCase):
)
self.assertFalse(src.is_applicable())
+ def test_with_faux_ip(self):
+ content = {'net6-eno1.conf': DHCP6_CONTENT_1}
+ files = sorted(populate_dir(self.tmp_dir(), content))
+ src = cmdline.KlibcNetworkConfigSource(
+ _files=files,
+ _cmdline='foo iscsi_target_ip=root=/dev/sda',
+ _mac_addrs=self.macs,
+ )
+ self.assertFalse(src.is_applicable())
+
+ def test_empty_cmdline(self):
+ content = {'net6-eno1.conf': DHCP6_CONTENT_1}
+ files = sorted(populate_dir(self.tmp_dir(), content))
+ src = cmdline.KlibcNetworkConfigSource(
+ _files=files,
+ _cmdline='',
+ _mac_addrs=self.macs,
+ )
+ self.assertFalse(src.is_applicable())
+
+ def test_whitespace_cmdline(self):
+ content = {'net6-eno1.conf': DHCP6_CONTENT_1}
+ files = sorted(populate_dir(self.tmp_dir(), content))
+ src = cmdline.KlibcNetworkConfigSource(
+ _files=files,
+ _cmdline=' ',
+ _mac_addrs=self.macs,
+ )
+ self.assertFalse(src.is_applicable())
+
+ def test_cmdline_no_lhand(self):
+ content = {'net6-eno1.conf': DHCP6_CONTENT_1}
+ files = sorted(populate_dir(self.tmp_dir(), content))
+ src = cmdline.KlibcNetworkConfigSource(
+ _files=files,
+ _cmdline='=wut',
+ _mac_addrs=self.macs,
+ )
+ self.assertFalse(src.is_applicable())
+
+ def test_cmdline_embedded_ip(self):
+ content = {'net6-eno1.conf': DHCP6_CONTENT_1}
+ files = sorted(populate_dir(self.tmp_dir(), content))
+ src = cmdline.KlibcNetworkConfigSource(
+ _files=files,
+ _cmdline='opt="some things and ip=foo"',
+ _mac_addrs=self.macs,
+ )
+ self.assertFalse(src.is_applicable())
+
def test_with_both_ip_ip6(self):
content = {
'/run/net-eth0.conf': DHCP_CONTENT_1,