forked from yadm-dev/yadm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore encrypted files (yadm-dev#69)
Append the contents of .config/yadm/encrypt to the repo's git ignore list. This is to help prevent accidentally committing unencrypted sensitive data.
- Loading branch information
1 parent
f3249e0
commit 0c9468c
Showing
6 changed files
with
159 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
"""Unit tests: exclude_encrypted""" | ||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'exclude', ['missing', 'outdated', 'up-to-date']) | ||
@pytest.mark.parametrize( | ||
'encrypt_exists', [True, False], ids=['encrypt', 'no-encrypt']) | ||
@pytest.mark.parametrize( | ||
'auto_exclude', [True, False], ids=['enabled', 'disabled']) | ||
def test_exclude_encrypted( | ||
runner, tmpdir, yadm, encrypt_exists, auto_exclude, exclude): | ||
"""Test exclude_encrypted()""" | ||
|
||
header = ( | ||
"# yadm-auto-excludes\n" | ||
"# This section is managed by yadm.\n" | ||
"# Any edits below will be lost.\n" | ||
) | ||
|
||
config_function = 'function config() { echo "false";}' | ||
if auto_exclude: | ||
config_function = 'function config() { return; }' | ||
|
||
encrypt_file = tmpdir.join('encrypt_file') | ||
repo_dir = tmpdir.join('repodir') | ||
exclude_file = repo_dir.join('info/exclude') | ||
|
||
if encrypt_exists: | ||
encrypt_file.write('test-encrypt-data\n', ensure=True) | ||
if exclude == 'outdated': | ||
exclude_file.write( | ||
f'original-exclude\n{header}outdated\n', ensure=True) | ||
elif exclude == 'up-to-date': | ||
exclude_file.write( | ||
f'original-exclude\n{header}test-encrypt-data\n', ensure=True) | ||
|
||
script = f""" | ||
YADM_TEST=1 source {yadm} | ||
{config_function} | ||
DEBUG=1 | ||
YADM_ENCRYPT="{encrypt_file}" | ||
YADM_REPO="{repo_dir}" | ||
exclude_encrypted | ||
""" | ||
run = runner(command=['bash'], inp=script) | ||
assert run.success | ||
assert run.err == '' | ||
|
||
if auto_exclude: | ||
if encrypt_exists: | ||
assert exclude_file.exists() | ||
if exclude == 'missing': | ||
assert exclude_file.read() == f'{header}test-encrypt-data\n' | ||
else: | ||
assert exclude_file.read() == ( | ||
'original-exclude\n' | ||
f'{header}test-encrypt-data\n') | ||
if exclude != 'up-to-date': | ||
assert f'Updating {exclude_file}' in run.out | ||
else: | ||
assert run.out == '' | ||
else: | ||
assert run.out == '' | ||
else: | ||
assert run.out == '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters