summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests')
-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")