def test_s3_object_expiry(self):
    bucket_name = ('test-%s' % short_uid())
    self.s3_client.create_bucket(Bucket=bucket_name)
    object_key = 'key-with-metadata'
    metadata = {'test_meta_1': 'foo', '__meta_2': 'bar'}
    self.s3_client.put_object(Bucket=bucket_name, Key=object_key, Metadata=metadata, Body='foo', Expires=(datetime.datetime.now(timezone('GMT')) - datetime.timedelta(hours=1)))
    self.assertRaises(Exception, self.s3_client.get_object, Bucket=bucket_name, Key=object_key.lower())
    self.s3_client.put_object(Bucket=bucket_name, Key=object_key, Metadata=metadata, Body='foo', Expires=(datetime.datetime.now(timezone('GMT')) + datetime.timedelta(hours=1)))
    resp = self.s3_client.get_object(Bucket=bucket_name, Key=object_key)
    self.assertIn('Expires', resp)
    self._delete_bucket(bucket_name, [object_key])
def test_s3_object_expiry(self):
    bucket_name = ('test-%s' % short_uid())
    self.s3_client.create_bucket(Bucket=bucket_name)
    object_key = 'key-with-metadata'
    metadata = {'test_meta_1': 'foo', '__meta_2': 'bar'}
    self.s3_client.put_object(Bucket=bucket_name, Key=object_key, Metadata=metadata, Body='foo', Expires=(datetime.datetime.now(timezone('GMT')) - datetime.timedelta(hours=1)))
    self.assertRaises(Exception, self.s3_client.get_object, Bucket=bucket_name, Key=object_key.lower())
    self.s3_client.put_object(Bucket=bucket_name, Key=object_key, Metadata=metadata, Body='foo', Expires=(datetime.datetime.now(timezone('GMT')) + datetime.timedelta(hours=1)))
    resp = self.s3_client.get_object(Bucket=bucket_name, Key=object_key)
    self.assertIn('Expires', resp)
    self._delete_bucket(bucket_name, [object_key])