From 6fe81cdf2dbd5e874859fb88f5ae002413fbc725 Mon Sep 17 00:00:00 2001 From: Frederik Ring Date: Mon, 23 Aug 2021 09:08:50 +0200 Subject: [PATCH] add testcase for gpg encryption --- .circleci/config.yml | 4 ++++ test/compose/docker-compose.yml | 2 +- test/compose/run.sh | 8 ++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 94d4181..512687a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,6 +11,10 @@ jobs: name: Build command: | docker build . -t offen/docker-volume-backup:canary + - run: + name: Install gnupg + command: | + sudo apt-get install -y gnupg - run: name: Run tests working_directory: ~/docker-volume-backup/test diff --git a/test/compose/docker-compose.yml b/test/compose/docker-compose.yml index c62747e..1646ce6 100644 --- a/test/compose/docker-compose.yml +++ b/test/compose/docker-compose.yml @@ -26,9 +26,9 @@ services: BACKUP_FILENAME: test.tar.gz BACKUP_CRON_EXPRESSION: 0 0 5 31 2 ? BACKUP_RETENTION_DAYS: ${BACKUP_RETENTION_DAYS:-7} - BACKUP_FORCE_PRUNE: ${BACKUP_FORCE_PRUNE:-} BACKUP_PRUNING_LEEWAY: 5s BACKUP_PRUNING_PREFIX: test + GPG_PASSPHRASE: 1234secret volumes: - ./local:/archive - app_data:/backup/app_data:ro diff --git a/test/compose/run.sh b/test/compose/run.sh index 9d65971..d8b830f 100755 --- a/test/compose/run.sh +++ b/test/compose/run.sh @@ -13,11 +13,13 @@ docker-compose exec backup backup docker run --rm -it \ -v compose_backup_data:/data alpine \ - ash -c 'tar -xf /data/backup/test.tar.gz && test -f /backup/app_data/offen.db' + ash -c 'apk add gnupg && echo 1234secret | gpg -d --pinentry-mode loopback --passphrase-fd 0 --yes /data/backup/test.tar.gz.gpg > /tmp/test.tar.gz && tar -xf /tmp/test.tar.gz -C /tmp && test -f /tmp/backup/app_data/offen.db' echo "[TEST:PASS] Found relevant files in untared remote backup." -tar -xf ./local/test.tar.gz -C /tmp && test -f /tmp/backup/app_data/offen.db +echo 1234secret | gpg -d --yes --passphrase-fd 0 ./local/test.tar.gz.gpg > ./local/decrypted.tar.gz +tar -xf ./local/decrypted.tar.gz -C /tmp && test -f /tmp/backup/app_data/offen.db +rm ./local/decrypted.tar.gz echo "[TEST:PASS] Found relevant files in untared local backup." @@ -29,8 +31,6 @@ fi echo "[TEST:PASS] All containers running post backup." -docker-compose down - # The second part of this test checks if backups get deleted when the retention # is set to 0 days (which it should not as it would mean all backups get deleted) # TODO: find out if we can test actual deletion without having to wait for a day