LIST: Fix memory leaks.
[pwmd.git] / tests / import.test
blob4617bf59f35d2f9b32441c14ed3ef34854aeccc5
1 #!/bin/sh
3 # Tests for the IMPORT protocol command.
5 MAX_TESTS=8
7 . $AM_SRCDIR/common.sh
8 . $AM_SRCDIR/import-common.sh
10 init_tests() {
11 do_import list
12 cat >$OUTDIR/config << EOF
13 [global]
14 log_level=9
15 #enable_logging=true
16 [import]
17 passphrase_file=$WDIR/passphrase.key
18 EOF
19 mv -f data/list data/import || bail_out "Could not move data/list."
20 launch_pwmd import
23 test_1() {
24 run_pwmc "--inquire IMPORT import" $DEVNULL <<EOF
25 <element _name="import">import value</invalid>
26 EOF
27 test_failure $test_n $? 536871001 "Invalid syntax."
30 test_2() {
31 run_pwmc "--inquire IMPORT import -S" $DEVNULL <<EOF
32 <element _name="import">import value</element>
33 EOF
34 e=$?
35 if [ $e -eq 0 ]; then
36 run_pwmc "import" >result $DEVNULL <<EOF
37 GET import
38 EOF
39 e=$?
41 test_result $test_n $e import "Import to root."
44 test_3() {
45 run_pwmc "--inquire IMPORT import -S" $DEVNULL <<EOF
46 <element _name="import">new import value</element>
47 EOF
48 e=$?
49 if [ $e -eq 0 ]; then
50 run_pwmc "import" >result $DEVNULL <<EOF
51 GET import
52 EOF
53 e=$?
55 test_result $test_n $e import "Import to root with overwrite."
58 test_4() {
59 run_pwmc "--inquire 'IMPORT --root=import' import -S" $DEVNULL <<EOF
60 <element _name="child">child import value</element>
61 EOF
62 e=$?
63 if [ $e -eq 0 ]; then
64 run_pwmc "import" >result $DEVNULL <<EOF
65 GET import child
66 EOF
67 e=$?
69 test_result $test_n $e import "Import to child."
72 test_5() {
73 run_pwmc "--inquire 'IMPORT --root=import' import -S" $DEVNULL <<EOF
74 <element _name="child">new child import value</element>
75 EOF
76 e=$?
77 if [ $e -eq 0 ]; then
78 run_pwmc "import" >result $DEVNULL <<EOF
79 GET import child
80 EOF
81 e=$?
83 test_result $test_n $e import "Import to child with overwrite."
86 test_6() {
87 run_pwmc "--inquire 'IMPORT --root=import\troot' import -S" $DEVNULL <<EOF
88 <element _name="a">A value<element _name="b">A B value</element></element>
89 <element _name="b">B value</element>
90 EOF
91 e=$?
92 if [ $e -eq 0 ]; then
93 run_pwmc "import" >result $DEVNULL <<EOF
94 GET import root a b
95 EOF
96 e=$?
98 test_result $test_n $e import "Import siblings."
101 test_7() {
102 run_pwmc "--inquire 'IMPORT --root=import\troot' import -S" $DEVNULL <<EOF
103 <element _name="a">A value<element _name="b"/></element>
104 <element _name="b">B value</element>
106 e=$?
107 if [ $e -eq 0 ]; then
108 run_pwmc "import" >result $DEVNULL <<EOF
109 GET import root b
111 e=$?
113 test_result $test_n $e import "Import siblings with overwrite."
116 # FIXME what is this supposed to do?
117 test_8() {
118 run_pwmc "import" >result $DEVNULL <<EOF
119 GET import root a b
121 test_failure $test_n $? 536870970 "Fail to import siblings."
124 run_tests $@