Files
kernalix7--winpodx/tests/test_compose_network.py
wehub-resource-sync 3e779be6f3
CI / lint (push) Failing after 13m4s
CI / test (3.11, ubuntu-latest) (push) Failing after 2m4s
CI / test (3.13, ubuntu-latest) (push) Successful in 13m30s
CI / test (3.14, ubuntu-latest) (push) Successful in 17m21s
CI / test (3.12, ubuntu-latest) (push) Successful in 17m55s
CI / discover-apps-ps (push) Successful in 1m56s
CI / test (3.9, ubuntu-latest) (push) Successful in 13m17s
CI / test (3.10, ubuntu-latest) (push) Successful in 26m21s
CI / audit (push) Successful in 13m38s
Deploy site / deploy (push) Has been cancelled
CI / test (3.14, ubuntu-24.04-arm) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:32:37 +08:00

47 lines
1.7 KiB
Python

# SPDX-License-Identifier: MIT
"""dockur networking-mode env tests.
winpodx reaches the Windows guest only over forwarded ports (RDP 3389,
the web viewer 8006, and the agent 8765) -- it never needs the guest on
the host LAN. So the compose always pins ``NETWORK: "user"`` (dockur's
user-mode / passt networking), which forwards every entry in ``USER_PORTS``.
This closes #269 / #387: on hosts where dockur's default bridge-NAT path
succeeds (typically rootful), that path silently ignores ``USER_PORTS``,
so the agent port 8765 is never forwarded to the guest and ``pod
wait-ready`` hangs forever. Pinning user-mode routes around the bridge
path so ``USER_PORTS`` is always honoured. (On rootless hosts dockur
already falls back to passt, so this is a no-op there.)
"""
from __future__ import annotations
from winpodx.core.config import Config
from winpodx.core.pod.compose import _build_compose_content
def _cfg() -> Config:
cfg = Config()
cfg.pod.backend = "podman"
cfg.rdp.user = "User"
cfg.rdp.password = "TestPassword1!"
cfg.rdp.port = 3390
cfg.pod.vnc_port = 8007
cfg.pod.container_name = "winpodx-windows"
cfg.pod.tuning_profile = "off"
return cfg
def test_compose_pins_user_mode_networking():
content = _build_compose_content(_cfg())
# user-mode networking is what makes USER_PORTS (the agent port) forward.
assert 'NETWORK: "user"' in content
def test_compose_user_ports_present_alongside_network():
content = _build_compose_content(_cfg())
# NETWORK + USER_PORTS must coexist: USER_PORTS is only honoured under
# user-mode, so both lines together are what forwards the agent port.
assert 'NETWORK: "user"' in content
assert "USER_PORTS:" in content