Index: third_party/gsutil/third_party/boto/tests/unit/cloudtrail/test_layer1.py |
diff --git a/third_party/gsutil/third_party/boto/tests/unit/cloudtrail/test_layer1.py b/third_party/gsutil/third_party/boto/tests/unit/cloudtrail/test_layer1.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..10f6f7022146bd77f3b012d3a4a7927af229b753 |
--- /dev/null |
+++ b/third_party/gsutil/third_party/boto/tests/unit/cloudtrail/test_layer1.py |
@@ -0,0 +1,81 @@ |
+#!/usr/bin/env python |
+ |
+import json |
+ |
+from boto.cloudtrail.layer1 import CloudTrailConnection |
+from tests.unit import AWSMockServiceTestCase |
+ |
+ |
+class TestDescribeTrails(AWSMockServiceTestCase): |
+ connection_class = CloudTrailConnection |
+ |
+ def default_body(self): |
+ return b''' |
+ {"trailList": |
+ [ |
+ { |
+ "IncludeGlobalServiceEvents": false, |
+ "Name": "test", |
+ "SnsTopicName": "cloudtrail-1", |
+ "S3BucketName": "cloudtrail-1" |
+ } |
+ ] |
+ }''' |
+ |
+ def test_describe(self): |
+ self.set_http_response(status_code=200) |
+ api_response = self.service_connection.describe_trails() |
+ |
+ self.assertEqual(1, len(api_response['trailList'])) |
+ self.assertEqual('test', api_response['trailList'][0]['Name']) |
+ |
+ self.assert_request_parameters({}) |
+ |
+ target = self.actual_request.headers['X-Amz-Target'] |
+ self.assertTrue('DescribeTrails' in target) |
+ |
+ def test_describe_name_list(self): |
+ self.set_http_response(status_code=200) |
+ api_response = self.service_connection.describe_trails( |
+ trail_name_list=['test']) |
+ |
+ self.assertEqual(1, len(api_response['trailList'])) |
+ self.assertEqual('test', api_response['trailList'][0]['Name']) |
+ |
+ self.assertEqual(json.dumps({ |
+ 'trailNameList': ['test'] |
+ }), self.actual_request.body.decode('utf-8')) |
+ |
+ target = self.actual_request.headers['X-Amz-Target'] |
+ self.assertTrue('DescribeTrails' in target) |
+ |
+ |
+class TestCreateTrail(AWSMockServiceTestCase): |
+ connection_class = CloudTrailConnection |
+ |
+ def default_body(self): |
+ return b''' |
+ {"trail": |
+ { |
+ "IncludeGlobalServiceEvents": false, |
+ "Name": "test", |
+ "SnsTopicName": "cloudtrail-1", |
+ "S3BucketName": "cloudtrail-1" |
+ } |
+ }''' |
+ |
+ def test_create(self): |
+ self.set_http_response(status_code=200) |
+ |
+ api_response = self.service_connection.create_trail( |
+ 'test', 'cloudtrail-1', sns_topic_name='cloudtrail-1', |
+ include_global_service_events=False) |
+ |
+ self.assertEqual('test', api_response['trail']['Name']) |
+ self.assertEqual('cloudtrail-1', api_response['trail']['S3BucketName']) |
+ self.assertEqual('cloudtrail-1', api_response['trail']['SnsTopicName']) |
+ self.assertEqual(False, |
+ api_response['trail']['IncludeGlobalServiceEvents']) |
+ |
+ target = self.actual_request.headers['X-Amz-Target'] |
+ self.assertTrue('CreateTrail' in target) |