1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2026-03-02 03:49:29 +00:00

Support transcrypt (#197)

Support is inherently provided by `enter`, which supports a command.
I've added a `transcrypt` command, which is really just an alias
under-the-hood for "enter transcrypt".
This commit is contained in:
Tim Byrne
2020-02-21 08:05:56 -06:00
parent ee9ffb6828
commit 4b99ece480
3 changed files with 28 additions and 9 deletions

View File

@@ -96,6 +96,7 @@ def supported_commands():
'introspect',
'list',
'perms',
'transcrypt',
'upgrade',
'version',
]

View File

@@ -1,4 +1,4 @@
"""Test git-crypt"""
"""Test external encryption commands"""
import pytest
@@ -8,15 +8,21 @@ import pytest
[False, 'installed', 'installed-but-failed'],
ids=['not-installed', 'installed', 'installed-but-failed']
)
def test_git_crypt(runner, yadm, paths, tmpdir, crypt):
"""git-crypt tests"""
@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-git-crypt')
pgm = bindir.join('test-ext-crypt')
if crypt:
pgm.write(f'#!/bin/sh\necho git-crypt ran\n')
pgm.write(f'#!/bin/sh\necho ext-crypt ran\n')
pgm.chmod(0o775)
if crypt == 'installed-but-failed':
pgm.write('false\n', mode='a')
@@ -24,8 +30,8 @@ def test_git_crypt(runner, yadm, paths, tmpdir, crypt):
script = f"""
YADM_TEST=1 source {yadm}
YADM_REPO={paths.repo}
GIT_CRYPT_PROGRAM="{pgm}"
git_crypt "param1"
{var}="{pgm}"
{cmd} "param1"
"""
run = runner(command=['bash'], inp=script)
@@ -35,7 +41,7 @@ def test_git_crypt(runner, yadm, paths, tmpdir, crypt):
assert run.failure
else:
assert run.success
assert run.out.strip() == 'git-crypt ran'
assert run.out.strip() == 'ext-crypt ran'
else:
assert run.failure
assert f"command '{pgm}' cannot be located" in run.out