diff options
author | Joshua Harlow <harlowja@gmail.com> | 2012-11-14 22:40:01 -0800 |
---|---|---|
committer | Joshua Harlow <harlowja@gmail.com> | 2012-11-14 22:40:01 -0800 |
commit | 7b9540b0a17cfcdb94bb133f1413b3a3f68433ef (patch) | |
tree | 62fa285c46d43b555e5e6665f884d3860e3d2caf /tests/unittests/test_distros | |
parent | 75c3482a8685151407c186ce5b1f3b8af3db49d4 (diff) | |
download | vyos-cloud-init-7b9540b0a17cfcdb94bb133f1413b3a3f68433ef.tar.gz vyos-cloud-init-7b9540b0a17cfcdb94bb133f1413b3a3f68433ef.zip |
Add a test to make sure this doesn't happen again.
Diffstat (limited to 'tests/unittests/test_distros')
-rw-r--r-- | tests/unittests/test_distros/test_generic.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/unittests/test_distros/test_generic.py b/tests/unittests/test_distros/test_generic.py index 704699b5..63a4af29 100644 --- a/tests/unittests/test_distros/test_generic.py +++ b/tests/unittests/test_distros/test_generic.py @@ -55,6 +55,29 @@ class TestGenericDistro(helpers.FilesystemMockingTestCase): # Make a temp directoy for tests to use. self.tmp = self.makeDir() + def test_sudoers_ensure_rules(self): + rules = ['ALL=(ALL:ALL) ALL'] + rules.append('B-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'] + expected.append('harlowja B-ALL=(ALL:ALL) ALL') + for e in expected: + for line in lines: + line = line.strip() + if line == e: + found_amount += 1 + self.assertEquals(2, found_amount) + def test_sudoers_ensure_new(self): cls = distros.fetch("ubuntu") d = cls("ubuntu", {}, None) |