Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The s3gw-ui container does not start #292

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ def get_ui_path() -> str:
"""

def post_process(key: str, value: str | None) -> str:
if value is None:
if value is None or value == "/":
return "/"
match = re.fullmatch(r"/?[\w.-/]+(?:[\w]+)/?", value)
match = re.fullmatch(r"/?[\w./-]+(?:[\w]+)/?", value)
if match is None:
logger.error(
f"The value of the environment variable {key} is malformed: {value}" # noqa: E501
Expand Down
28 changes: 20 additions & 8 deletions src/backend/tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from backend.api import s3gw_config
from backend.config import (
Config,
EnvironMalformedError,
S3AddressingStyle,
get_environ_enum,
get_environ_str,
Expand Down Expand Up @@ -109,14 +110,25 @@ def test_malformed_ui_path() -> None:
)


def test_good_ui_path() -> None:
path = "/s3store"
os.environ["S3GW_UI_PATH"] = path
try:
cfg = Config()
assert cfg.ui_path == path
except Exception as e:
pytest.fail(str(e))
def test_malformed_ui_path_2() -> None:
os.environ["S3GW_UI_PATH"] = "/foo-bar/baz?aaa"
with pytest.raises(EnvironMalformedError):
get_ui_path()


def test_good_ui_path_1() -> None:
os.environ["S3GW_UI_PATH"] = "/s3store"
assert "/s3store" == get_ui_path()


def test_good_ui_path_2() -> None:
os.environ["S3GW_UI_PATH"] = "/"
assert "/" == get_ui_path()


def test_good_ui_path_3() -> None:
os.environ["S3GW_UI_PATH"] = "/foo-bar/baz/"
assert "/foo-bar/baz/" == get_ui_path()


def test_no_ui_path() -> None:
Expand Down