Skip to content

Commit 0f1e4ad

Browse files
committed
fixes test
1 parent 1cbcbdd commit 0f1e4ad

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

services/web/server/src/simcore_service_webserver/statics/_handlers.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414

1515

1616
async def get_cached_frontend_index(request: web.Request):
17-
# NOTE: always deliver a front-end
1817
product_name = get_product_name(request)
1918

2019
assert ( # nosec
2120
product_name in FRONTEND_APPS_AVAILABLE
2221
), "Every product is mapped with a front-end app with IDENTICAL name"
2322

24-
# NOTE: CANNOT redirect , i.e.
25-
# raise web.HTTPFound(f"/{target_frontend}/index.html")
23+
# NOTE: CANNOT redirect , i.e. `web.HTTPFound(f"/{target_frontend}/index.html")`
2624
# because it losses fragments and therefore it fails in study links.
2725
#
2826
# SEE services/web/server/tests/unit/isolated/test_redirections.py

services/web/server/tests/unit/isolated/test_products_middlewares.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,22 @@ def mock_postgres_product_table():
2929

3030
column_defaults["login_settings"] = LOGIN_SETTINGS_DEFAULT
3131

32+
_SUBDOMAIN_PREFIX = r"[\w-]+\."
33+
3234
return [
33-
dict(name="osparc", host_regex=r"([\.-]{0,1}osparc[\.-])", **column_defaults),
35+
dict(
36+
name="osparc",
37+
host_regex=rf"^({_SUBDOMAIN_PREFIX})*osparc[\.-]",
38+
**column_defaults,
39+
),
3440
dict(
3541
name="s4l",
36-
host_regex=r"(^s4l[\.-])|(^sim4life\.)|(^api.s4l[\.-])|(^api.sim4life\.)",
42+
host_regex=rf"^({_SUBDOMAIN_PREFIX})*(s4l|sim4life)[\.-]",
3743
**column_defaults,
3844
),
3945
dict(
4046
name="tis",
41-
host_regex=r"(^tis[\.-])|(^ti-solutions\.)",
47+
host_regex=rf"^({_SUBDOMAIN_PREFIX})*(tis|^ti-solutions)[\.-]",
4248
vendor={
4349
"name": "ACME",
4450
"address": "sesame street",
@@ -68,7 +74,6 @@ def mock_app(mock_postgres_product_table: dict[str, Any]) -> web.Application:
6874
"request_url,x_product_name_header,expected_product",
6975
[
7076
("https://tis-master.domain.io/", "tis", "tis"),
71-
("https://s4l-staging.domain.com/v0/", "s4l", "s4l"),
7277
("https://osparc-master.domain.com/v0/projects", None, "osparc"),
7378
("https://s4l.domain.com/", "s4l", "s4l"),
7479
("https://some-valid-but-undefined-product.io/", None, FRONTEND_APP_DEFAULT),
@@ -77,10 +82,11 @@ def mock_app(mock_postgres_product_table: dict[str, Any]) -> web.Application:
7782
("https://ti-solutions.io/", "tis", "tis"),
7883
("https://osparc.io/", None, "osparc"), # e.g. an old front-end
7984
("https://staging.osparc.io/", "osparc", "osparc"),
85+
("https://s4l-staging.domain.com/v0/", "s4l", "s4l"),
8086
# new auth of subdomains. SEE https://github.com/ITISFoundation/osparc-simcore/pull/6484
8187
(
82-
"https://34c878cd-f801-433f-9ddb-7dccba9251af.services.s4l-solutions.com/notebooks/lab",
83-
"s4l",
88+
"https://34c878cd-f801-433f-9ddb-7dccba9251af.services.s4l-staging.domain.com",
89+
None,
8490
"s4l",
8591
),
8692
],
@@ -99,6 +105,7 @@ async def test_middleware_product_discovery(
99105
url = URL(request_url)
100106
headers = {
101107
"Host": url.host,
108+
"X-Forwarded-Host": url.host,
102109
}
103110
if x_product_name_header:
104111
headers.update({X_PRODUCT_NAME_HEADER: x_product_name_header})

0 commit comments

Comments
 (0)