Skip to content

Commit

Permalink
fixes test
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Oct 11, 2024
1 parent 1cbcbdd commit 0f1e4ad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@


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

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

# NOTE: CANNOT redirect , i.e.
# raise web.HTTPFound(f"/{target_frontend}/index.html")
# NOTE: CANNOT redirect , i.e. `web.HTTPFound(f"/{target_frontend}/index.html")`
# because it losses fragments and therefore it fails in study links.
#
# SEE services/web/server/tests/unit/isolated/test_redirections.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@ def mock_postgres_product_table():

column_defaults["login_settings"] = LOGIN_SETTINGS_DEFAULT

_SUBDOMAIN_PREFIX = r"[\w-]+\."

return [
dict(name="osparc", host_regex=r"([\.-]{0,1}osparc[\.-])", **column_defaults),
dict(
name="osparc",
host_regex=rf"^({_SUBDOMAIN_PREFIX})*osparc[\.-]",
**column_defaults,
),
dict(
name="s4l",
host_regex=r"(^s4l[\.-])|(^sim4life\.)|(^api.s4l[\.-])|(^api.sim4life\.)",
host_regex=rf"^({_SUBDOMAIN_PREFIX})*(s4l|sim4life)[\.-]",
**column_defaults,
),
dict(
name="tis",
host_regex=r"(^tis[\.-])|(^ti-solutions\.)",
host_regex=rf"^({_SUBDOMAIN_PREFIX})*(tis|^ti-solutions)[\.-]",
vendor={
"name": "ACME",
"address": "sesame street",
Expand Down Expand Up @@ -68,7 +74,6 @@ def mock_app(mock_postgres_product_table: dict[str, Any]) -> web.Application:
"request_url,x_product_name_header,expected_product",
[
("https://tis-master.domain.io/", "tis", "tis"),
("https://s4l-staging.domain.com/v0/", "s4l", "s4l"),
("https://osparc-master.domain.com/v0/projects", None, "osparc"),
("https://s4l.domain.com/", "s4l", "s4l"),
("https://some-valid-but-undefined-product.io/", None, FRONTEND_APP_DEFAULT),
Expand All @@ -77,10 +82,11 @@ def mock_app(mock_postgres_product_table: dict[str, Any]) -> web.Application:
("https://ti-solutions.io/", "tis", "tis"),
("https://osparc.io/", None, "osparc"), # e.g. an old front-end
("https://staging.osparc.io/", "osparc", "osparc"),
("https://s4l-staging.domain.com/v0/", "s4l", "s4l"),
# new auth of subdomains. SEE https://github.com/ITISFoundation/osparc-simcore/pull/6484
(
"https://34c878cd-f801-433f-9ddb-7dccba9251af.services.s4l-solutions.com/notebooks/lab",
"s4l",
"https://34c878cd-f801-433f-9ddb-7dccba9251af.services.s4l-staging.domain.com",
None,
"s4l",
),
],
Expand All @@ -99,6 +105,7 @@ async def test_middleware_product_discovery(
url = URL(request_url)
headers = {
"Host": url.host,
"X-Forwarded-Host": url.host,
}
if x_product_name_header:
headers.update({X_PRODUCT_NAME_HEADER: x_product_name_header})
Expand Down

0 comments on commit 0f1e4ad

Please sign in to comment.