A Python library for code common to TripleO CLI and TripleO UI.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.2KB

  1. # Copyright 2016 Red Hat, Inc.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  12. # implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. import mock
  16. from tripleo_common.tests import base
  17. from tripleo_common.utils import overcloudrc
  18. class OvercloudRcTest(base.TestCase):
  19. def test_generate_overcloudrc(self):
  20. stack = mock.MagicMock()
  21. stack.stack_name = 'overcast'
  22. stack.to_dict.return_value = {
  23. "outputs": [
  24. {'output_key': 'KeystoneURL',
  25. 'output_value': 'http://foo.com:8000/'},
  26. {'output_key': 'EndpointMap',
  27. 'output_value': {'KeystoneAdmin': {'host': 'fd00::1'}}},
  28. ]
  29. }
  30. result = overcloudrc.create_overcloudrc(stack, "foo", "AdminPassword",
  31. "regionTwo")
  32. self.assertIn("export no_proxy='foo,foo.com,[fd00::1]'",
  33. result['overcloudrc'])
  34. self.assertIn("OS_PASSWORD=AdminPassword", result['overcloudrc'])
  35. self.assertIn("OS_PASSWORD=AdminPassword", result['overcloudrc.v3'])
  36. self.assertIn("OS_IDENTITY_API_VERSION=3", result['overcloudrc'])
  37. self.assertIn("OS_IDENTITY_API_VERSION=3", result['overcloudrc.v3'])
  38. self.assertIn(overcloudrc.CLOUDPROMPT, result['overcloudrc'])
  39. self.assertIn(overcloudrc.CLOUDPROMPT, result['overcloudrc.v3'])
  40. self.assertIn("OS_AUTH_TYPE=password", result['overcloudrc'])
  41. self.assertIn("OS_AUTH_TYPE=password", result['overcloudrc.v3'])
  42. self.assertIn("OS_AUTH_URL=http://foo.com:8000/",
  43. result['overcloudrc'])
  44. self.assertIn("OS_AUTH_URL=http://foo.com:8000/",
  45. result['overcloudrc.v3'])
  46. self.assertIn("OS_REGION_NAME=regionTwo",
  47. result['overcloudrc'])