@@ -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