Fixup tests for with and without gpg-agent use.
[pwmd.git] / tests / move.test
blob7cf91d3e753ae0b96a25315178bf32a0fdad8164
1 #!/bin/bash
3 # Most checks should be done by the client. For example, recursion loop
4 # checking is not done after the element has been moved.
6 source common.sh
7 source import-common.sh
9 do_import list
11 cat > config << EOF
12 [global]
13 log_level=9
14 #enable_logging=true
15 [move]
16 passphrase_file=`pwd`/list.key
17 EOF
19 mv -f data/list data/move
20 launch_pwmd move
22 begin_test
23 echo "Test 1. Move src to src (fail)."
24 set +o errexit
25 echo -ne 'MOVE !a !a' | pwmc $PWMC_ARGS move
26 if [ ${PIPESTATUS[1]} == 0 ]; then
27 echo "The previous command should have failed. Stopping."
28 exit 1
31 set -e
33 echo
34 echo "Test 2. Move non-existant (fail)."
35 set +o errexit
36 echo -ne 'MOVE non-existant !a' | pwmc $PWMC_ARGS move
37 if [ ${PIPESTATUS[1]} == 0 ]; then
38 echo "The previous command should have failed. Stopping."
39 exit 1
42 set -e
44 echo
45 echo "Test 3. Move child with target to root."
46 echo -ne 'MOVE !a\t!b\tc ' | pwmc $PWMC_ARGS move
48 echo
49 echo "Test 4. Move child to sibling child with target."
50 echo -ne 'MOVE !a\tc !a\tb\tc\td\te' | pwmc $PWMC_ARGS -S move
51 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS move > result
52 cmp move.result4 result
53 rm -f result
55 echo
56 echo "Test 5. Move child with target to parent sibling."
57 echo -ne 'MOVE !a\tb\tc\td\te\tc !a' | pwmc $PWMC_ARGS -S move
58 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS move > result
59 cmp move.result5 result
60 rm -f result
62 echo
63 echo "Test 6. Overwrite existing tree."
64 echo -ne 'MOVE !a\tb\tc\t!d ' | pwmc $PWMC_ARGS -S move
65 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS move > result
66 cmp move.result6 result
67 rm -f result
69 echo
70 echo "Test 7. Show child elements whose target contains an error."
71 echo -ne 'MOVE !d c\te' | pwmc $PWMC_ARGS -S move
72 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS move > result
73 cmp move.result7 result
74 rm -f result
76 test_success