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

Side by Side Diff: third_party/gsutil/boto/tests/integration/sts/test_session_token.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 # 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 sts = True
36
37 def test_session_token(self):
38 print '--- running Session Token tests ---'
39 c = STSConnection()
40
41 # Create a session token
42 token = c.get_session_token()
43
44 # Save session token to a file
45 token.save('token.json')
46
47 # Now load up a copy of that token
48 token_copy = Credentials.load('token.json')
49 assert token_copy.access_key == token.access_key
50 assert token_copy.secret_key == token.secret_key
51 assert token_copy.session_token == token.session_token
52 assert token_copy.expiration == token.expiration
53 assert token_copy.request_id == token.request_id
54
55 os.unlink('token.json')
56
57 assert not token.is_expired()
58
59 # Try using the session token with S3
60 s3 = S3Connection(aws_access_key_id=token.access_key,
61 aws_secret_access_key=token.secret_key,
62 security_token=token.session_token)
63 buckets = s3.get_all_buckets()
64
65 print '--- tests completed ---'
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698