-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add testinfra check that the backup script works
Try creating a backup and verify it contains a few of the files we expect it to.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pytest | ||
import testutils | ||
|
||
sdvars = testutils.securedrop_test_vars | ||
testinfra_hosts = [sdvars.app_hostname] | ||
|
||
|
||
@pytest.mark.skip_in_prod | ||
def test_backup(host): | ||
"""Create a backup and verify it contains expected files""" | ||
|
||
with host.sudo(): | ||
result = host.run("securedrop-app-backup.py --dest /tmp") | ||
assert result.rc == 0 | ||
tarball = result.stdout.strip() | ||
# looks like a file path | ||
assert tarball.endswith(".tar.gz") | ||
assert host.file(f"/tmp/{tarball}").exists | ||
# list files in the tarball | ||
contains = host.run(f"tar -tzf /tmp/{tarball}") | ||
assert contains.rc == 0 | ||
contains_list = contains.stdout.splitlines() | ||
assert "/var/www/securedrop/config.py" in contains_list | ||
assert "/etc/tor/torrc" in contains_list | ||
assert "/var/lib/tor/services" in contains_list | ||
# cleanup | ||
cleanup = host.run(f"rm /tmp/{tarball}") | ||
assert cleanup.rc == 0 |