def regular_account(): account = { 'accountId': '500', 'account_name': 'blue', } accounts_table.put_item(Item=account) yield account accounts_table.delete_item(Key={'accountId': account['accountId']})
def special_account(): account = { 'accountId': '600', 'account_name': 'green', 'scorecard_profile': 'special', } accounts_table.put_item(Item=account) yield account accounts_table.delete_item(Key={'accountId': account['accountId']})
def test_no_cross_account_role(self): account = { 'accountId': '100', 'scorecard_profile': 'settings1' } accounts_table.put_item(Item=account) with pytest.raises(ValueError): cloudsploit_setup(self.event, None) accounts_table.delete_item(Key={'accountId': account['accountId']})
def test_invalid_setting(self): account = { 'accountId': '100', 'cross_account_role': 'arn:aaa', 'scorecard_profile': 'settingNotPresent', } accounts_table.put_item(Item=account) with pytest.raises(KeyError): cloudsploit_setup(self.event, None) accounts_table.delete_item(Key={'accountId': account['accountId']})
def test_default_settings(self): account = { 'accountId': '100', 'cross_account_role': 'arn:aaa', } expected_result = { 'cloud': 'aws', 'cloudConfig': {'roleArn': 'arn:aaa'}, 'settings': { 'key1': 'value1' }, 's3Prefix': '100' } accounts_table.put_item(Item=account) output = cloudsploit_setup(self.event, None) accounts_table.delete_item(Key={'accountId': account['accountId']}) assert output == expected_result
def test_setting_selection(self): """Tests the logic for setting up cloudsploit and returns the required error or cloudsploit settings""" account = { 'accountId': '100', 'cross_account_role': 'arn:aaa', 'scorecard_profile': 'settings1' } desired_output = { 'cloud': 'aws', 'cloudConfig': {'roleArn': 'arn:aaa'}, 'settings': { 'key_1': 'value_1' }, 's3Prefix': '100' } accounts_table.put_item(Item=account) output = cloudsploit_setup(self.event, None) accounts_table.delete_item(Key={'accountId': account['accountId']}) assert output == desired_output
def del_mock_accountsdata(): for data in ACCOUNTS_DATA: accounts_table.delete_item(Key={'accountId': data['accountId']})