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 $PREFS" 26 27 DECLINE_SCRIPT="$THIS_DIR/test_handle.py" 28 DECLINE_ARGS="decline $STORE $PREFS" 29 30 ERROR=err.tmp 31 32 rm -rf $STORE 33 rm -rf $STATIC 34 rm -rf $PREFS 35 rm -f $ERROR 36 rm -f out*.tmp 37 38 mkdir -p "$PREFS/$USER" 39 echo 'Europe/Oslo' > "$PREFS/$USER/TZID" 40 echo 'share' > "$PREFS/$USER/freebusy_sharing" 41 echo 'add' > "$PREFS/$USER/add_method_response" 42 43 mkdir -p "$PREFS/$SENDER" 44 echo 'Europe/Oslo' > "$PREFS/$USER/TZID" 45 echo 'always' > "$PREFS/$SENDER/event_refreshing" 46 47 # Publish an event, testing registration in the outgoing handler. 48 49 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring.txt" 2>> $ERROR 50 51 grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBSENDERFILE" \ 52 && echo "Success" \ 53 || echo "Failed" 54 55 # Test a request from an attendee for the event details to be refreshed. 56 57 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-refresh-person-recurring.txt" 2>> $ERROR \ 58 | "$SHOWMAIL" \ 59 > out2.tmp 60 61 grep -q 'METHOD:REQUEST' out2.tmp \ 62 && echo "Success" \ 63 || echo "Failed" 64 65 # Present the result to the recipient. 66 67 "$PERSON_SCRIPT" $ARGS < out2.tmp 2>> $ERROR \ 68 | "$SHOWMAIL" \ 69 > out3.tmp 70 71 ! grep -q 'METHOD:REPLY' out3.tmp \ 72 && echo "Success" \ 73 || echo "Failed" 74 75 ! [ -e "$FBFILE" ] \ 76 || ! grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \ 77 && echo "Success" \ 78 || echo "Failed" 79 80 grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBOTHERFILE" \ 81 && echo "Success" \ 82 || echo "Failed" 83 84 # Test acceptance and registration in the outgoing handler. 85 86 "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" 2>> $ERROR \ 87 | tee out4.tmp \ 88 | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR 89 90 grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \ 91 && echo "Success" \ 92 || echo "Failed" 93 94 # Test a request from a non-attendee for the event details to be refreshed. 95 96 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-refresh-person-recurring-non-attendee.txt" 2>> $ERROR \ 97 | "$SHOWMAIL" \ 98 > out5.tmp 99 100 ! grep -q 'METHOD:REQUEST' out5.tmp \ 101 && echo "Success" \ 102 || echo "Failed" 103 104 # Test rescheduling in the outgoing handler. 105 106 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring-reschedule-instance.txt" 2>> $ERROR 107 108 grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBSENDERFILE" \ 109 && ! grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBSENDERFILE" \ 110 && echo "Success" \ 111 || echo "Failed" 112 113 # Test another request from an attendee for the event details to be refreshed. 114 115 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-refresh-person-recurring.txt" 2>> $ERROR \ 116 | tee out6r.tmp \ 117 | "$SHOWMAIL" \ 118 > out6.tmp 119 120 grep -q 'METHOD:REQUEST' out6.tmp \ 121 && grep -q 'RECURRENCE-ID' out6.tmp \ 122 && [ `grep 'BEGIN:VEVENT' out6.tmp | wc -l` = '2' ] \ 123 && echo "Success" \ 124 || echo "Failed" 125 126 # Process the resulting message. 127 128 "$PERSON_SCRIPT" $ARGS < out6r.tmp 2>> $ERROR \ 129 | "$SHOWMAIL" \ 130 > out6a.tmp 131 132 [ -e "$STORE/$USER/objects/event8@example.com" ] \ 133 && [ -e "$STORE/$USER/recurrences/event8@example.com/20141010T080000Z" ] \ 134 && echo "Success" \ 135 || echo "Failed" 136 137 # Cancel a recurrence. Both the original and rescheduled recurrences should be 138 # absent from the free/busy collection. 139 140 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring-rescheduled-instance.txt" 2>> $ERROR 141 142 [ -e "$STORE/$SENDER/objects/event8@example.com" ] \ 143 && ! [ -e "$STORE/$SENDER/recurrences/event8@example.com/20141010T080000Z" ] \ 144 && [ -e "$STORE/$SENDER/cancellations/recurrences/event8@example.com/20141010T080000Z" ] \ 145 && echo "Success" \ 146 || echo "Failed" 147 148 ! grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBSENDERFILE" \ 149 && ! grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBSENDERFILE" \ 150 && echo "Success" \ 151 || echo "Failed" 152 153 # Test another request from an attendee for the event details to be refreshed. 154 # The additional recurrence should now be absent. 155 156 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-refresh-person-recurring.txt" 2>> $ERROR \ 157 | tee out7r.tmp \ 158 | "$SHOWMAIL" \ 159 > out7.tmp 160 161 grep -q 'METHOD:REQUEST' out7.tmp \ 162 && grep -q 'METHOD:CANCEL' out7.tmp \ 163 && [ `grep 'BEGIN:VEVENT' out7.tmp | wc -l` = '2' ] \ 164 && echo "Success" \ 165 || echo "Failed" 166 167 # Process the resulting message. 168 169 "$PERSON_SCRIPT" $ARGS < out7r.tmp 2>> $ERROR \ 170 | "$SHOWMAIL" \ 171 > out7a.tmp 172 173 [ -e "$STORE/$USER/objects/event8@example.com" ] \ 174 && ! [ -e "$STORE/$USER/recurrences/event8@example.com/20141010T080000Z" ] \ 175 && [ -e "$STORE/$USER/cancellations/recurrences/event8@example.com/20141010T080000Z" ] \ 176 && echo "Success" \ 177 || echo "Failed" 178 179 # Re-add the cancelled instance. 180 181 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-add-person-recurring-rescheduled-instance.txt" 2>> $ERROR 182 183 grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBSENDERFILE" \ 184 && ! grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBSENDERFILE" \ 185 && echo "Success" \ 186 || echo "Failed" 187 188 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-add-person-recurring-rescheduled-instance.txt" 2>> $ERROR \ 189 | "$SHOWMAIL" \ 190 > out8.tmp 191 192 [ -e "$STORE/$USER/objects/event8@example.com" ] \ 193 && [ -e "$STORE/$USER/recurrences/event8@example.com/20141010T080000Z" ] \ 194 && ! [ -e "$STORE/$USER/cancellations/recurrences/event8@example.com/20141010T080000Z" ] \ 195 && echo "Success" \ 196 || echo "Failed" 197 198 ! grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBFILE" \ 199 && echo "Success" \ 200 || echo "Failed" 201 202 grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBOTHERFILE" \ 203 && echo "Success" \ 204 || echo "Failed" 205 206 # Test acceptance and registration in the outgoing handler. 207 208 "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" "20141010T080000Z" 2>> $ERROR \ 209 | tee out9.tmp \ 210 | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR 211 212 grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBFILE" \ 213 && echo "Success" \ 214 || echo "Failed" 215 216 # Test yet another request from an attendee for the event details to be refreshed. 217 218 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-refresh-person-recurring.txt" 2>> $ERROR \ 219 | tee out10r.tmp \ 220 | "$SHOWMAIL" \ 221 > out10.tmp 222 223 grep -q 'METHOD:REQUEST' out10.tmp \ 224 && grep -q 'RECURRENCE-ID' out10.tmp \ 225 && [ `grep 'BEGIN:VEVENT' out10.tmp | wc -l` = '2' ] \ 226 && echo "Success" \ 227 || echo "Failed" 228 229 # Process the resulting message. 230 231 "$PERSON_SCRIPT" $ARGS < out10r.tmp 2>> $ERROR \ 232 | "$SHOWMAIL" \ 233 > out11.tmp 234 235 [ -e "$STORE/$USER/objects/event8@example.com" ] \ 236 && [ -e "$STORE/$USER/recurrences/event8@example.com/20141010T080000Z" ] \ 237 && echo "Success" \ 238 || echo "Failed"