summaryrefslogtreecommitdiff
path: root/tests/unittests/test_rh_subscription.py
diff options
context:
space:
mode:
authorDave Mulford <dmulford@redhat.com>2017-10-09 15:28:15 -0500
committerScott Moser <smoser@brickies.net>2017-11-10 16:26:05 -0500
commit9bc4ce0596544ffa56d9d67245b00e07006a8662 (patch)
treea12158ec8136d341be78f2920b42afe2719452c6 /tests/unittests/test_rh_subscription.py
parent420c3452f2009e08f545eaa9ef126ab922133678 (diff)
downloadvyos-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.py15
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,