<s> """<STR_LIT>""" <EOL> import unittest <EOL> import time <EOL> from boto . s3 . connection import S3Connection <EOL> from boto . exception import S3ResponseError <EOL> json_policy = """<STR_LIT>""" <EOL> class S3EncryptionTest ( unittest . TestCase ) : <EOL> s3 = True <EOL> def test_1_versions ( self ) : <EOL> print ( '<STR_LIT>' ) <EOL> c = S3Connection ( ) <EOL> bucket_name = '<STR_LIT>' % int ( time . time ( ) ) <EOL> bucket = c . create_bucket ( bucket_name ) <EOL> bucket = c . get_bucket ( bucket_name ) <EOL> k = bucket . new_key ( '<STR_LIT>' ) <EOL> s1 = '<STR_LIT>' <EOL> s2 = '<STR_LIT>' <EOL> k . set_contents_from_string ( s1 ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> o = k . get_contents_as_string ( ) . decode ( '<STR_LIT:utf-8>' ) <EOL> assert o == s1 <EOL> k . set_contents_from_string ( s2 , encrypt_key = True ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> o = k . get_contents_as_string ( ) . decode ( '<STR_LIT:utf-8>' ) <EOL> assert o == s2 <EOL> bucket . set_policy ( json_policy % bucket . name ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> write_failed = False <EOL> try : <EOL> k . set_contents_from_string ( s1 ) <EOL> except S3ResponseError : <EOL> write_failed = True <EOL> assert write_failed <EOL> write_failed = False <EOL> try : <EOL> k . set_contents_from_string ( s1 , encrypt_key = True ) <EOL> except S3ResponseError : <EOL> write_failed = True <EOL> assert not write_failed <EOL> k . delete ( ) <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> bucket . delete ( ) <EOL> print ( '<STR_LIT>' ) </s>
