imip-agent

tests/test_person_invitation_recurring.sh

708:1e82e542a9a7
2015-09-08 Paul Boddie Added tests for absent files to suppress uninteresting error messages.
     1 #!/bin/sh     2      3 THIS_DIR=`dirname $0`     4      5 TEMPLATES="$THIS_DIR/templates"     6 PERSON_SCRIPT="$THIS_DIR/../imip_person.py"     7 SHOWMAIL="$THIS_DIR/../tools/showmail.py"     8 STORE=/tmp/store     9 STATIC=/tmp/static    10 PREFS=/tmp/prefs    11 ARGS="-S $STORE -P $STATIC -p $PREFS -d"    12 USER="mailto:vincent.vole@example.com"    13 SENDER="mailto:paul.boddie@example.com"    14 FBFILE="$STORE/$USER/freebusy"    15 FBOTHERFILE="$STORE/$USER/freebusy-other/$SENDER"    16 FBSENDERFILE="$STORE/$SENDER/freebusy"    17 TAB=`printf '\t'`    18     19 OUTGOING_SCRIPT="$THIS_DIR/../imip_person_outgoing.py"    20     21 PYTHONPATH="$THIS_DIR/.."    22 export PYTHONPATH    23     24 ACCEPT_SCRIPT="$THIS_DIR/test_handle.py"    25 ACCEPT_ARGS="accept $STORE"    26     27 DECLINE_SCRIPT="$THIS_DIR/test_handle.py"    28 DECLINE_ARGS="decline $STORE"    29     30 ERROR=err.tmp    31     32 rm -r $STORE    33 rm -r $STATIC    34 rm -r $PREFS    35 rm $ERROR    36 rm out*.tmp    37     38 mkdir -p "$PREFS/$USER"    39 echo 'Europe/Oslo' > "$PREFS/$USER/TZID"    40 echo 'share' > "$PREFS/$USER/freebusy_sharing"    41     42 mkdir -p "$PREFS/$SENDER"    43 echo 'Europe/Oslo' > "$PREFS/$USER/TZID"    44     45 # Test free/busy responses.    46     47   "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \    48 | "$SHOWMAIL" \    49 > out0.tmp    50     51    grep -q 'METHOD:REPLY' out0.tmp \    52 && ! grep -q '^FREEBUSY' out0.tmp \    53 && echo "Success" \    54 || echo "Failed"    55     56   "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person.txt" 2>> $ERROR \    57 | "$SHOWMAIL" \    58 > out1.tmp    59     60    grep -q 'METHOD:REPLY' out1.tmp \    61 && ! grep -q '^FREEBUSY' out1.tmp \    62 && echo "Success" \    63 || echo "Failed"    64     65 # Publish an event, testing registration in the outgoing handler.    66     67 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring.txt" 2>> $ERROR    68     69    grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBSENDERFILE" \    70 && echo "Success" \    71 || echo "Failed"    72     73 # Test registration in the incoming handler for the recipient.    74     75   "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring.txt" 2>> $ERROR \    76 | "$SHOWMAIL" \    77 > out2.tmp    78     79    ! grep -q 'METHOD:REPLY' out2.tmp \    80 && echo "Success" \    81 || echo "Failed"    82     83    ! [ -e "$FBFILE" ] \    84 || ! grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \    85 && echo "Success" \    86 || echo "Failed"    87     88    grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBOTHERFILE" \    89 && echo "Success" \    90 || echo "Failed"    91     92 # Test acceptance and registration in the outgoing handler.    93     94   "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" 2>> $ERROR \    95 | tee out3.tmp \    96 | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR    97     98    grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \    99 && echo "Success" \   100 || echo "Failed"   101    102 # Test recurrence cancellation in the outgoing handler.   103    104 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring-instance.txt" 2>> $ERROR   105    106    [ `grep "event8@example.com" "$FBSENDERFILE" | wc -l` = '2' ] \   107 && ! grep -q "^20141114T090000Z${TAB}20141114T100000Z" "$FBSENDERFILE" \   108 && echo "Success" \   109 || echo "Failed"   110    111 # Test cancellation in the incoming handler.   112    113   "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring-instance.txt" 2>> $ERROR \   114 | "$SHOWMAIL" \   115 > out4.tmp   116    117    ! grep -q 'METHOD:REPLY' out4.tmp \   118 && echo "Success" \   119 || echo "Failed"   120    121    [ `grep "event8@example.com" "$FBFILE" | wc -l` = '2' ] \   122 && ! grep -q "^20141114T090000Z${TAB}20141114T100000Z" "$FBFILE" \   123 && echo "Success" \   124 || echo "Failed"   125    126    [ `grep "event8@example.com" "$FBOTHERFILE" | wc -l` = '2' ] \   127 && ! grep -q "^20141114T090000Z${TAB}20141114T100000Z" "$FBOTHERFILE" \   128 && echo "Success" \   129 || echo "Failed"   130    131 # Test rescheduling in the outgoing handler.   132    133 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring-reschedule-instance.txt" 2>> $ERROR   134    135    grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBSENDERFILE" \   136 && ! grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBSENDERFILE" \   137 && echo "Success" \   138 || echo "Failed"   139    140 # Test rescheduling in the incoming handler.   141    142   "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring-reschedule-instance.txt" 2>> $ERROR \   143 | "$SHOWMAIL" \   144 > out5.tmp   145    146    ! grep -q 'METHOD:REPLY' out5.tmp \   147 && echo "Success" \   148 || echo "Failed"   149    150    ! grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBFILE" \   151 && grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBFILE" \   152 && echo "Success" \   153 || echo "Failed"   154    155    grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBOTHERFILE" \   156 && ! grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBOTHERFILE" \   157 && echo "Success" \   158 || echo "Failed"   159    160 # Test rescheduling acceptance in the outgoing handler.   161    162   "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" "20141010T080000Z" 2>> $ERROR \   163 | tee out6.tmp \   164 | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR   165    166    grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBFILE" \   167 && ! grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBFILE" \   168 && echo "Success" \   169 || echo "Failed"   170    171 # Test complete cancellation in the outgoing handler.   172    173 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring.txt" 2>> $ERROR   174    175    ! grep -q "event8@example.com" "$FBSENDERFILE" \   176 && echo "Success" \   177 || echo "Failed"   178    179 # Test complete cancellation in the incoming handler.   180    181   "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring.txt" 2>> $ERROR \   182 | "$SHOWMAIL" \   183 > out6.tmp   184    185    ! grep -q 'METHOD:REPLY' out6.tmp \   186 && echo "Success" \   187 || echo "Failed"   188    189    ! grep -q "event8@example.com" "$FBFILE" \   190 && echo "Success" \   191 || echo "Failed"   192    193    ! grep -q "event8@example.com" "$FBOTHERFILE" \   194 && echo "Success" \   195 || echo "Failed"   196    197 # Switch time zones.   198    199 echo 'Europe/Mariehamn' > "$PREFS/$USER/TZID"   200    201 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring.txt" 2>> $ERROR   202    203    grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBSENDERFILE" \   204 && echo "Success" \   205 || echo "Failed"   206    207   "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring.txt" 2>> $ERROR \   208 | "$SHOWMAIL" \   209 > out7.tmp   210    211    ! grep -q 'METHOD:REPLY' out7.tmp \   212 && echo "Success" \   213 || echo "Failed"   214    215    ! grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \   216 && echo "Success" \   217 || echo "Failed"   218    219    grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBOTHERFILE" \   220 && echo "Success" \   221 || echo "Failed"   222    223   "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" 2>> $ERROR \   224 | tee out8.tmp \   225 | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR   226    227    grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \   228 && echo "Success" \   229 || echo "Failed"   230    231 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring.txt" 2>> $ERROR   232    233    ! grep -q "event8@example.com" "$FBSENDERFILE" \   234 && echo "Success" \   235 || echo "Failed"   236    237   "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring.txt" 2>> $ERROR \   238 | "$SHOWMAIL" \   239 > out9.tmp   240    241    ! grep -q 'METHOD:REPLY' out9.tmp \   242 && echo "Success" \   243 || echo "Failed"   244    245    ! grep -q "event8@example.com" "$FBFILE" \   246 && echo "Success" \   247 || echo "Failed"   248    249    ! grep -q "event8@example.com" "$FBOTHERFILE" \   250 && echo "Success" \   251 || echo "Failed"   252    253 # Test floating dates. Here, the outgoing interpretation is different because   254 # the sender is in a different time zone.   255    256 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring-day-floating.txt" 2>> $ERROR   257    258    grep -q "^20141211T230000Z${TAB}20141212T230000Z" "$FBSENDERFILE" \   259 && echo "Success" \   260 || echo "Failed"   261    262   "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring-day-floating.txt" 2>> $ERROR \   263 | "$SHOWMAIL" \   264 > out10.tmp   265    266    ! grep -q 'METHOD:REPLY' out10.tmp \   267 && echo "Success" \   268 || echo "Failed"   269    270    ! grep -q "^20141211T220000Z${TAB}20141212T220000Z" "$FBFILE" \   271 && echo "Success" \   272 || echo "Failed"   273    274 # (The organiser is not attending.)   275    276    ! grep -q "^20141211T220000Z${TAB}20141212T220000Z" "$FBOTHERFILE" \   277 && echo "Success" \   278 || echo "Failed"   279    280   "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event12@example.com" 2>> $ERROR \   281 | tee out11.tmp \   282 | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR   283    284    grep -q "^20141211T220000Z${TAB}20141212T220000Z" "$FBFILE" \   285 && echo "Success" \   286 || echo "Failed"