Merge "Increase code coverage for ip_lib sysctl()"

This commit is contained in:
Zuul 2024-05-20 09:44:29 +00:00 committed by Gerrit Code Review
commit 527e712a18
1 changed files with 18 additions and 0 deletions

View File

@ -1189,6 +1189,24 @@ class TestSysctl(base.BaseTestCase):
self.assertFalse(self.execute.called)
class TestGetSysctl(base.BaseTestCase):
@mock.patch.object(ip_lib, 'IPWrapper')
def test_get_ip_nonlocal_bind(self, mIPWrapper):
cmd = ['sysctl', '-bn', ip_lib.IP_NONLOCAL_BIND]
ip_lib.get_ip_nonlocal_bind()
mIPWrapper.assert_has_calls([
mock.call().netns.execute(cmd, run_as_root=True, privsep_exec=True)
])
@mock.patch.object(ip_lib, 'IPWrapper')
def test_get_ipv6_forwarding(self, mIPWrapper):
cmd = ['sysctl', '-b', 'net.ipv6.conf.tap0.forwarding']
ip_lib.get_ipv6_forwarding('tap0')
mIPWrapper.assert_has_calls([
mock.call().netns.execute(cmd, run_as_root=True, privsep_exec=True)
])
class TestConntrack(base.BaseTestCase):
def setUp(self):
super(TestConntrack, self).setUp()