mirror of
https://github.com/TheLocehiliosan/yadm
synced 2024-10-27 20:34:27 +00:00
6378fe3073
This makes it possible to run e.g. "yadm -Y foo introspect repo 2>/dev/null" and get an empty output instead of getting the error message about foo not being fully qualified.
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
"""Test external encryption commands"""
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
'crypt',
|
|
[False, 'installed', 'installed-but-failed'],
|
|
ids=['not-installed', 'installed', 'installed-but-failed']
|
|
)
|
|
@pytest.mark.parametrize(
|
|
'cmd,var', [
|
|
['git_crypt', 'GIT_CRYPT_PROGRAM'],
|
|
['transcrypt', 'TRANSCRYPT_PROGRAM'],
|
|
],
|
|
ids=['git-crypt', 'transcrypt'])
|
|
def test_ext_encryption(runner, yadm, paths, tmpdir, crypt, cmd, var):
|
|
"""External encryption tests"""
|
|
|
|
paths.repo.ensure(dir=True)
|
|
bindir = tmpdir.mkdir('bin')
|
|
pgm = bindir.join('test-ext-crypt')
|
|
|
|
if crypt:
|
|
pgm.write('#!/bin/sh\necho ext-crypt ran\n')
|
|
pgm.chmod(0o775)
|
|
if crypt == 'installed-but-failed':
|
|
pgm.write('false\n', mode='a')
|
|
|
|
script = f"""
|
|
YADM_TEST=1 source {yadm}
|
|
YADM_REPO={paths.repo}
|
|
{var}="{pgm}"
|
|
{cmd} "param1"
|
|
"""
|
|
|
|
run = runner(command=['bash'], inp=script)
|
|
|
|
if crypt:
|
|
if crypt == 'installed-but-failed':
|
|
assert run.failure
|
|
else:
|
|
assert run.success
|
|
assert run.out.strip() == 'ext-crypt ran'
|
|
assert run.err == ''
|
|
else:
|
|
assert run.failure
|
|
assert f"command '{pgm}' cannot be located" in run.err
|