diff --git a/tests/unit/responses/alarms/monitoring.ListTagsForResource_1.json b/tests/unit/responses/alarms/monitoring.ListTagsForResource_1.json new file mode 100644 index 0000000..f9ef1fb --- /dev/null +++ b/tests/unit/responses/alarms/monitoring.ListTagsForResource_1.json @@ -0,0 +1,15 @@ +{ + "status_code": 200, + "data": { + "Tags": [ + { + "Key": "Env", + "Value": "Production" + }, + { + "Key": "Project", + "Value": "Marketing" + } + ] + } +} diff --git a/tests/unit/responses/applications/elasticbeanstalk.DescribeApplications_1.json b/tests/unit/responses/applications/elasticbeanstalk.DescribeApplications_1.json new file mode 100644 index 0000000..d352397 --- /dev/null +++ b/tests/unit/responses/applications/elasticbeanstalk.DescribeApplications_1.json @@ -0,0 +1,31 @@ +{ + "status_code": 200, + "data": { + "Applications": [ + { + "ApplicationArn": "arn:aws:elasticbeanstalk:us-east-1:123456789012:application/super-app", + "ApplicationName": "super-app", + "DateCreated": "2020-08-28T07:07:41.158Z", + "DateUpdated": "2020-08-28T07:07:41.158Z", + "Versions": [ + "Sample Application" + ], + "ConfigurationTemplates": [], + "ResourceLifecycleConfig": { + "VersionLifecycleConfig": { + "MaxCountRule": { + "Enabled": false, + "MaxCount": 200, + "DeleteSourceFromS3": false + }, + "MaxAgeRule": { + "Enabled": false, + "MaxAgeInDays": 180, + "DeleteSourceFromS3": false + } + } + } + } + ] + } +} diff --git a/tests/unit/responses/applications/elasticbeanstalk.ListTagsForResource_1.json b/tests/unit/responses/applications/elasticbeanstalk.ListTagsForResource_1.json new file mode 100644 index 0000000..a07b3f3 --- /dev/null +++ b/tests/unit/responses/applications/elasticbeanstalk.ListTagsForResource_1.json @@ -0,0 +1,16 @@ +{ + "status_code": 200, + "data": { + "ResourceArn": "arn:aws:elasticbeanstalk:us-east-1:123456789012:application/super-app", + "ResourceTags": [ + { + "Key": "Env", + "Value": "Production" + }, + { + "Key": "Project", + "Value": "Marketing" + } + ] + } +} diff --git a/tests/unit/responses/deliverystreams/firehose.DescribeDeliveryStream_1.json b/tests/unit/responses/deliverystreams/firehose.DescribeDeliveryStream_1.json new file mode 100644 index 0000000..3e1fe05 --- /dev/null +++ b/tests/unit/responses/deliverystreams/firehose.DescribeDeliveryStream_1.json @@ -0,0 +1,65 @@ +{ + "status_code": 200, + "data": { + "DeliveryStreamDescription": { + "DeliveryStreamName": "test-delivery-stream", + "DeliveryStreamARN": "arn:aws:firehose:us-east-1:123456789012:deliverystream/test-delivery-stream", + "DeliveryStreamStatus": "ACTIVE", + "DeliveryStreamEncryptionConfiguration": { + "Status": "DISABLED" + }, + "DeliveryStreamType": "DirectPut", + "VersionId": "1", + "CreateTimestamp": 1598963515.917, + "Destinations": [ + { + "DestinationId": "destinationId-000000000001", + "S3DestinationDescription": { + "RoleARN": "arn:aws:iam::123456789012:role/service-role/KinesisFirehoseServiceRole-test-deliv", + "BucketARN": "arn:aws:s3:::some-bucket", + "Prefix": "", + "ErrorOutputPrefix": "", + "BufferingHints": { + "SizeInMBs": 5, + "IntervalInSeconds": 300 + }, + "CompressionFormat": "UNCOMPRESSED", + "EncryptionConfiguration": { + "NoEncryptionConfig": "NoEncryption" + }, + "CloudWatchLoggingOptions": { + "Enabled": true, + "LogGroupName": "/aws/kinesisfirehose/test-delivery-stream", + "LogStreamName": "S3Delivery" + } + }, + "ExtendedS3DestinationDescription": { + "RoleARN": "arn:aws:iam::123456789012:role/service-role/KinesisFirehoseServiceRole-test-deliv", + "BucketARN": "arn:aws:s3:::some-bucket", + "Prefix": "", + "ErrorOutputPrefix": "", + "BufferingHints": { + "SizeInMBs": 5, + "IntervalInSeconds": 300 + }, + "CompressionFormat": "UNCOMPRESSED", + "EncryptionConfiguration": { + "NoEncryptionConfig": "NoEncryption" + }, + "CloudWatchLoggingOptions": { + "Enabled": true, + "LogGroupName": "/aws/kinesisfirehose/test-delivery-stream", + "LogStreamName": "S3Delivery" + }, + "ProcessingConfiguration": { + "Enabled": false, + "Processors": [] + }, + "S3BackupMode": "Disabled" + } + } + ], + "HasMoreDestinations": false + } + } +} diff --git a/tests/unit/responses/deliverystreams/firehose.ListDeliveryStreams_1.json b/tests/unit/responses/deliverystreams/firehose.ListDeliveryStreams_1.json new file mode 100644 index 0000000..f0e9a66 --- /dev/null +++ b/tests/unit/responses/deliverystreams/firehose.ListDeliveryStreams_1.json @@ -0,0 +1,9 @@ +{ + "status_code": 200, + "data": { + "DeliveryStreamNames": [ + "delivery-stream-1" + ], + "HasMoreDeliveryStreams": false + } +} diff --git a/tests/unit/responses/deliverystreams/firehose.ListTagsForDeliveryStream_1.json b/tests/unit/responses/deliverystreams/firehose.ListTagsForDeliveryStream_1.json new file mode 100644 index 0000000..67097f4 --- /dev/null +++ b/tests/unit/responses/deliverystreams/firehose.ListTagsForDeliveryStream_1.json @@ -0,0 +1,16 @@ +{ + "status_code": 200, + "data": { + "Tags": [ + { + "Key": "Env", + "Value": "Production" + }, + { + "Key": "Project", + "Value": "Marketing" + } + ], + "HasMoreTags": false + } +} diff --git a/tests/unit/responses/environments/elasticbeanstalk.ListTagsForResource_1.json b/tests/unit/responses/environments/elasticbeanstalk.ListTagsForResource_1.json new file mode 100644 index 0000000..033748f --- /dev/null +++ b/tests/unit/responses/environments/elasticbeanstalk.ListTagsForResource_1.json @@ -0,0 +1,16 @@ +{ + "status_code": 200, + "data": { + "ResourceArn": "arn:aws:elasticbeanstalk:us-west-2:123456789012:environment/sample-application/Env1", + "ResourceTags": [ + { + "Key": "Env", + "Value": "Production" + }, + { + "Key": "Project", + "Value": "Marketing" + } + ] + } +} diff --git a/tests/unit/responses/rdssecgrps/rds.DescribeDBSecurityGroups_1.json b/tests/unit/responses/rdssecgrps/rds.DescribeDBSecurityGroups_1.json new file mode 100644 index 0000000..e66f602 --- /dev/null +++ b/tests/unit/responses/rdssecgrps/rds.DescribeDBSecurityGroups_1.json @@ -0,0 +1,15 @@ +{ + "status_code": 200, + "data": { + "DBSecurityGroups": [ + { + "OwnerId": "123456789012", + "DBSecurityGroupName": "default", + "DBSecurityGroupDescription": "default", + "EC2SecurityGroups": [], + "IPRanges": [], + "DBSecurityGroupArn": "arn:aws:rds:us-east-1:123456789012:secgrp:default" + } + ] + } +} diff --git a/tests/unit/responses/rdssecgrps/rds.ListTagsForResource_1.json b/tests/unit/responses/rdssecgrps/rds.ListTagsForResource_1.json new file mode 100644 index 0000000..8c6d95d --- /dev/null +++ b/tests/unit/responses/rdssecgrps/rds.ListTagsForResource_1.json @@ -0,0 +1,16 @@ +{ + "status_code": 200, + "data": { + "TagList": [ + { + "Key": "Env", + "Value": "Production" + }, + { + "Key": "Project", + "Value": "Marketing" + } + ] + } + +} diff --git a/tests/unit/responses/topics/sns.GetTopicAttributes_1.json b/tests/unit/responses/topics/sns.GetTopicAttributes_1.json new file mode 100644 index 0000000..2b5e5c6 --- /dev/null +++ b/tests/unit/responses/topics/sns.GetTopicAttributes_1.json @@ -0,0 +1,15 @@ +{ + "status_code": 200, + "data": { + "Attributes": { + "Policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:us-east-1:123456789012:Default_CloudWatch_Alarms_Topic\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"123456789012\"}}}]}", + "Owner": "123456789012", + "SubscriptionsPending": "0", + "TopicArn": "arn:aws:sns:us-east-1:123456789012:SomeTopic", + "EffectiveDeliveryPolicy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false}}", + "SubscriptionsConfirmed": "0", + "DisplayName": "", + "SubscriptionsDeleted": "0" + } + } +} diff --git a/tests/unit/responses/topics/sns.ListTagsForResource_1.json b/tests/unit/responses/topics/sns.ListTagsForResource_1.json new file mode 100644 index 0000000..f9ef1fb --- /dev/null +++ b/tests/unit/responses/topics/sns.ListTagsForResource_1.json @@ -0,0 +1,15 @@ +{ + "status_code": 200, + "data": { + "Tags": [ + { + "Key": "Env", + "Value": "Production" + }, + { + "Key": "Project", + "Value": "Marketing" + } + ] + } +} diff --git a/tests/unit/responses/topics/sns.ListTopics_1.json b/tests/unit/responses/topics/sns.ListTopics_1.json new file mode 100644 index 0000000..427c7ed --- /dev/null +++ b/tests/unit/responses/topics/sns.ListTopics_1.json @@ -0,0 +1,10 @@ +{ + "status_code": 200, + "data": { + "Topics": [ + { + "TopicArn": "arn:aws:sns:us-east-1:123456789012:SomeTopic" + } + ] + } +} diff --git a/tests/unit/test_arn.py b/tests/unit/test_arn.py index 85f27c7..6f53b5a 100644 --- a/tests/unit/test_arn.py +++ b/tests/unit/test_arn.py @@ -343,6 +343,8 @@ def test_alarm(self): self.assertEqual(l[0].arn, 'arn:aws:cloudwatch:us-east-1:123456789012:alarm:some-alarm') self.assertEqual(l[0].data['AlarmArn'], 'arn:aws:cloudwatch:us-east-1:123456789012:alarm:some-alarm') + self.assertEqual(l[0].tags['Env'], 'Production') + self.assertEqual(l[0].tags['Project'], 'Marketing') def test_customer_gateway(self): placebo_cfg = { @@ -367,9 +369,11 @@ def test_beanstalk_environments(self): **placebo_cfg) l = list(arn) r = l[0] - self.assertEqual(r.data['EnvironmentName'], "Env1") - self.assertEqual(r.arn, "arn:aws:elasticbeanstalk:us-west-2:123456789012:environment/sample-application/Env1") - self.assertEqual(r.data['ApplicationName'], "sample-application") + self.assertEqual(r.data['EnvironmentName'], 'Env1') + self.assertEqual(r.arn, 'arn:aws:elasticbeanstalk:us-west-2:123456789012:environment/sample-application/Env1') + self.assertEqual(r.data['ApplicationName'], 'sample-application') + self.assertEqual(r.tags['Env'], 'Production') + self.assertEqual(r.tags['Project'], 'Marketing') def test_ec2_address(self): placebo_cfg = { @@ -388,7 +392,6 @@ def test_ec2_address(self): self.assertEqual(l[2].data['Tags'], [{'Key': 'Name', 'Value': 'some-name'}, {'Key': 'Env', 'Value': 'Prod'}]) - def test_vpc_peering_connection(self): placebo_cfg = { 'placebo': placebo, @@ -401,4 +404,58 @@ def test_vpc_peering_connection(self): self.assertEqual(len(l), 1) self.assertEqual(l[0].arn, 'arn:aws:ec2:us-east-1:123456789012:vpc-peering-connection/pcx-027a582b95db2af78') + def test_sns(self): + placebo_cfg = { + 'placebo': placebo, + 'placebo_dir': self._get_response_path('topics'), + 'placebo_mode': 'playback'} + arn = scan( + 'arn:aws:sns:us-east-1:123456789012:topic/*', + **placebo_cfg) + l = list(arn) + self.assertEqual(len(l), 1) + self.assertEqual(l[0].arn, 'arn:aws:sns:us-east-1:123456789012:SomeTopic') + self.assertEqual(l[0].tags['Env'], 'Production') + self.assertEqual(l[0].tags['Project'], 'Marketing') + + def test_elasticbeanstalk_application(self): + placebo_cfg = { + 'placebo': placebo, + 'placebo_dir': self._get_response_path('applications'), + 'placebo_mode': 'playback'} + arn = scan( + 'arn:aws:elasticbeanstalk:us-east-1:123456789012:application/*', + **placebo_cfg) + l = list(arn) + self.assertEqual(len(l), 1) + self.assertEqual(l[0].arn, 'arn:aws:elasticbeanstalk:us-east-1:123456789012:application/super-app') + self.assertEqual(l[0].tags['Env'], 'Production') + self.assertEqual(l[0].tags['Project'], 'Marketing') + def test_rds_sec_grp(self): + placebo_cfg = { + 'placebo': placebo, + 'placebo_dir': self._get_response_path('rdssecgrps'), + 'placebo_mode': 'playback'} + arn = scan( + 'arn:aws:rds:us-east-1:123456789012:secgrp/*', + **placebo_cfg) + l = list(arn) + self.assertEqual(len(l), 1) + self.assertEqual(l[0].arn, 'arn:aws:rds:us-east-1:123456789012:secgrp:default') + self.assertEqual(l[0].tags['Env'], 'Production') + self.assertEqual(l[0].tags['Project'], 'Marketing') + + def test_firehose(self): + placebo_cfg = { + 'placebo': placebo, + 'placebo_dir': self._get_response_path('deliverystreams'), + 'placebo_mode': 'playback'} + arn = scan( + 'arn:aws:firehose:us-east-1:123456789012:deliverystream/*', + **placebo_cfg) + l = list(arn) + self.assertEqual(len(l), 1) + self.assertEqual(l[0].arn, 'arn:aws:firehose:us-east-1:123456789012:deliverystream/delivery-stream-1') + self.assertEqual(l[0].tags['Env'], 'Production') + self.assertEqual(l[0].tags['Project'], 'Marketing')