ATTR LIST: No non-reserved attributes for bad permissions.
[pwmd.git] / tests / store.test
blob51fddff26c209af17edbca095cb2e6f916b7b6da
1 #!/bin/bash
2 source common.sh
3 source import-common.sh
5 do_import datafile
7 cat > config << EOF
8 [global]
9 log_level=9
10 #enable_logging=true
11 [datafile]
12 passphrase_file=`pwd`/passphrase.key
13 [datafile.tmp]
14 passphrase_file=`pwd`/passphrase.key
15 EOF
17 launch_pwmd datafile
18 begin_test
20 test_header "Test 1. An element with the same value as the element name."
21 cp -f data/datafile data/datafile.tmp
22 echo -ne 'a\ta' | pwmc $PWMC_ARGS --inquire STORE -S datafile.tmp
23 echo -ne 'GET a' | pwmc $PWMC_ARGS datafile.tmp > result
25 cmp store.result1 result
26 rm -f result
28 echo
29 test_header "Test 2. Empty content (fail)."
30 cp -f data/datafile data/datafile.tmp
31 echo -ne 'a\t' | pwmc $PWMC_ARGS --inquire STORE -S datafile.tmp
32 set +o errexit
33 echo -ne 'GET a' | pwmc $PWMC_ARGS datafile.tmp > result
34 if [ ${PIPESTATUS[1]} == 0 ]; then
35 echo "The previous command should have failed. Stopping."
36 exit 1
39 set -e
41 echo
42 test_header "Test 3. Child element content."
43 echo -ne 'a\tb\ta b value' | pwmc $PWMC_ARGS --inquire STORE -S datafile
44 echo -ne 'GET a\tb' | pwmc $PWMC_ARGS datafile > result
45 cmp store.result3 result
46 rm -f result
48 echo
49 test_header "Test 4. Root targets."
50 echo -ne 'ATTR SET target b a' | pwmc $PWMC_ARGS -S datafile
51 echo -ne 'GET b\tb' | pwmc $PWMC_ARGS datafile > result
52 cmp store.result4 result
53 rm -f result
55 echo
56 test_header "Test 5. Store target content."
57 echo -ne 'b\tb\ta b value' | pwmc $PWMC_ARGS --inquire STORE -S datafile
58 echo -ne 'GET b\tb' | pwmc $PWMC_ARGS datafile > result
59 cmp store.result5 result
60 rm -f result
62 test_header "Test 6. Recursion loop."
63 cp -f data/datafile data/datafile.tmp
64 echo -ne 'ATTR SET target a b' | pwmc $PWMC_ARGS -S datafile.tmp
65 echo -ne 'LIST --recurse' | pwmc $PWMC_ARGS datafile.tmp > result
66 cmp store.result6 result
67 rm -f result
69 echo
70 test_header "Test 7. Recursion to parent (fail)."
71 set +o errexit
72 echo -ne 'ATTR SET target a\tb a' | pwmc $PWMC_ARGS -S datafile.tmp
73 if [ ${PIPESTATUS[1]} == 0 ]; then
74 echo "The previous command should have failed. Stopping."
75 exit 1
78 set -e
80 echo
81 test_header "Test 8. Target to child."
82 cp -f data/datafile data/datafile.tmp
83 echo -ne 'ATTR SET target a a\tb' | pwmc $PWMC_ARGS -S datafile.tmp
84 echo -ne 'LIST --recurse' | pwmc $PWMC_ARGS datafile.tmp > result
85 cmp store.result8 result
86 rm -f result
88 echo
89 test_header "Test 9. Create element at element with recursion loop (fail)."
90 echo -ne 'ATTR SET target a\tb b' | pwmc $PWMC_ARGS -S datafile
91 set +o errexit
92 echo -ne 'a\tb\tc\t' | pwmc $PWMC_ARGS --inquire STORE -S datafile
93 if [ ${PIPESTATUS[1]} == 0 ]; then
94 echo "The previous command should have failed. Stopping."
95 exit 1
98 set -e
100 echo
101 test_header "Test 10. Create content at element with recursion loop (fail)."
102 set +o errexit
103 echo -ne 'a\tb\tcontent' | pwmc $PWMC_ARGS --inquire STORE -S datafile
104 if [ ${PIPESTATUS[1]} == 0 ]; then
105 echo "The previous command should have failed. Stopping."
106 exit 1
109 set -e
110 test_success