test_plugin_prescript.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # vim: tabstop=4 shiftwidth=4 softtabstop=4
  2. # Copyright 2013, Red Hat, Inc.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. from unittest import TestCase
  16. from test_base import PackstackTestCaseMixin
  17. from packstack.plugins import prescript_000
  18. class OSPluginUtilsTestCase(PackstackTestCaseMixin, TestCase):
  19. def test_rhn_creds_quoted(self):
  20. """Make sure RHN password is quoted."""
  21. # On non-RHEL, the CONFIG_{RH,SATELLITE} options are never set,
  22. # i.e. this test would always fail. Therefore, only run it on RHEL.
  23. if not prescript_000.is_rhel():
  24. return
  25. password = "dasd|'asda%><?"
  26. prescript_000.controller.CONF["CONFIG_KEYSTONE_HOST"] = "1.2.3.4"
  27. prescript_000.controller.CONF["CONFIG_USE_EPEL"] = "n"
  28. prescript_000.controller.CONF["CONFIG_REPO"] = ""
  29. prescript_000.controller.CONF["CONFIG_RH_USER"] = "testuser"
  30. prescript_000.controller.CONF["CONFIG_RH_PW"] = password
  31. prescript_000.controller.CONF["CONFIG_RH_BETA_REPO"] = "n"
  32. prescript_000.controller.CONF["CONFIG_SATELLITE_FLAGS"] = ""
  33. prescript_000.controller.CONF["CONFIG_SATELLITE_URL"] = ""
  34. prescript_000.controller.CONF["CONFIG_SATELLITE_USER"] = ""
  35. prescript_000.controller.CONF["CONFIG_SATELLITE_PW"] = ""
  36. prescript_000.controller.CONF["CONFIG_SATELLITE_CACERT"] = ""
  37. prescript_000.controller.CONF["CONFIG_SATELLITE_AKEY"] = ""
  38. prescript_000.controller.CONF["CONFIG_SATELLITE_PROFILE"] = ""
  39. prescript_000.controller.CONF["CONFIG_SATELLITE_PROXY"] = ""
  40. prescript_000.controller.CONF["CONFIG_SATELLITE_PROXY_USER"] = ""
  41. prescript_000.controller.CONF["CONFIG_SATELLITE_PROXY_PW"] = ""
  42. prescript_000.serverprep(prescript_000.controller.CONF)
  43. self.assertNotEqual(
  44. self.fake_popen.data.find('--password="%s"' % password), -1
  45. )