summaryrefslogtreecommitdiff
path: root/tests/unittests/test_distros/test_generic.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2012-11-14 23:11:20 -0800
committerJoshua Harlow <harlowja@gmail.com>2012-11-14 23:11:20 -0800
commitae6c2665d51fffe5fdc2a15b7f97af0d8c1484af (patch)
treec8859e23a0f440e1a372a049885aa643b1133281 /tests/unittests/test_distros/test_generic.py
parent7b9540b0a17cfcdb94bb133f1413b3a3f68433ef (diff)
downloadvyos-cloud-init-ae6c2665d51fffe5fdc2a15b7f97af0d8c1484af.tar.gz
vyos-cloud-init-ae6c2665d51fffe5fdc2a15b7f97af0d8c1484af.zip
Add the string sudoers rule test case as well.
Diffstat (limited to 'tests/unittests/test_distros/test_generic.py')
-rw-r--r--tests/unittests/test_distros/test_generic.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/unittests/test_distros/test_generic.py b/tests/unittests/test_distros/test_generic.py
index 63a4af29..8ceb141a 100644
--- a/tests/unittests/test_distros/test_generic.py
+++ b/tests/unittests/test_distros/test_generic.py
@@ -56,6 +56,27 @@ class TestGenericDistro(helpers.FilesystemMockingTestCase):
self.tmp = self.makeDir()
def test_sudoers_ensure_rules(self):
+ rules = 'ALL=(ALL:ALL) ALL'
+ cls = distros.fetch("ubuntu")
+ d = cls("ubuntu", {}, None)
+ os.makedirs(os.path.join(self.tmp, "etc"))
+ os.makedirs(os.path.join(self.tmp, "etc", 'sudoers.d'))
+ self.patchOS(self.tmp)
+ self.patchUtils(self.tmp)
+ d.write_sudo_rules("harlowja", rules)
+ contents = util.load_file(d.ci_sudoers_fn)
+ self.restore()
+ lines = contents.splitlines()
+ found_amount = 0
+ expected = ['harlowja ALL=(ALL:ALL) ALL']
+ for e in expected:
+ for line in lines:
+ line = line.strip()
+ if line == e:
+ found_amount += 1
+ self.assertEquals(1, found_amount)
+
+ def test_sudoers_ensure_rules_list(self):
rules = ['ALL=(ALL:ALL) ALL']
rules.append('B-ALL=(ALL:ALL) ALL')
cls = distros.fetch("ubuntu")