Merge pull request #235 from ttionya/hotfix/#229
Fix unable to validate encrypted rclone config file (fixed #229)
This commit is contained in:
+8
-9
@@ -33,15 +33,6 @@ function color() {
|
||||
# success strategy (all / any)
|
||||
########################################
|
||||
function check_rclone_connection() {
|
||||
# check if the configuration exists
|
||||
local RCLONE_CONFIG_FILE=$(rclone config file 2>&1 | grep -o '/[^[:space:]]*rclone\.conf')
|
||||
grep -c "\[${RCLONE_REMOTE_NAME}\]" "${RCLONE_CONFIG_FILE}" > /dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
color red "rclone configuration information not found"
|
||||
color blue "Please configure rclone first, check https://github.com/ttionya/vaultwarden-backup/blob/master/README.md#backup"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check flags validity
|
||||
rclone ${RCLONE_GLOBAL_FLAG} version > /dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
@@ -50,6 +41,14 @@ function check_rclone_connection() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if the configuration exists
|
||||
rclone ${RCLONE_GLOBAL_FLAG} config show 2>&1 | grep -F "[${RCLONE_REMOTE_NAME}]" > /dev/null
|
||||
if [[ $? != 0 ]]; then
|
||||
color red "rclone configuration information not found"
|
||||
color blue "Please configure rclone first, check https://github.com/ttionya/vaultwarden-backup/blob/master/README.md#backup"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check connection
|
||||
local ERROR_COUNT=0
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# Encrypted rclone configuration File (ttionya)
|
||||
|
||||
RCLONE_ENCRYPT_V0:
|
||||
l3mwqE8IiDshJArOYQLMlsen3b/oGL2mT87k29sB0nnLch1gH8aV6oJYh5IrUvKtY8FeCKaNq0cENcYR5V0W7IcHqKFYl1lyo7nG
|
||||
@@ -96,6 +96,7 @@ function test_result() {
|
||||
. tests/units/check-rclone-config-exists/test.sh
|
||||
. tests/units/check-rclone-flags-valid/test.sh
|
||||
. tests/units/check-rclone-connection-initializing/test.sh
|
||||
. tests/units/check-encrypted-rclone-config/test.sh
|
||||
. tests/units/backup-zip-file/test.sh
|
||||
. tests/units/backup-7z-file/test.sh
|
||||
. tests/units/backup-unpackage/test.sh
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
TEST_NAME="check-encrypted-rclone-config"
|
||||
TEST_OUTPUT_DIR="$(pwd)/${OUTPUT_DIR}/${TEST_NAME}"
|
||||
TEST_EXTRACT_DIR="$(pwd)/${EXTRACT_DIR}/${TEST_NAME}"
|
||||
|
||||
PASSWORD="32d22daa-4e38-4c4c-8eeb-caf954d2259c"
|
||||
BACKUP_FILE="${TEST_OUTPUT_DIR}/backup.test.zip"
|
||||
|
||||
FAILED_NUM=0
|
||||
|
||||
color yellow "Starting test case \"${TEST_NAME}\""
|
||||
|
||||
function prepare() {
|
||||
mkdir -p "${TEST_OUTPUT_DIR}" "${TEST_EXTRACT_DIR}"
|
||||
}
|
||||
|
||||
function start() {
|
||||
docker run --rm \
|
||||
--mount "type=bind,source=${TEST_OUTPUT_DIR},target=${REMOTE_DIR}" \
|
||||
-e "RCLONE_REMOTE_DIR=${REMOTE_DIR}" \
|
||||
-e "RCLONE_GLOBAL_FLAG=--config /config/rclone/rclone.enc.conf" \
|
||||
-e "RCLONE_CONFIG_PASS=ttionya" \
|
||||
-e "ZIP_PASSWORD=${PASSWORD}" \
|
||||
-e "BACKUP_FILE_SUFFIX=test" \
|
||||
"${DOCKER_IMAGE}" \
|
||||
backup
|
||||
}
|
||||
|
||||
function test() {
|
||||
color blue "Testing..."
|
||||
|
||||
ls -l "${BACKUP_FILE}"
|
||||
|
||||
7z l -p"${PASSWORD}" "${BACKUP_FILE}"
|
||||
|
||||
docker run --rm \
|
||||
--mount "type=bind,source=${TEST_EXTRACT_DIR},target=/bitwarden/data/" \
|
||||
--mount "type=bind,source=${TEST_OUTPUT_DIR},target=/bitwarden/restore/" \
|
||||
"${DOCKER_IMAGE}" \
|
||||
restore \
|
||||
-f \
|
||||
-p "${PASSWORD}" \
|
||||
--zip-file "$(basename "${BACKUP_FILE}")"
|
||||
|
||||
check_files_same_in_folders "${DATA_DIR}" "${TEST_EXTRACT_DIR}"
|
||||
if [[ $? != 0 ]]; then
|
||||
((FAILED_NUM++))
|
||||
fi
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
sudo rm -rf "${TEST_OUTPUT_DIR}" "${TEST_EXTRACT_DIR}"
|
||||
|
||||
unset TEST_OUTPUT_DIR
|
||||
unset TEST_EXTRACT_DIR
|
||||
unset PASSWORD
|
||||
unset BACKUP_FILE
|
||||
}
|
||||
|
||||
prepare
|
||||
start
|
||||
test
|
||||
cleanup
|
||||
|
||||
test_result "${TEST_NAME}" "${FAILED_NUM}"
|
||||
Reference in New Issue
Block a user