From f4ceea72d0a9d571e0a8ae2879ae0616758161df Mon Sep 17 00:00:00 2001 From: Felix Moessbauer Date: Thu, 31 Oct 2024 10:24:17 +0100 Subject: [PATCH] add test to check dump lock redirect For backwards compatibility, "kas dump --lock --inplace" redirects to "kas dump". This redirect was already implicitly tested. Now we also explicitly test if this generated the same lockfile. Signed-off-by: Felix Moessbauer Signed-off-by: Jan Kiszka --- tests/test_commands.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_commands.py b/tests/test_commands.py index a573de11..b851964d 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -31,6 +31,7 @@ from kas import kas from kas.libkas import run_cmd from kas.libkas import TaskExecError, KasUserError +from kas.attestation import file_digest_slow @pytest.mark.online @@ -245,6 +246,15 @@ def test_lockfile(monkeykas, tmpdir, capsys): kas.kas('dump --lock --inplace test.yml'.split()) assert os.path.exists('test.lock.yml') + # check if legacy dump -> lock redirection works + with open('test.lock.yml', "rb") as f: + hash_dump = file_digest_slow(f, 'sha256') + os.remove('test.lock.yml') + kas.kas('lock test.yml'.split()) + with open('test.lock.yml', "rb") as f: + hash_lock = file_digest_slow(f, 'sha256') + assert hash_dump.hexdigest() == hash_lock.hexdigest() + # lockfile is considered during import, expect pinned branches kas.kas('dump test.yml'.split()) lockspec = yaml.safe_load(capsys.readouterr().out)