mirror of
https://github.com/deajan/obackup.git
synced 2024-12-25 06:53:41 +01:00
Added gpg unit test
This commit is contained in:
parent
93dbcb4f74
commit
20cf783bdb
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
## obackup basic tests suite 2016090402
|
## obackup basic tests suite 2016090403
|
||||||
|
|
||||||
#TODO: Must recreate files before each test set
|
#TODO: Must recreate files before each test set
|
||||||
|
|
||||||
@ -62,6 +62,7 @@ CRYPT_EXTENSION=".obackup.gpg"
|
|||||||
ROTATE_1_EXTENSION=".obackup.1"
|
ROTATE_1_EXTENSION=".obackup.1"
|
||||||
|
|
||||||
PASSFILE="passfile"
|
PASSFILE="passfile"
|
||||||
|
CRYPT_TEST_FILE="testfile"
|
||||||
|
|
||||||
function SetStableToYes () {
|
function SetStableToYes () {
|
||||||
if grep "^IS_STABLE=YES" "$OBACKUP_DIR/$OBACKUP_EXECUTABLE" > /dev/null; then
|
if grep "^IS_STABLE=YES" "$OBACKUP_DIR/$OBACKUP_EXECUTABLE" > /dev/null; then
|
||||||
@ -95,16 +96,14 @@ function SetEncryption () {
|
|||||||
|
|
||||||
function SetupGPG {
|
function SetupGPG {
|
||||||
if type gpg2 > /dev/null; then
|
if type gpg2 > /dev/null; then
|
||||||
GPG=gpg2
|
CRYPT_TOOL=gpg2
|
||||||
echo "USING GPG2"
|
|
||||||
elif type gpg > /dev/null; then
|
elif type gpg > /dev/null; then
|
||||||
echo "USING GPG"
|
CRYPT_TOOL=gpg
|
||||||
GPG=gpg
|
|
||||||
else
|
else
|
||||||
echo "No gpg support"
|
echo "No gpg support"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! $GPG --list-keys | grep "John Doe" ; then
|
if ! $CRYPT_TOOL --list-keys | grep "John Doe" > /dev/null; then
|
||||||
|
|
||||||
cat >gpgcommand <<EOF
|
cat >gpgcommand <<EOF
|
||||||
%echo Generating a GPG Key
|
%echo Generating a GPG Key
|
||||||
@ -131,8 +130,9 @@ EOF
|
|||||||
echo "No rngd support"
|
echo "No rngd support"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$GPG --batch --gen-key gpgcommand
|
$CRYPT_TOOL --batch --gen-key gpgcommand
|
||||||
echo $($GPG --list-keys)
|
echo "Currently owned $CRYPT_TOOL keys"
|
||||||
|
echo $($CRYPT_TOOL --list-keys)
|
||||||
rm -f gpgcommand
|
rm -f gpgcommand
|
||||||
|
|
||||||
fi
|
fi
|
||||||
@ -213,6 +213,17 @@ function test_Merge () {
|
|||||||
SetStableToYes
|
SetStableToYes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_GPG () {
|
||||||
|
$CRYPT_TOOL --out "$TESTS_DIR/$CRYPT_TEST_FILE$CRYPT_EXTENSION" --recipient "John Doe" --batch --yes --encrypt "$TESTS_DIR/$PASSFILE"
|
||||||
|
assertEquals "Encrypt file" "0" $?
|
||||||
|
|
||||||
|
$CRYPT_TOOL --out "$TESTS_DIR/$CRYPT_TEST_FILE" --batch --yes --passphrase-file="$TESTS_DIR/$PASSFILE" --decrypt "$TESTS_DIR/$CRYPT_TEST_FILE$CRYPT_EXTENSION"
|
||||||
|
assertEquals "Decrypt file using passfile" "0" $?
|
||||||
|
|
||||||
|
$CRYPT_TOOL --out "$TESTS_DIR/$CRYPT_TEST_FILE" --batch --yes --passphrase=PassPhrase123 --decrypt "$TESTS_DIR/$CRYPT_TEST_FILE$CRYPT_EXTENSION"
|
||||||
|
assertEquals "Decrypt file using passphrase" "0" $?
|
||||||
|
}
|
||||||
|
|
||||||
function test_LocalRun () {
|
function test_LocalRun () {
|
||||||
SetEncryption "$CONF_DIR/$LOCAL_CONF" false
|
SetEncryption "$CONF_DIR/$LOCAL_CONF" false
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user