parent
34c711189f
commit
6e61ee4caa
@ -25,6 +25,7 @@ class FakeKey(BaseModel):
|
||||
self.value = value
|
||||
self.last_modified = datetime.datetime.utcnow()
|
||||
self.acl = get_canned_acl('private')
|
||||
self.website_redirect_location = None
|
||||
self._storage_class = storage if storage else "STANDARD"
|
||||
self._metadata = {}
|
||||
self._expiry = None
|
||||
@ -103,6 +104,9 @@ class FakeKey(BaseModel):
|
||||
if self._is_versioned:
|
||||
res['x-amz-version-id'] = str(self._version_id)
|
||||
|
||||
if self.website_redirect_location:
|
||||
res['x-amz-website-redirect-location'] = self.website_redirect_location
|
||||
|
||||
return res
|
||||
|
||||
@property
|
||||
|
@ -570,6 +570,7 @@ class ResponseObject(_TemplateEnvironmentMixin):
|
||||
metadata = metadata_from_headers(request.headers)
|
||||
new_key.set_metadata(metadata)
|
||||
new_key.set_acl(acl)
|
||||
new_key.website_redirect_location = request.headers.get('x-amz-website-redirect-location')
|
||||
|
||||
template = self.response_template(S3_OBJECT_RESPONSE)
|
||||
response_headers.update(new_key.response_dict)
|
||||
|
@ -1046,6 +1046,19 @@ def test_boto3_key_etag():
|
||||
resp = s3.get_object(Bucket='mybucket', Key='steve')
|
||||
resp['ETag'].should.equal('"d32bda93738f7e03adb22e66c90fbc04"')
|
||||
|
||||
@mock_s3
|
||||
def test_website_redirect_location():
|
||||
s3 = boto3.client('s3', region_name='us-east-1')
|
||||
s3.create_bucket(Bucket='mybucket')
|
||||
|
||||
s3.put_object(Bucket='mybucket', Key='steve', Body=b'is awesome')
|
||||
resp = s3.get_object(Bucket='mybucket', Key='steve')
|
||||
resp.get('WebsiteRedirectLocation').should.be.none
|
||||
|
||||
url = 'https://github.com/spulec/moto'
|
||||
s3.put_object(Bucket='mybucket', Key='steve', Body=b'is awesome', WebsiteRedirectLocation=url)
|
||||
resp = s3.get_object(Bucket='mybucket', Key='steve')
|
||||
resp['WebsiteRedirectLocation'].should.equal(url)
|
||||
|
||||
@mock_s3
|
||||
def test_boto3_list_keys_xml_escaped():
|
||||
|
Loading…
Reference in New Issue
Block a user