Skip to content

Commit

Permalink
test: add new test_stage_users
Browse files Browse the repository at this point in the history
Play with the idea of a integration test that checks that the
user is created and enabled.
  • Loading branch information
mvo5 committed Nov 3, 2023
1 parent 73dc9fe commit 4fcc1d9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/run/test_stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4fcc1d9

Please sign in to comment.