1987 support transfer acceleration (#2018)
* chore(): remove executable flag on moto/s3/response.py * chore(): ignore .eggs temp file * feat(#1987): get bucket acceleration support * feat(#1987): put bucket acceleration support * feat(#1987): suspend undefined bucket is a no-op * feat(#1987): validate accelerate_configuration status * feat(#1987): bucket containing dots do not support acceleration * doc(#1987): update implementation coverage
This commit is contained in:
parent
1b91534165
commit
d952410965
5 changed files with 133 additions and 6 deletions
|
|
@ -2820,3 +2820,80 @@ def test_boto3_bucket_name_too_short():
|
|||
with assert_raises(ClientError) as exc:
|
||||
s3.create_bucket(Bucket='x'*2)
|
||||
exc.exception.response['Error']['Code'].should.equal('InvalidBucketName')
|
||||
|
||||
@mock_s3
|
||||
def test_accelerated_none_when_unspecified():
|
||||
bucket_name = 'some_bucket'
|
||||
s3 = boto3.client('s3')
|
||||
s3.create_bucket(Bucket=bucket_name)
|
||||
resp = s3.get_bucket_accelerate_configuration(Bucket=bucket_name)
|
||||
resp.shouldnt.have.key('Status')
|
||||
|
||||
@mock_s3
|
||||
def test_can_enable_bucket_acceleration():
|
||||
bucket_name = 'some_bucket'
|
||||
s3 = boto3.client('s3')
|
||||
s3.create_bucket(Bucket=bucket_name)
|
||||
resp = s3.put_bucket_accelerate_configuration(
|
||||
Bucket=bucket_name,
|
||||
AccelerateConfiguration={'Status': 'Enabled'},
|
||||
)
|
||||
resp.keys().should.have.length_of(1) # Response contains nothing (only HTTP headers)
|
||||
resp = s3.get_bucket_accelerate_configuration(Bucket=bucket_name)
|
||||
resp.should.have.key('Status')
|
||||
resp['Status'].should.equal('Enabled')
|
||||
|
||||
@mock_s3
|
||||
def test_can_suspend_bucket_acceleration():
|
||||
bucket_name = 'some_bucket'
|
||||
s3 = boto3.client('s3')
|
||||
s3.create_bucket(Bucket=bucket_name)
|
||||
resp = s3.put_bucket_accelerate_configuration(
|
||||
Bucket=bucket_name,
|
||||
AccelerateConfiguration={'Status': 'Enabled'},
|
||||
)
|
||||
resp = s3.put_bucket_accelerate_configuration(
|
||||
Bucket=bucket_name,
|
||||
AccelerateConfiguration={'Status': 'Suspended'},
|
||||
)
|
||||
resp.keys().should.have.length_of(1) # Response contains nothing (only HTTP headers)
|
||||
resp = s3.get_bucket_accelerate_configuration(Bucket=bucket_name)
|
||||
resp.should.have.key('Status')
|
||||
resp['Status'].should.equal('Suspended')
|
||||
|
||||
@mock_s3
|
||||
def test_suspending_acceleration_on_not_configured_bucket_does_nothing():
|
||||
bucket_name = 'some_bucket'
|
||||
s3 = boto3.client('s3')
|
||||
s3.create_bucket(Bucket=bucket_name)
|
||||
resp = s3.put_bucket_accelerate_configuration(
|
||||
Bucket=bucket_name,
|
||||
AccelerateConfiguration={'Status': 'Suspended'},
|
||||
)
|
||||
resp.keys().should.have.length_of(1) # Response contains nothing (only HTTP headers)
|
||||
resp = s3.get_bucket_accelerate_configuration(Bucket=bucket_name)
|
||||
resp.shouldnt.have.key('Status')
|
||||
|
||||
@mock_s3
|
||||
def test_accelerate_configuration_status_validation():
|
||||
bucket_name = 'some_bucket'
|
||||
s3 = boto3.client('s3')
|
||||
s3.create_bucket(Bucket=bucket_name)
|
||||
with assert_raises(ClientError) as exc:
|
||||
s3.put_bucket_accelerate_configuration(
|
||||
Bucket=bucket_name,
|
||||
AccelerateConfiguration={'Status': 'bad_status'},
|
||||
)
|
||||
exc.exception.response['Error']['Code'].should.equal('MalformedXML')
|
||||
|
||||
@mock_s3
|
||||
def test_accelerate_configuration_is_not_supported_when_bucket_name_has_dots():
|
||||
bucket_name = 'some.bucket.with.dots'
|
||||
s3 = boto3.client('s3')
|
||||
s3.create_bucket(Bucket=bucket_name)
|
||||
with assert_raises(ClientError) as exc:
|
||||
s3.put_bucket_accelerate_configuration(
|
||||
Bucket=bucket_name,
|
||||
AccelerateConfiguration={'Status': 'Enabled'},
|
||||
)
|
||||
exc.exception.response['Error']['Code'].should.equal('InvalidRequest')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue