diff options
author | Scott Moser <smoser@brickies.net> | 2012-10-23 12:13:41 +0200 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2012-10-23 12:13:41 +0200 |
commit | 605c10763752582af139f8677f1f907705564824 (patch) | |
tree | 3543d8a2a92f825a36352af1e80f9242d5201b06 /tests/unittests/test_distros/test_user_data_normalize.py | |
parent | bdaa57bc5b8a75b0891673a7bb0a60c5b02beb7c (diff) | |
parent | 0049b6e7bc7f52fd442f1b8902294ca8c379df5c (diff) | |
download | vyos-cloud-init-605c10763752582af139f8677f1f907705564824.tar.gz vyos-cloud-init-605c10763752582af139f8677f1f907705564824.zip |
move default user info out of code and into config
Remove the need to have 'default_user' and 'default_user_groups' groups be
hard coded into the distro class, instead let that set of configuration be
located in the config file where it should be specified instead.
Diffstat (limited to 'tests/unittests/test_distros/test_user_data_normalize.py')
-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', |