salt/tests/integration/modules/boto_iam.py

47 lines
1.1 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
'''
Validate the boto_iam module
'''
2015-01-21 02:13:19 +00:00
# Import Python libs
from __future__ import absolute_import
# Import Salt Testing libs
from salttesting import skipIf
from salttesting.helpers import ensure_in_syspath
ensure_in_syspath('../../')
2015-01-21 02:13:19 +00:00
# Import Salt libs
import integration
2015-01-21 02:13:19 +00:00
# Import 3rd-party libs
2015-01-14 21:06:43 +00:00
NO_BOTO_MODULE = True
BOTO_NOT_CONFIGURED = True
try:
import boto
NO_BOTO_MODULE = False
try:
boto.connect_iam()
BOTO_NOT_CONFIGURED = False
except boto.exception.NoAuthHandlerFound:
pass
except ImportError:
pass
@skipIf(
NO_BOTO_MODULE,
'Please install the boto library before running boto integration tests.'
)
@skipIf(
BOTO_NOT_CONFIGURED,
'Please setup boto AWS credentials before running boto integration tests.'
)
class BotoIAMTest(integration.ModuleCase):
def test_get_account_id(self):
ret = self.run_function('boto_iam.get_account_id')
2015-01-14 19:12:23 +00:00
# The AWS account ID is a 12-digit number.
# http://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html
self.assertRegexpMatches(ret, r'^\d{12}$')