1
0

test_boto_iam.py 1008 B

12345678910111213141516171819202122232425262728293031323334353637
  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('Please setup boto AWS credentials before running boto integration tests.')
  26. def test_get_account_id(self):
  27. ret = self.run_function('boto_iam.get_account_id')
  28. # The AWS account ID is a 12-digit number.
  29. # http://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html
  30. self.assertRegex(ret, r'^\d{12}$')