Files
DECNET/tests/cli/test_web_proxy_target.py
anti f2b3393669 chore: relicense to AGPL-3.0-or-later and add SPDX headers
Replaces LICENSE (GPLv3 -> AGPLv3) and prepends
`SPDX-License-Identifier: AGPL-3.0-or-later` to every source file
across decnet/, decnet_web/, tests/, scripts/, and tools/.

Rationale: closes the GPLv3 ASP loophole so any party operating a
modified DECNET as a network service must offer their modified
source. Personal copyright (Samuel Paschuan) + inbound=outbound
contributions make a future unilateral relicense infeasible.

- LICENSE: full AGPL-3.0 text (gnu.org/licenses/agpl-3.0.txt)
- COPYRIGHT: project copyright notice
- tools/add_spdx_headers.py: idempotent header injector
  (shebang- and PEP 263-aware)

Touches 1565 source files (.py, .ts, .tsx, .js, .jsx, .css, .sh).
No behavior change; comments only.
2026-05-22 21:04:16 -04:00

38 lines
1.2 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""The web dashboard proxy must follow DECNET_API_HOST.
Hardcoding 127.0.0.1 broke deploys where the operator binds the API to
a specific tailnet/VPN address: the API drops loopback entirely and the
proxy gets ECONNREFUSED. Wildcard binds still proxy via loopback because
both processes share the host.
"""
from __future__ import annotations
from decnet.cli.web import _proxy_target
def test_loopback_passthrough() -> None:
assert _proxy_target("127.0.0.1") == "127.0.0.1"
def test_wildcard_v4_falls_back_to_loopback() -> None:
assert _proxy_target("0.0.0.0") == "127.0.0.1"
def test_wildcard_v6_falls_back_to_loopback() -> None:
assert _proxy_target("::") == "127.0.0.1"
def test_empty_falls_back_to_loopback() -> None:
assert _proxy_target("") == "127.0.0.1"
def test_specific_address_is_followed() -> None:
# The case that was broken: API bound only on tailnet IP, proxy
# tried loopback and got ECONNREFUSED.
assert _proxy_target("100.64.1.7") == "100.64.1.7"
def test_hostname_is_followed() -> None:
assert _proxy_target("decnet-master.tailnet.ts.net") == "decnet-master.tailnet.ts.net"