Check S3_IGNORE_SUBDOMAIN_BUCKETNAME environment variable (#3796)
* Check S3_IGNORE_SUBDOMAIN_BUCKETNAME environment variable * move S3_IGNORE_SUBDOMAIN_BUCKETNAME environment variable to settings
This commit is contained in:
parent
1761be46e3
commit
9f9716ee01
6 changed files with 30 additions and 9 deletions
|
|
@ -1,5 +1,4 @@
|
|||
from __future__ import unicode_literals
|
||||
import os
|
||||
import pytest
|
||||
from sure import expect
|
||||
from moto.s3.utils import (
|
||||
|
|
@ -9,6 +8,7 @@ from moto.s3.utils import (
|
|||
clean_key_name,
|
||||
undo_clean_key_name,
|
||||
)
|
||||
from tests.compat import patch
|
||||
|
||||
|
||||
def test_base_url():
|
||||
|
|
@ -25,12 +25,11 @@ 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_force_ignore_subdomain_for_bucketnames(monkeypatch):
|
||||
with patch("moto.s3.utils.S3_IGNORE_SUBDOMAIN_BUCKETNAME", True):
|
||||
expect(
|
||||
bucket_name_from_url("https://subdomain.localhost:5000/abc/resource")
|
||||
).should.equal(None)
|
||||
|
||||
|
||||
def test_versioned_key_store():
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import sure # noqa
|
|||
|
||||
from flask.testing import FlaskClient
|
||||
import moto.server as server
|
||||
from tests.compat import patch
|
||||
|
||||
"""
|
||||
Test the different server responses
|
||||
|
|
@ -56,6 +57,15 @@ def test_s3_server_bucket_create():
|
|||
res.data.should.equal(b"test value")
|
||||
|
||||
|
||||
def test_s3_server_ignore_subdomain_for_bucketnames():
|
||||
with patch("moto.s3.responses.S3_IGNORE_SUBDOMAIN_BUCKETNAME", True):
|
||||
test_client = authenticated_client()
|
||||
|
||||
res = test_client.put("/mybucket", "http://foobaz.localhost:5000/")
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.contain(b"mybucket")
|
||||
|
||||
|
||||
def test_s3_server_bucket_versioning():
|
||||
test_client = authenticated_client()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue