Skip to content

Commit 86b0ad7

Browse files
GitHKAndrei Neagu
andauthored
fixed issue with url parsing (ITISFoundation#3023)
Co-authored-by: Andrei Neagu <[email protected]>
1 parent 46d91c6 commit 86b0ad7

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

services/storage/src/simcore_service_storage/s3.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from typing import Dict
66

77
from aiohttp import web
8-
from tenacity import before_sleep_log, retry, stop_after_attempt, wait_fixed
98
from pydantic import AnyUrl, parse_obj_as
9+
from tenacity import before_sleep_log, retry, stop_after_attempt, wait_fixed
1010

1111
from .constants import APP_CONFIG_KEY, APP_S3_KEY
1212
from .s3wrapper.s3_client import MinioClientWrapper
@@ -58,9 +58,10 @@ async def do_create_bucket():
5858
def _minio_client_endpint(s3_endpoint: str) -> str:
5959
# Minio client adds http and https based on the secure paramenter
6060
# provided at construction time, already including the schema
61-
# will cause issues, encoding url to HOST:PORT
61+
# will cause issues, encoding url to HOST:PORT or just HOST
62+
# if port is missing
6263
url = parse_obj_as(AnyUrl, s3_endpoint)
63-
return f"{url.host}:{url.port}"
64+
return f"{url.host}" if url.port is None else f"{url.host}:{url.port}"
6465

6566

6667
def setup_s3(app: web.Application):

services/storage/tests/unit/test_route_s3_access.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# pylint: disable=redefined-outer-name
2-
# pylint: disable=redefined-outer-name
32
# pylint: disable=unused-argument
43
# pylint: disable=unused-variable
54

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# pylint: disable=protected-access
2+
3+
import pytest
4+
from simcore_service_storage import s3
5+
6+
7+
@pytest.mark.parametrize(
8+
"url, expected",
9+
[
10+
("https://ceph.com", "ceph.com"),
11+
("http://ciao.com", "ciao.com"),
12+
("http://local.address:8012", "local.address:8012"),
13+
("https://remote.stragen.com:4432", "remote.stragen.com:4432"),
14+
],
15+
)
16+
def test_minio_client_endpint(url: str, expected: str) -> None:
17+
assert s3._minio_client_endpint(url) == expected

0 commit comments

Comments
 (0)