From 4fcc1d975ad20dbf681bda698509883caf754b55 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 3 Nov 2023 21:54:57 +0100 Subject: [PATCH] test: add new test_stage_users Play with the idea of a integration test that checks that the user is created and enabled. --- test/run/test_stages.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/run/test_stages.py b/test/run/test_stages.py index 93152d4b2..01f534aa8 100644 --- a/test/run/test_stages.py +++ b/test/run/test_stages.py @@ -641,3 +641,21 @@ def _get_file_fields(image: str) -> List[str]: fields = _get_file_fields(image) assert "heads 12" in fields assert "sectors/track 42" in fields + + def test_stage_users(self): + datadir = self.locate_test_data() + testdir = os.path.join(datadir, "stages", "users") + + with self.osbuild as osb, tempfile.TemporaryDirectory(dir="/var/tmp") as outdir: + osb.compile_file(os.path.join(testdir, "b.json"), exports=["tree"], output_dir=outdir) + + tree = os.path.join(outdir, "tree") + assert os.path.isdir(tree) + + # check that the user is correctly created + output = subprocess.check_output([ + "chroot", tree, "/usr/bin/id", "-u", "nohome"], text=True) + self.assertEqual(output, "1337\n") + + # TODO: run ssh inside the container and check if + # ssh login actually really works