Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: third_party/gsutil/boto/tests/unit/sqs/test_connection.py

Issue 12317103: Added gsutil to depot tools (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: added readme Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining a
5 # copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish, dis-
8 # tribute, sublicense, and/or sell copies of the Software, and to permit
9 # persons to whom the Software is furnished to do so, subject to the fol-
10 # lowing conditions:
11 #
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 # IN THE SOFTWARE.
22 #
23
24 from tests.unit import unittest
25 from tests.unit import AWSMockServiceTestCase
26
27 from boto.sqs.connection import SQSConnection
28 from boto.sqs.regioninfo import SQSRegionInfo
29
30
31 class SQSAuthParams(AWSMockServiceTestCase):
32 connection_class = SQSConnection
33
34 def setUp(self):
35 super(SQSAuthParams, self).setUp()
36
37 def default_body(self):
38 return """<?xml version="1.0"?>
39 <CreateQueueResponse>
40 <CreateQueueResult>
41 <QueueUrl>
42 https://queue.amazonaws.com/599169622985/myqueue1
43 </QueueUrl>
44 </CreateQueueResult>
45 <ResponseMetadata>
46 <RequestId>54d4c94d-2307-54a8-bb27-806a682a5abd</RequestId>
47 </ResponseMetadata>
48 </CreateQueueResponse>"""
49
50 def test_auth_service_name_override(self):
51 self.set_http_response(status_code=200)
52 # We can use the auth_service_name to change what service
53 # name to use for the credential scope for sigv4.
54 self.service_connection.auth_service_name = 'service_override'
55
56 self.service_connection.create_queue('my_queue')
57 # Note the service_override value instead.
58 self.assertIn('us-east-1/service_override/aws4_request',
59 self.actual_request.headers['Authorization'])
60
61 def test_class_attribute_can_set_service_name(self):
62 self.set_http_response(status_code=200)
63 # The SQS class has an 'AuthServiceName' param of 'sqs':
64 self.assertEqual(self.service_connection.AuthServiceName, 'sqs')
65
66 self.service_connection.create_queue('my_queue')
67 # And because of this, the value of 'sqs' will be used instead of
68 # 'queue' for the credential scope:
69 self.assertIn('us-east-1/sqs/aws4_request',
70 self.actual_request.headers['Authorization'])
71
72 def test_auth_region_name_is_automatically_updated(self):
73 region = SQSRegionInfo(name='us-west-2',
74 endpoint='us-west-2.queue.amazonaws.com')
75 self.service_connection = SQSConnection(
76 https_connection_factory=self.https_connection_factory,
77 aws_access_key_id='aws_access_key_id',
78 aws_secret_access_key='aws_secret_access_key',
79 region=region)
80 self.initialize_service_connection()
81 self.set_http_response(status_code=200)
82
83 self.service_connection.create_queue('my_queue')
84 # Note the region name below is 'us-west-2'.
85 self.assertIn('us-west-2/sqs/aws4_request',
86 self.actual_request.headers['Authorization'])
87
88 def test_set_get_auth_service_and_region_names(self):
89 self.service_connection.auth_service_name = 'service_name'
90 self.service_connection.auth_region_name = 'region_name'
91
92 self.assertEqual(self.service_connection.auth_service_name,
93 'service_name')
94 self.assertEqual(self.service_connection.auth_region_name, 'region_name' )
95
96
97 if __name__ == '__main__':
98 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698