def test_dynamodb_backend_delete(dynamodb_table): from swag_client.backend import SWAGManager from swag_client.util import parse_swag_config_options swag_opts = { 'swag.type': 'dynamodb', 'swag.namespace': 'accounts', 'swag.cache_expires': 0 } swag = SWAGManager(**parse_swag_config_options(swag_opts)) account = { 'aliases': ['test'], 'contacts': ['*****@*****.**'], 'description': 'LOL, Test account', 'email': '*****@*****.**', 'environment': 'test', 'id': '012345678910', 'name': 'testaccount', 'owner': 'netflix', 'provider': 'aws', 'sensitive': False } swag.create(account) swag.delete(account) assert not swag.get("[?id=='012345678910']")
def test_s3_backend_delete_v1(s3_bucket_name): from swag_client.backend import SWAGManager from swag_client.util import parse_swag_config_options swag_opts = { 'swag.type': 's3', 'swag.bucket_name': s3_bucket_name, 'swag.schema_version': 1, 'swag.cache_expires': 0 } swagv1 = SWAGManager(**parse_swag_config_options(swag_opts)) account = { "bastion": "testaccount.net", "metadata": { "s3_name": "testaccounts3", "cloudtrail_index": "cloudtrail_testaccount[yyyymm]", "cloudtrail_kibana_url": "http://testaccount.cloudtrail.dashboard.net", "email": "*****@*****.**", "account_number": "012345678910" }, "schema_version": 1, "owners": ["*****@*****.**"], "ours": True, "email": "*****@*****.**", "description": "LOL, Test account", "cmc_required": False, "tags": ["testing"], "id": "aws-012345678910", "name": "testaccount", "type": "aws", "alias": [ "test", ], "services": { "rolliepollie": { "enabled": True }, "awwwdit": { "enabled": True } } } swagv1.create(account) assert len(swagv1.get_all()['accounts']) == 1 swagv1.delete(account) assert len(swagv1.get_all()['accounts']) == 0
def test_s3_backend_delete(s3_bucket_name): from swag_client.backend import SWAGManager from swag_client.util import parse_swag_config_options swag_opts = { 'swag.type': 's3', 'swag.bucket_name': s3_bucket_name, 'swag.cache_expires': 0 } swag = SWAGManager(**parse_swag_config_options(swag_opts)) account = { 'aliases': ['test'], 'contacts': ['*****@*****.**'], 'description': 'LOL, Test account', 'email': '*****@*****.**', 'environment': 'test', 'id': '012345678910', 'name': 'testaccount', 'owner': 'netflix', 'provider': 'aws', 'sensitive': False } swag.create(account) account = { 'aliases': ['test'], 'contacts': ['*****@*****.**'], 'description': 'LOL, Test account', 'email': '*****@*****.**', 'environment': 'test', 'id': '012345678911', 'name': 'testaccount', 'owner': 'netflix', 'provider': 'aws', 'sensitive': False } swag.create(account) assert len(swag.get_all()) == 2 swag.delete(account) assert len(swag.get_all()) == 1