S3 Ignore Subdomain for Bucketname Flag (#1419)

* Some circumstances need subdomains to be ignored rather that interpreted as bucketname, this patch allows such behaviour to be configured

* Adding helper case whereby localstack features as path based exception

* Remove whitespace :(
This commit is contained in:
Colin Jones 2018-03-21 16:33:09 +00:00 committed by Jack Danger
commit 1a8a4a084d
3 changed files with 14 additions and 3 deletions

View file

@ -1,4 +1,5 @@
from __future__ import unicode_literals
import os
from sure import expect
from moto.s3.utils import bucket_name_from_url, _VersionedKeyStore, parse_region_from_url
@ -16,6 +17,12 @@ def test_localhost_without_bucket():
expect(bucket_name_from_url(
'https://www.localhost:5000/def')).should.equal(None)
def test_force_ignore_subdomain_for_bucketnames():
os.environ['S3_IGNORE_SUBDOMAIN_BUCKETNAME'] = '1'
expect(bucket_name_from_url('https://subdomain.localhost:5000/abc/resource')).should.equal(None)
del(os.environ['S3_IGNORE_SUBDOMAIN_BUCKETNAME'])
def test_versioned_key_store():
d = _VersionedKeyStore()