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

Side by Side Diff: third_party/gsutil/boto/tests/unit/sts/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 boto.sts.connection import STSConnection
26 from tests.unit import AWSMockServiceTestCase
27
28
29 class TestSTSConnection(AWSMockServiceTestCase):
30 connection_class = STSConnection
31
32 def setUp(self):
33 super(TestSTSConnection, self).setUp()
34
35 def default_body(self):
36 return """
37 <AssumeRoleResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/ ">
38 <AssumeRoleResult>
39 <AssumedRoleUser>
40 <Arn>arn:role</Arn>
41 <AssumedRoleId>roleid:myrolesession</AssumedRoleId>
42 </AssumedRoleUser>
43 <Credentials>
44 <SessionToken>session_token</SessionToken>
45 <SecretAccessKey>secretkey</SecretAccessKey>
46 <Expiration>2012-10-18T10:18:14.789Z</Expiration>
47 <AccessKeyId>accesskey</AccessKeyId>
48 </Credentials>
49 </AssumeRoleResult>
50 <ResponseMetadata>
51 <RequestId>8b7418cb-18a8-11e2-a706-4bd22ca68ab7</RequestId>
52 </ResponseMetadata>
53 </AssumeRoleResponse>
54 """
55
56 def test_assume_role(self):
57 self.set_http_response(status_code=200)
58 response = self.service_connection.assume_role('arn:role', 'mysession')
59 self.assert_request_parameters(
60 {'Action': 'AssumeRole',
61 'RoleArn': 'arn:role',
62 'RoleSessionName': 'mysession'},
63 ignore_params_values=['Timestamp', 'AWSAccessKeyId',
64 'SignatureMethod', 'SignatureVersion',
65 'Version'])
66 self.assertEqual(response.credentials.access_key, 'accesskey')
67 self.assertEqual(response.credentials.secret_key, 'secretkey')
68 self.assertEqual(response.credentials.session_token, 'session_token')
69 self.assertEqual(response.user.arn, 'arn:role')
70 self.assertEqual(response.user.assume_role_id, 'roleid:myrolesession')
71
72
73 if __name__ == '__main__':
74 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698