예제 #1
0
def test_session():
    session = Session()
    assert session.session is None
    assert session.region_name is None
    assert session.role_arn is None
    inspect.isclass(Session)
    assert isinstance(session, Session)
예제 #2
0
 def __init__(self, role_arn=None, region_name=None):
     self.master_account = None
     self.org_root = None
     self.org_unit = None
     self.org_units = {}
     self.accounts = {}
     self.org = Session(role_arn=role_arn,
                        region_name=region_name).get_client('organizations')
예제 #3
0
 def __init__(self, client=None, region_name=None):
     self.bucket_name = None
     self.key_name = None
     self.session = Session(region_name=region_name)
     if client:
         self.s3 = client
     else:
         self.s3 = self.session.get_client('s3')
예제 #4
0
 def __init__(self, role_arn=None, region_name=None):
     self.org_id = None
     self.org_arn = None
     self.master_acct_arn = None
     self.master_acct_email = None
     self.master_acct_id = None
     self.org = Session(role_arn=role_arn,
                        region_name=region_name).get_client('organizations')
예제 #5
0
def test_session_region_env():
    session = Session()
    assert session.get_region() is None

    os.environ['AWS_REGION'] = 'us-least-7'
    session.set_region()
    assert session.region_name == 'us-least-7'
    assert session.get_region() == 'us-least-7'
    os.environ.pop('AWS_REGION')
예제 #6
0
def test_client_with_service(sts, cc):
    session = Session()
    chk = session.get_client('project-grand-slam')
    assert chk == 'boto!'
    cc.assert_called_with(ANY,
                          'project-grand-slam',
                          aws_access_key_id=None,
                          aws_secret_access_key=None,
                          aws_session_token=None,
                          region_name=None)
    sts.assert_not_called()
예제 #7
0
def test_get_client_with_role(sts, cc):

    sts.assume_role.return_value = 20
    sts().aws_access_key_id = 'my_access_key'
    sts().aws_secret_access_key = 'my_secret_key'
    sts().aws_session_token = 'my_session_token'

    test_role_arn = 'arn:aws:iam::111111111:role/net.dilex.some.test.role'
    session = Session(role_arn=test_role_arn)
    chk = session.get_client('project-grand-slam')

    assert chk == 'boto!'
    cc.assert_called_once()
    cc.assert_called_with(ANY,
                          'project-grand-slam',
                          aws_access_key_id='my_access_key',
                          aws_secret_access_key='my_secret_key',
                          aws_session_token='my_session_token',
                          region_name=None)
예제 #8
0
파일: kms.py 프로젝트: DilexNetworks/AwAws
    def __init__(self, region_name=None):

        self.enc_regions = []
        self.master_keys = []
        self.key_provider = None
        self.kms = Session(region_name).get_client('kms')
예제 #9
0
def test_get_region():
    session = Session()
    session.set_region(region_name='us-least-6')
    assert session.region_name == 'us-least-6'
    assert session.get_region() == 'us-least-6'
예제 #10
0
def test_set_region():
    session = Session()
    session.set_region('us-least-8')
    assert session.region_name == 'us-least-8'
예제 #11
0
def test_session_region():
    session = Session(region_name='us-least-9')
    assert session.region_name == 'us-least-9'
예제 #12
0
def test_init_with_role_none():
    test_role_arn = None
    session = Session(role_arn=test_role_arn)
    assert session.role_arn is None
예제 #13
0
def test_init_with_role_and_region():
    test_region_name = 'us-least-5'
    test_role_arn = 'arn:aws:iam::111111111:role/net.dilex.some.test.role'
    session = Session(role_arn=test_role_arn, region_name=test_region_name)
    assert session.role_arn == 'arn:aws:iam::111111111:role/net.dilex.some.test.role'
    assert session.region_name == 'us-least-5'
예제 #14
0
파일: sqs.py 프로젝트: DilexNetworks/AwAws
 def __init__(self, region_name=None, role_arn=None):
     self.sqs_url = None
     self.sqs = Session(region_name, role_arn).get_client('sqs')
     self.messages = []
예제 #15
0
 def __init__(self, region_name=None, role_arn=None):
     self.accounts = []
     self.event_bus = 'event-bus/default'
     self.events = Session(region_name, role_arn).get_client('events')
예제 #16
0
 def get_ssm(self):
     if self.ssm is None:
         self.ssm = Session(self.region_name,
                            self.role_arn).get_client('ssm')
     return self.ssm