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

Side by Side Diff: third_party/gsutil/boto/tests/sts/test_session_token.py

Issue 10199002: Upgrade gsutil to 3.4 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « third_party/gsutil/boto/tests/sts/__init__.py ('k') | third_party/gsutil/boto/tests/test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2012 Mitch Garnaat http://garnaat.org/
2 # 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 Tests for Session Tokens
25 """
26
27 import unittest
28 import time
29 import os
30 from boto.sts.connection import STSConnection
31 from boto.sts.credentials import Credentials
32 from boto.s3.connection import S3Connection
33
34 class SessionTokenTest (unittest.TestCase):
35
36 def test_session_token(self):
37 print '--- running Session Token tests ---'
38 c = STSConnection()
39
40 # Create a session token
41 token = c.get_session_token()
42
43 # Save session token to a file
44 token.save('token.json')
45
46 # Now load up a copy of that token
47 token_copy = Credentials.load('token.json')
48 assert token_copy.access_key == token.access_key
49 assert token_copy.secret_key == token.secret_key
50 assert token_copy.session_token == token.session_token
51 assert token_copy.expiration == token.expiration
52 assert token_copy.request_id == token.request_id
53
54 os.unlink('token.json')
55
56 assert not token.is_expired()
57
58 # Try using the session token with S3
59 s3 = S3Connection(aws_access_key_id=token.access_key,
60 aws_secret_access_key=token.secret_key,
61 security_token=token.session_token)
62 buckets = s3.get_all_buckets()
63
64 print '--- tests completed ---'
65
OLDNEW
« no previous file with comments | « third_party/gsutil/boto/tests/sts/__init__.py ('k') | third_party/gsutil/boto/tests/test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698