test_boto_iam.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # -*- coding: utf-8 -*-
  2. """
  3. Validate the boto_iam module
  4. """
  5. # Import Python libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. # Import Salt Testing libs
  8. from tests.support.case import ModuleCase
  9. from tests.support.unit import skipIf
  10. # Import 3rd-party libs
  11. try:
  12. import boto
  13. NO_BOTO_MODULE = False
  14. except ImportError:
  15. NO_BOTO_MODULE = True
  16. @skipIf(
  17. NO_BOTO_MODULE,
  18. "Please install the boto library before running boto integration tests.",
  19. )
  20. class BotoIAMTest(ModuleCase):
  21. def setUp(self):
  22. try:
  23. boto.connect_iam()
  24. except boto.exception.NoAuthHandlerFound:
  25. self.skipTest(
  26. "Please setup boto AWS credentials before running boto integration tests."
  27. )
  28. def test_get_account_id(self):
  29. ret = self.run_function("boto_iam.get_account_id")
  30. # The AWS account ID is a 12-digit number.
  31. # http://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html
  32. self.assertRegex(ret, r"^\d{12}$")