feat(install): build the Flutter web app in Docker, optional ./install --apk, chosen web password, startup report
This commit is contained in:
@@ -116,7 +116,8 @@ class SetupNativeTests(unittest.TestCase):
|
||||
# user configuration during tests.
|
||||
return setup_native.Setup(directory, prefix=Path(directory) / "prefix", runner=recorder,
|
||||
resolver=resolution,
|
||||
environ={"XDG_CONFIG_HOME": str(Path(directory) / "config")})
|
||||
environ={"XDG_CONFIG_HOME": str(Path(directory) / "config"),
|
||||
"PIPELINES_WEB_PASSWORD": "chosen-password"})
|
||||
|
||||
@staticmethod
|
||||
def which_all(opencode="/usr/bin/opencode", pi=None, cc="/usr/bin/cc"):
|
||||
@@ -202,11 +203,39 @@ class SetupNativeTests(unittest.TestCase):
|
||||
installer.configure_web(prefix, setup_native.arguments([]))
|
||||
self.assertEqual(auth.read_bytes(), before)
|
||||
self.assertEqual(auth.stat().st_mode & 0o777, 0o600)
|
||||
self.assertGreaterEqual(len(json.loads(before)["password"]), 8)
|
||||
self.assertEqual(json.loads(before)["password"], "chosen-password")
|
||||
self.assertTrue(Path(web["script"]).is_file())
|
||||
# The web app is built in Docker once and installed for the proxy.
|
||||
self.assertTrue(installer.runner.has("docker", "run", "pipelines-app-build", "web"))
|
||||
self.assertEqual(web["root"], str(prefix / "lib/app-web"))
|
||||
self.assertTrue(Path(web["root"]).is_dir())
|
||||
self.assertTrue(Path(web["updates"]).is_dir())
|
||||
self.assertTrue((prefix / "lib/web/src/proxySecurity.js").is_file())
|
||||
self.assertEqual(web["port"], 8082)
|
||||
|
||||
def test_new_web_password_must_be_chosen(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
installer = self.installer(directory, Recorder())
|
||||
prefix = Path(directory) / "prefix"
|
||||
installer.prepare_layout(prefix)
|
||||
installer.environ.pop("PIPELINES_WEB_PASSWORD")
|
||||
with patch.object(setup_native.shutil, "which", side_effect=self.which_all()), \
|
||||
patch.object(setup_native.sys.stdin, "isatty", return_value=False):
|
||||
with self.assertRaisesRegex(ValueError, "PIPELINES_WEB_PASSWORD"):
|
||||
installer.configure_web(prefix, setup_native.arguments([]))
|
||||
installer.environ["PIPELINES_WEB_PASSWORD"] = "short"
|
||||
with patch.object(setup_native.shutil, "which", side_effect=self.which_all()):
|
||||
with self.assertRaisesRegex(ValueError, "at least 8"):
|
||||
installer.configure_web(prefix, setup_native.arguments([]))
|
||||
installer.environ.pop("PIPELINES_WEB_PASSWORD")
|
||||
with patch.object(setup_native.shutil, "which", side_effect=self.which_all()), \
|
||||
patch.object(setup_native.sys.stdin, "isatty", return_value=True), \
|
||||
patch.object(setup_native.getpass, "getpass",
|
||||
side_effect=["short", "typed-password", "other-password",
|
||||
"typed-password", "typed-password"]):
|
||||
web = installer.configure_web(prefix, setup_native.arguments([]))
|
||||
self.assertEqual(json.loads(Path(web["auth_file"]).read_text())["password"], "typed-password")
|
||||
|
||||
def test_invalid_web_auth_is_retained(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
installer = self.installer(directory, Recorder())
|
||||
|
||||
Reference in New Issue
Block a user