diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/test_distros/test_user_data_normalize.py | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/tests/unittests/test_distros/test_user_data_normalize.py b/tests/unittests/test_distros/test_user_data_normalize.py index 9d6fb996..f27af826 100644 --- a/tests/unittests/test_distros/test_user_data_normalize.py +++ b/tests/unittests/test_distros/test_user_data_normalize.py @@ -4,19 +4,26 @@ from cloudinit import distros from cloudinit import helpers from cloudinit import settings +bcfg = { + 'name': 'bob', + 'plain_text_passwd': 'ubuntu', + 'home': "/home/ubuntu", + 'shell': "/bin/bash", + 'lock_passwd': True, + 'gecos': "Ubuntu", + 'groups': ["foo"] +} class TestUGNormalize(MockerTestCase): - def _make_distro(self, dtype, def_user=None, def_groups=None): + def _make_distro(self, dtype, def_user=None): cfg = dict(settings.CFG_BUILTIN) cfg['system_info']['distro'] = dtype paths = helpers.Paths(cfg['system_info']['paths']) distro_cls = distros.fetch(dtype) - distro = distro_cls(dtype, cfg['system_info'], paths) if def_user: - distro.default_user = def_user - if def_groups: - distro.default_user_groups = def_groups + cfg['system_info']['default_user'] = def_user.copy() + distro = distro_cls(dtype, cfg['system_info'], paths) return distro def _norm(self, cfg, distro): @@ -71,7 +78,7 @@ class TestUGNormalize(MockerTestCase): self.assertEquals({}, users) def test_users_simple_dict(self): - distro = self._make_distro('ubuntu', 'bob') + distro = self._make_distro('ubuntu', bcfg) ug_cfg = { 'users': { 'default': True, @@ -95,7 +102,7 @@ class TestUGNormalize(MockerTestCase): self.assertIn('bob', users) def test_users_simple_dict_no(self): - distro = self._make_distro('ubuntu', 'bob') + distro = self._make_distro('ubuntu', bcfg) ug_cfg = { 'users': { 'default': False, @@ -137,7 +144,7 @@ class TestUGNormalize(MockerTestCase): self.assertEquals({'default': False}, users['bob']) def test_users_old_user(self): - distro = self._make_distro('ubuntu', 'bob') + distro = self._make_distro('ubuntu', bcfg) ug_cfg = { 'user': 'zetta', 'users': 'default' @@ -185,7 +192,7 @@ class TestUGNormalize(MockerTestCase): self.assertEquals({}, groups) def test_users_dict_default_additional(self): - distro = self._make_distro('ubuntu', 'bob') + distro = self._make_distro('ubuntu', bcfg) ug_cfg = { 'users': [ {'name': 'default', 'blah': True} @@ -201,7 +208,7 @@ class TestUGNormalize(MockerTestCase): users['bob']['default']) def test_users_dict_extract(self): - distro = self._make_distro('ubuntu', 'bob') + distro = self._make_distro('ubuntu', bcfg) ug_cfg = { 'users': [ 'default', @@ -228,7 +235,7 @@ class TestUGNormalize(MockerTestCase): self.assertEquals(config, expected_config) def test_users_dict_default(self): - distro = self._make_distro('ubuntu', 'bob') + distro = self._make_distro('ubuntu', bcfg) ug_cfg = { 'users': [ 'default', |