Serve one web app: route the tailnet address to the installed proxy

./install retires the pre-native standalone web agent (net.awan.pipelines.web,
kept as .disabled) and, when the public web URL is a tailnet HTTPS address,
points tailscale serve at the installed web proxy, failing the install if it
cannot.
This commit is contained in:
2026-10-31 20:26:16 +00:00
parent cc3d450696
commit 62b56e66d0
2 changed files with 73 additions and 0 deletions
+35
View File
@@ -733,6 +733,41 @@ class SetupNativeTests(unittest.TestCase):
self.assertFalse(any("start" in call for call in recorder.calls))
self.assertNotIn("Native Pipelines installed", output.getvalue())
def test_legacy_standalone_web_agent_is_retired(self):
with tempfile.TemporaryDirectory() as directory:
recorder = Recorder()
installer = self.installer(directory, recorder)
agents = Path(self.home.name) / "Library/LaunchAgents"
agents.mkdir(parents=True)
legacy = agents / "net.awan.pipelines.web.plist"
legacy.write_text("legacy")
with patch.object(setup_native.platform, "system", return_value="Darwin"), \
redirect_stdout(io.StringIO()):
installer.retire_legacy_web()
installer.retire_legacy_web()
self.assertFalse(legacy.exists())
self.assertEqual((agents / "net.awan.pipelines.web.plist.disabled").read_text(), "legacy")
self.assertEqual(sum(call[:2] == ["launchctl", "bootout"] for call in recorder.calls), 1)
def test_tailnet_public_url_serves_the_installed_web_app(self):
with tempfile.TemporaryDirectory() as directory:
recorder = Recorder()
installer = self.installer(directory, recorder)
with patch.object(setup_native.shutil, "which", return_value="/usr/bin/tailscale"), \
redirect_stdout(io.StringIO()):
installer.serve_on_tailnet("https://box.tail1.ts.net:8443", 8083)
installer.serve_on_tailnet("http://10.0.0.5:8083", 8083)
self.assertEqual([call for call in recorder.calls if "serve" in call],
[["/usr/bin/tailscale", "serve", "--bg", "--https=8443", "http://127.0.0.1:8083"]])
def refusing(command, **kwargs):
return subprocess.CompletedProcess(command, 1, stdout="", stderr="serve: access denied")
installer = self.installer(directory, refusing)
with patch.object(setup_native.shutil, "which", return_value="/usr/bin/tailscale"):
with self.assertRaisesRegex(ValueError, "access denied"):
installer.serve_on_tailnet("https://box.tail1.ts.net", 8083)
def test_install_is_all_or_nothing_with_the_web_app(self):
cases = {"no docker": dict(docker=False), "web build fails": dict(fail_web=True),
"server build fails": dict(fail_build=True)}