2015-01-14 19:08:54 +00:00
|
|
|
# -*- 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
|
2015-01-14 19:49:54 +00:00
|
|
|
from salttesting import skipIf
|
2015-01-14 19:08:54 +00:00
|
|
|
from salttesting.helpers import ensure_in_syspath
|
|
|
|
ensure_in_syspath('../../')
|
|
|
|
|
2015-01-21 02:13:19 +00:00
|
|
|
# Import Salt libs
|
2015-01-14 19:08:54 +00:00
|
|
|
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
|
2015-01-14 19:49:54 +00:00
|
|
|
try:
|
|
|
|
import boto
|
|
|
|
NO_BOTO_MODULE = False
|
|
|
|
try:
|
|
|
|
boto.connect_iam()
|
|
|
|
BOTO_NOT_CONFIGURED = False
|
|
|
|
except boto.exception.NoAuthHandlerFound:
|
|
|
|
pass
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2015-01-14 19:08:54 +00:00
|
|
|
|
2015-01-14 19:49:54 +00:00
|
|
|
@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.'
|
|
|
|
)
|
2015-01-14 19:08:54 +00:00
|
|
|
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}$')
|