1
0
Fork 0
mirror of synced 2024-12-22 06:31:07 -05:00

Add test case for supporting directories in .yadm/encrypt (#81)

This commit is contained in:
Tim Byrne 2017-09-04 12:59:13 -05:00
parent e09b5a551e
commit df952094a1
No known key found for this signature in database
GPG key ID: 14DB4FC2465A4B12

View file

@ -96,8 +96,15 @@ EOF
while IFS='' read -r glob || [ -n "$glob" ]; do while IFS='' read -r glob || [ -n "$glob" ]; do
if [[ ! $glob =~ ^# && ! $glob =~ ^[[:space:]]*$ ]] ; then if [[ ! $glob =~ ^# && ! $glob =~ ^[[:space:]]*$ ]] ; then
local IFS=$'\n' local IFS=$'\n'
for matching_file in $(eval ls "$glob" 2>/dev/null); do for matching_file in $(eval ls -d "$glob" 2>/dev/null); do
echo "$matching_file" if [ -d "$matching_file" ]; then
echo "$matching_file/"
for subfile in "$matching_file"/*; do
echo "$subfile"
done
else
echo "$matching_file"
fi
done done
fi fi
done < "$T_YADM_ENCRYPT" | sort > "$T_TMP/expected_list" done < "$T_YADM_ENCRYPT" | sort > "$T_TMP/expected_list"
@ -311,6 +318,40 @@ EOF
validate_archive symmetric validate_archive symmetric
} }
@test "Command 'encrypt' (directories in YADM_ENCRYPT)" {
echo "
When 'encrypt' command is provided,
and YADM_ENCRYPT is present
Create YADM_ARCHIVE
Report the archive created
Archive should be valid
Exit with 0
"
#; add directory paths to YADM_ARCHIVE
local original_encrypt
original_encrypt=$(cat "$T_YADM_ENCRYPT")
echo -e "'space test'" >> "$T_YADM_ENCRYPT"
#; run encrypt
run expect <<EOF
set timeout 2;
spawn ${T_YADM_Y[*]} encrypt;
expect "passphrase:" {send "$T_PASSWD\n"}
expect "passphrase:" {send "$T_PASSWD\n"}
expect "$"
foreach {pid spawnid os_error_flag value} [wait] break
exit \$value
EOF
#; validate status and output
[ "$status" -eq 0 ]
[[ "$output" =~ Wrote\ new\ file:.+$T_YADM_ARCHIVE ]]
#; validate the archive
validate_archive symmetric
}
@test "Command 'encrypt' (overwrite)" { @test "Command 'encrypt' (overwrite)" {
echo " echo "
When 'encrypt' command is provided, When 'encrypt' command is provided,