diff options
author | Vlastimil Holer <vlastimil.holer@gmail.com> | 2013-09-10 16:47:15 +0200 |
---|---|---|
committer | Vlastimil Holer <vlastimil.holer@gmail.com> | 2013-09-10 16:47:15 +0200 |
commit | 18ec61a5b5e2c67d84cbdcef1e47cc72b0ba6218 (patch) | |
tree | e0eb84562c1df6ffd03897d10e5fa7f778ecdfd1 /tests | |
parent | 6e156e4877e420050307249345287cf48ff5d795 (diff) | |
download | vyos-cloud-init-18ec61a5b5e2c67d84cbdcef1e47cc72b0ba6218.tar.gz vyos-cloud-init-18ec61a5b5e2c67d84cbdcef1e47cc72b0ba6218.zip |
Detect invalid system user for test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/test_datasource/test_opennebula.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/unittests/test_datasource/test_opennebula.py b/tests/unittests/test_datasource/test_opennebula.py index 752638b6..f5103dc0 100644 --- a/tests/unittests/test_datasource/test_opennebula.py +++ b/tests/unittests/test_datasource/test_opennebula.py @@ -5,6 +5,7 @@ from mocker import MockerTestCase from tests.unittests.helpers import populate_dir import os +import pwd TEST_VARS = { 'VAR1': 'single', @@ -21,7 +22,6 @@ TEST_VARS = { 'VAR12': '$', # expect $ } -INVALID_PARSEUSER = 'cloud-init-mocker-opennebula-invalid' INVALID_CONTEXT = ';' USER_DATA = '#cloud-config\napt_upgrade: true' SSH_KEY = 'ssh-rsa AAAAB3NzaC1....sIkJhq8wdX+4I3A4cYbYP ubuntu@server-460-%i' @@ -78,9 +78,16 @@ class TestOpenNebulaDataSource(MockerTestCase): orig_find_devs_with = util.find_devs_with util.find_devs_with = lambda n: [] + # generate non-existing system user name sys_cfg = self.sys_cfg - sys_cfg['datasource']['OpenNebula']['parseuser'] = \ - INVALID_PARSEUSER + invalid_user = 'invalid' + while not sys_cfg['datasource']['OpenNebula'].get('parseuser'): + try: + pwd.getpwnam(invalid_user) + invalid_user += 'X' + except KeyError: + sys_cfg['datasource']['OpenNebula']['parseuser'] = \ + invalid_user populate_context_dir(self.seed_dir, {'KEY1': 'val1'}) dsrc = self.ds(sys_cfg=sys_cfg, distro=None, paths=self.paths) |