diff options
author | Dave Mulford <dmulford@redhat.com> | 2017-10-09 15:28:15 -0500 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2017-11-10 16:26:05 -0500 |
commit | 9bc4ce0596544ffa56d9d67245b00e07006a8662 (patch) | |
tree | a12158ec8136d341be78f2920b42afe2719452c6 /tests/unittests/test_rh_subscription.py | |
parent | 420c3452f2009e08f545eaa9ef126ab922133678 (diff) | |
download | vyos-cloud-init-9bc4ce0596544ffa56d9d67245b00e07006a8662.tar.gz vyos-cloud-init-9bc4ce0596544ffa56d9d67245b00e07006a8662.zip |
rh_subscription: Perform null checks for enabled and disabled repos.
The rh_subscription module doesn't perform null checks when attempting to
iterate on the enabled and disable repos arrays. When only one is
specified, cloud-init fails to run.
Diffstat (limited to 'tests/unittests/test_rh_subscription.py')
-rw-r--r-- | tests/unittests/test_rh_subscription.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/unittests/test_rh_subscription.py b/tests/unittests/test_rh_subscription.py index e9d5702a..22718108 100644 --- a/tests/unittests/test_rh_subscription.py +++ b/tests/unittests/test_rh_subscription.py @@ -2,6 +2,7 @@ """Tests for registering RHEL subscription via rh_subscription.""" +import copy import logging from cloudinit.config import cc_rh_subscription @@ -68,6 +69,20 @@ class GoodTests(TestCase): self.assertEqual(self.SM.log_success.call_count, 1) self.assertEqual(self.SM._sub_man_cli.call_count, 2) + @mock.patch.object(cc_rh_subscription.SubscriptionManager, "_getRepos") + @mock.patch.object(cc_rh_subscription.SubscriptionManager, "_sub_man_cli") + def test_update_repos_disable_with_none(self, m_sub_man_cli, m_get_repos): + cfg = copy.deepcopy(self.config) + m_get_repos.return_value = ([], ['repo1']) + m_sub_man_cli.return_value = (b'', b'') + cfg['rh_subscription'].update( + {'enable-repo': ['repo1'], 'disable-repo': None}) + mysm = cc_rh_subscription.SubscriptionManager(cfg) + self.assertEqual(True, mysm.update_repos()) + m_get_repos.assert_called_with() + self.assertEqual(m_sub_man_cli.call_args_list, + [mock.call(['repos', '--enable=repo1'])]) + def test_full_registration(self): ''' Registration with auto-attach, service-level, adding pools, |