MCPcopy
hub / github.com/pallets/werkzeug / test_http_host_before_server_name

Function test_http_host_before_server_name

tests/test_routing.py:486–504  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

484
485
486def test_http_host_before_server_name():
487 env = {
488 "HTTP_HOST": "wiki.example.com",
489 "SERVER_NAME": "web0.example.com",
490 "SERVER_PORT": "80",
491 "SCRIPT_NAME": "",
492 "PATH_INFO": "",
493 "REQUEST_METHOD": "GET",
494 "wsgi.url_scheme": "http",
495 }
496 map = r.Map([r.Rule("/", endpoint="index", subdomain="wiki")])
497 adapter = map.bind_to_environ(env, server_name="example.com")
498 assert adapter.match("/") == ("index", {})
499 assert adapter.build("index", force_external=True) == "http://wiki.example.com/"
500 assert adapter.build("index") == "/"
501
502 env["HTTP_HOST"] = "admin.example.com"
503 adapter = map.bind_to_environ(env, server_name="example.com")
504 assert adapter.build("index") == "http://wiki.example.com/"
505
506
507def test_invalid_subdomain_warning():

Callers

nothing calls this directly

Calls 3

bind_to_environMethod · 0.95
matchMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected