@@ -951,7 +951,10 @@ def index():
951
951
952
952
953
953
def test_nesting_subdomains (app , client ) -> None :
954
- subdomain = "api"
954
+ app .subdomain_matching = True
955
+ app .config ["SERVER_NAME" ] = "example.test"
956
+ client .allow_subdomain_redirects = True
957
+
955
958
parent = flask .Blueprint ("parent" , __name__ )
956
959
child = flask .Blueprint ("child" , __name__ )
957
960
@@ -960,42 +963,31 @@ def index():
960
963
return "child"
961
964
962
965
parent .register_blueprint (child )
963
- app .register_blueprint (parent , subdomain = subdomain )
964
-
965
- client .allow_subdomain_redirects = True
966
-
967
- domain_name = "domain.tld"
968
- app .config ["SERVER_NAME" ] = domain_name
969
- response = client .get ("/child/" , base_url = "http://api." + domain_name )
966
+ app .register_blueprint (parent , subdomain = "api" )
970
967
968
+ response = client .get ("/child/" , base_url = "http://api.example.test" )
971
969
assert response .status_code == 200
972
970
973
971
974
972
def test_child_and_parent_subdomain (app , client ) -> None :
975
- child_subdomain = "api"
976
- parent_subdomain = "parent"
973
+ app .subdomain_matching = True
974
+ app .config ["SERVER_NAME" ] = "example.test"
975
+ client .allow_subdomain_redirects = True
976
+
977
977
parent = flask .Blueprint ("parent" , __name__ )
978
- child = flask .Blueprint ("child" , __name__ , subdomain = child_subdomain )
978
+ child = flask .Blueprint ("child" , __name__ , subdomain = "api" )
979
979
980
980
@child .route ("/" )
981
981
def index ():
982
982
return "child"
983
983
984
984
parent .register_blueprint (child )
985
- app .register_blueprint (parent , subdomain = parent_subdomain )
986
-
987
- client .allow_subdomain_redirects = True
988
-
989
- domain_name = "domain.tld"
990
- app .config ["SERVER_NAME" ] = domain_name
991
- response = client .get (
992
- "/" , base_url = f"http://{ child_subdomain } .{ parent_subdomain } .{ domain_name } "
993
- )
985
+ app .register_blueprint (parent , subdomain = "parent" )
994
986
987
+ response = client .get ("/" , base_url = "http://api.parent.example.test" )
995
988
assert response .status_code == 200
996
989
997
- response = client .get ("/" , base_url = f"http://{ parent_subdomain } .{ domain_name } " )
998
-
990
+ response = client .get ("/" , base_url = "http://parent.example.test" )
999
991
assert response .status_code == 404
1000
992
1001
993
0 commit comments