Merge pull request #1460 from okomestudio/s3-region-from-url
Support both virtual-hosted and path-style URLs for region name parsing
This commit is contained in:
commit
326698f3fa
3 changed files with 41 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
from sure import expect
|
||||
from moto.s3.utils import bucket_name_from_url, _VersionedKeyStore
|
||||
from moto.s3.utils import bucket_name_from_url, _VersionedKeyStore, parse_region_from_url
|
||||
|
||||
|
||||
def test_base_url():
|
||||
|
|
@ -53,3 +53,21 @@ def test_versioned_key_store():
|
|||
d.setlist('key', [[1], [2]])
|
||||
d['key'].should.have.length_of(1)
|
||||
d.getlist('key').should.be.equal([[1], [2]])
|
||||
|
||||
|
||||
def test_parse_region_from_url():
|
||||
expected = 'us-west-2'
|
||||
for url in ['http://s3-us-west-2.amazonaws.com/bucket',
|
||||
'http://s3.us-west-2.amazonaws.com/bucket',
|
||||
'http://bucket.s3-us-west-2.amazonaws.com',
|
||||
'https://s3-us-west-2.amazonaws.com/bucket',
|
||||
'https://s3.us-west-2.amazonaws.com/bucket',
|
||||
'https://bucket.s3-us-west-2.amazonaws.com']:
|
||||
parse_region_from_url(url).should.equal(expected)
|
||||
|
||||
expected = 'us-east-1'
|
||||
for url in ['http://s3.amazonaws.com/bucket',
|
||||
'http://bucket.s3.amazonaws.com',
|
||||
'https://s3.amazonaws.com/bucket',
|
||||
'https://bucket.s3.amazonaws.com']:
|
||||
parse_region_from_url(url).should.equal(expected)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue