Add STATUS_MODIFIED.
[pwmd.git] / tests / import.test
blob17c6eef7ec57b040e105ef16b36f90551901fa24
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 invoking_user=$USER
15 log_level=9
16 #enable_logging=true
17 [import]
18 passphrase_file=$WDIR/passphrase.key
19 EOF
20 mv -f data/list data/import || bail_out "Could not move data/list."
21 launch_pwmd import
24 test_1() {
25 run_pwmc "--inquire IMPORT import" $DEVNULL <<EOF
26 <element _name="import">import value</invalid>
27 EOF
28 test_failure $test_n $? 536871001 "Invalid syntax."
31 test_2() {
32 run_pwmc "--inquire IMPORT import -S" $DEVNULL <<EOF
33 <element _name="import">import value</element>
34 EOF
35 e=$?
36 if [ $e -eq 0 ]; then
37 run_pwmc "import" >result $DEVNULL <<EOF
38 GET import
39 EOF
40 e=$?
42 test_result $test_n $e import "Import to root."
45 test_3() {
46 run_pwmc "--inquire IMPORT import -S" $DEVNULL <<EOF
47 <element _name="import">new import value</element>
48 EOF
49 e=$?
50 if [ $e -eq 0 ]; then
51 run_pwmc "import" >result $DEVNULL <<EOF
52 GET import
53 EOF
54 e=$?
56 test_result $test_n $e import "Import to root with overwrite."
59 test_4() {
60 run_pwmc "--inquire 'IMPORT --root=import' import -S" $DEVNULL <<EOF
61 <element _name="child">child import value</element>
62 EOF
63 e=$?
64 if [ $e -eq 0 ]; then
65 run_pwmc "import" >result $DEVNULL <<EOF
66 GET import child
67 EOF
68 e=$?
70 test_result $test_n $e import "Import to child."
73 test_5() {
74 run_pwmc "--inquire 'IMPORT --root=import' import -S" $DEVNULL <<EOF
75 <element _name="child">new child import value</element>
76 EOF
77 e=$?
78 if [ $e -eq 0 ]; then
79 run_pwmc "import" >result $DEVNULL <<EOF
80 GET import child
81 EOF
82 e=$?
84 test_result $test_n $e import "Import to child with overwrite."
87 test_6() {
88 run_pwmc "--inquire 'IMPORT --root=import\troot' import -S" $DEVNULL <<EOF
89 <element _name="a">A value<element _name="b">A B value</element></element>
90 <element _name="b">B value</element>
91 EOF
92 e=$?
93 if [ $e -eq 0 ]; then
94 run_pwmc "import" >result $DEVNULL <<EOF
95 GET import root a b
96 EOF
97 e=$?
99 test_result $test_n $e import "Import siblings."
102 test_7() {
103 run_pwmc "--inquire 'IMPORT --root=import\troot' import -S" $DEVNULL <<EOF
104 <element _name="a">A value<element _name="b"/></element>
105 <element _name="b">B value</element>
107 e=$?
108 if [ $e -eq 0 ]; then
109 run_pwmc "import" >result $DEVNULL <<EOF
110 GET import root b
112 e=$?
114 test_result $test_n $e import "Import siblings with overwrite."
117 # FIXME what is this supposed to do?
118 test_8() {
119 run_pwmc "import" >result $DEVNULL <<EOF
120 GET import root a b
122 test_failure $test_n $? 536870970 "Fail to import siblings."
125 run_tests $@