()
| 1527 | |
| 1528 | |
| 1529 | def test_server_name_subdomain(): |
| 1530 | app = flask.Flask(__name__, subdomain_matching=True) |
| 1531 | client = app.test_client() |
| 1532 | |
| 1533 | @app.route("/") |
| 1534 | def index(): |
| 1535 | return "default" |
| 1536 | |
| 1537 | @app.route("/", subdomain="foo") |
| 1538 | def subdomain(): |
| 1539 | return "subdomain" |
| 1540 | |
| 1541 | app.config["SERVER_NAME"] = "dev.local:5000" |
| 1542 | rv = client.get("/") |
| 1543 | assert rv.data == b"default" |
| 1544 | |
| 1545 | rv = client.get("/", "http://dev.local:5000") |
| 1546 | assert rv.data == b"default" |
| 1547 | |
| 1548 | rv = client.get("/", "https://dev.local:5000") |
| 1549 | assert rv.data == b"default" |
| 1550 | |
| 1551 | app.config["SERVER_NAME"] = "dev.local:443" |
| 1552 | rv = client.get("/", "https://dev.local") |
| 1553 | |
| 1554 | # Werkzeug 1.0 fixes matching https scheme with 443 port |
| 1555 | if rv.status_code != 404: |
| 1556 | assert rv.data == b"default" |
| 1557 | |
| 1558 | app.config["SERVER_NAME"] = "dev.local" |
| 1559 | rv = client.get("/", "https://dev.local") |
| 1560 | assert rv.data == b"default" |
| 1561 | |
| 1562 | # suppress Werkzeug 0.15 warning about name mismatch |
| 1563 | with warnings.catch_warnings(): |
| 1564 | warnings.filterwarnings( |
| 1565 | "ignore", "Current server name", UserWarning, "flask.app" |
| 1566 | ) |
| 1567 | rv = client.get("/", "http://foo.localhost") |
| 1568 | assert rv.status_code == 404 |
| 1569 | |
| 1570 | rv = client.get("/", "http://foo.dev.local") |
| 1571 | assert rv.data == b"subdomain" |
| 1572 | |
| 1573 | |
| 1574 | @pytest.mark.parametrize("key", ["TESTING", "PROPAGATE_EXCEPTIONS", "DEBUG", None]) |
nothing calls this directly
no test coverage detected