parent
a78fe20c5d
commit
d80bbff2b9
3 changed files with 52 additions and 6 deletions
|
@ -10,7 +10,7 @@ function create_encrypt() {
|
|||
echo "$efile" >> "$T_YADM_ENCRYPT"
|
||||
echo "$efile" >> "$T_DIR_WORK/$efile"
|
||||
mkdir -p "$T_DIR_WORK/dir one/$efile"
|
||||
echo "dir one/$efile/file1" >> "$T_YADM_ENCRYPT"
|
||||
echo "'dir one'/$efile/file1" >> "$T_YADM_ENCRYPT"
|
||||
echo "dir one/$efile/file1" >> "$T_DIR_WORK/dir one/$efile/file1"
|
||||
done
|
||||
}
|
||||
|
@ -97,8 +97,11 @@ function test_alt() {
|
|||
if [ -z "$auto_alt" ]; then
|
||||
run "${T_YADM_Y[@]}" alt
|
||||
#; validate status and output
|
||||
echo "TEST:Link Name:$link_name"
|
||||
echo "TEST:DIR Link Name:$dir_link_name"
|
||||
if [ "$status" != 0 ] || [[ ! "$output" =~ Linking.+$link_name ]] || [[ ! "$output" =~ Linking.+$dir_link_name ]]; then
|
||||
echo "OUTPUT:$output"
|
||||
echo "STATUS:$status"
|
||||
echo "ERROR: Could not confirm status and output of alt command"
|
||||
return 1;
|
||||
fi
|
||||
|
|
|
@ -93,9 +93,14 @@ EOF
|
|||
if cd "$T_DIR_WORK"; then
|
||||
# shellcheck disable=2013
|
||||
# (globbing is desired)
|
||||
for f in $(cat "$T_YADM_ENCRYPT"); do
|
||||
echo "$f"
|
||||
done | sort > "$T_TMP/expected_list"
|
||||
while IFS='' read -r glob || [ -n "$glob" ]; do
|
||||
if [[ ! $glob =~ ^# && ! $glob =~ ^[[:space:]]*$ ]] ; then
|
||||
local IFS=$'\n'
|
||||
for matching_file in $(eval ls "$glob" 2>/dev/null); do
|
||||
echo "$matching_file"
|
||||
done
|
||||
fi
|
||||
done < "$T_YADM_ENCRYPT" | sort > "$T_TMP/expected_list"
|
||||
fi
|
||||
)
|
||||
|
||||
|
@ -104,6 +109,8 @@ EOF
|
|||
echo "ERROR: Archive does not contain the correct files"
|
||||
echo "Contains:"
|
||||
cat "$T_TMP/archive_list"
|
||||
echo "Expected:"
|
||||
cat "$T_TMP/expected_list"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
|
@ -196,7 +203,7 @@ EOF
|
|||
validate_archive symmetric
|
||||
}
|
||||
|
||||
@test "Command 'encrypt' (comments in YADM_ARCHIVE)" {
|
||||
@test "Command 'encrypt' (comments in YADM_ENCRYPT)" {
|
||||
echo "
|
||||
When 'encrypt' command is provided,
|
||||
and YADM_ENCRYPT is present
|
||||
|
@ -233,7 +240,7 @@ EOF
|
|||
validate_archive symmetric
|
||||
}
|
||||
|
||||
@test "Command 'encrypt' (empty lines and space lines in YADM_ARCHIVE)" {
|
||||
@test "Command 'encrypt' (empty lines and space lines in YADM_ENCRYPT)" {
|
||||
echo "
|
||||
When 'encrypt' command is provided,
|
||||
and YADM_ENCRYPT is present
|
||||
|
@ -270,6 +277,40 @@ EOF
|
|||
validate_archive symmetric
|
||||
}
|
||||
|
||||
@test "Command 'encrypt' (paths with spaces/globs 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 paths with spaces to YADM_ARCHIVE
|
||||
local original_encrypt
|
||||
original_encrypt=$(cat "$T_YADM_ENCRYPT")
|
||||
echo -e "'space test'/file*" >> "$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)" {
|
||||
echo "
|
||||
When 'encrypt' command is provided,
|
||||
|
|
|
@ -303,6 +303,8 @@ function create_worktree() {
|
|||
.ssh/secret.pub \
|
||||
.tmux.conf \
|
||||
.vimrc \
|
||||
"space test/file one" \
|
||||
"space test/file two" \
|
||||
;
|
||||
do
|
||||
make_parents "$DIR_WORKTREE/$f"
|
||||
|
|
Loading…
Reference in a new issue