Skip to content

Commit

Permalink
add test to check dump lock redirect
Browse files Browse the repository at this point in the history
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 <felix.moessbauer@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
  • Loading branch information
fmoessbauer authored and jan-kiszka committed Oct 31, 2024
1 parent 2d7eff5 commit f4ceea7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f4ceea7

Please # to comment.