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 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 | "$SHOWMAIL" \ 117 > out6.tmp 118 119 grep -q 'METHOD:REQUEST' out6.tmp \ 120 && grep -q 'RECURRENCE-ID' out6.tmp \ 121 && [ `grep 'BEGIN:VEVENT' out6.tmp | wc -l` = '2' ] \ 122 && echo "Success" \ 123 || echo "Failed" 124 125 # Process the resulting message. 126 127 "$PERSON_SCRIPT" $ARGS < out6.tmp 2>> $ERROR \ 128 | "$SHOWMAIL" \ 129 > out6a.tmp 130 131 [ -e "$STORE/$USER/objects/event8@example.com" ] \ 132 && [ -e "$STORE/$USER/recurrences/event8@example.com/20141010T080000Z" ] \ 133 && echo "Success" \ 134 || echo "Failed" 135 136 # Cancel a recurrence. Both the original and rescheduled recurrences should be 137 # absent from the free/busy collection. 138 139 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring-rescheduled-instance.txt" 2>> $ERROR 140 141 [ -e "$STORE/$SENDER/objects/event8@example.com" ] \ 142 && ! [ -e "$STORE/$SENDER/recurrences/event8@example.com/20141010T080000Z" ] \ 143 && [ -e "$STORE/$SENDER/cancellations/recurrences/event8@example.com/20141010T080000Z" ] \ 144 && echo "Success" \ 145 || echo "Failed" 146 147 ! grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBSENDERFILE" \ 148 && ! grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBSENDERFILE" \ 149 && echo "Success" \ 150 || echo "Failed" 151 152 # Test another request from an attendee for the event details to be refreshed. 153 # The additional recurrence should now be absent. 154 155 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-refresh-person-recurring.txt" 2>> $ERROR \ 156 | tee out7r.tmp \ 157 | "$SHOWMAIL" \ 158 > out7.tmp 159 160 grep -q 'METHOD:REQUEST' out7.tmp \ 161 && grep -q 'METHOD:CANCEL' out7.tmp \ 162 && [ `grep 'BEGIN:VEVENT' out7.tmp | wc -l` = '2' ] \ 163 && echo "Success" \ 164 || echo "Failed" 165 166 # Process the resulting message. 167 168 "$PERSON_SCRIPT" $ARGS < out7r.tmp 2>> $ERROR \ 169 | "$SHOWMAIL" \ 170 > out7a.tmp 171 172 [ -e "$STORE/$USER/objects/event8@example.com" ] \ 173 && ! [ -e "$STORE/$USER/recurrences/event8@example.com/20141010T080000Z" ] \ 174 && [ -e "$STORE/$USER/cancellations/recurrences/event8@example.com/20141010T080000Z" ] \ 175 && echo "Success" \ 176 || echo "Failed" 177 178 # Re-add the cancelled instance. 179 180 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-add-person-recurring-rescheduled-instance.txt" 2>> $ERROR 181 182 grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBSENDERFILE" \ 183 && ! grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBSENDERFILE" \ 184 && echo "Success" \ 185 || echo "Failed" 186 187 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-add-person-recurring-rescheduled-instance.txt" 2>> $ERROR \ 188 | "$SHOWMAIL" \ 189 > out8.tmp 190 191 [ -e "$STORE/$USER/objects/event8@example.com" ] \ 192 && [ -e "$STORE/$USER/recurrences/event8@example.com/20141010T080000Z" ] \ 193 && ! [ -e "$STORE/$USER/cancellations/recurrences/event8@example.com/20141010T080000Z" ] \ 194 && echo "Success" \ 195 || echo "Failed" 196 197 ! grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBFILE" \ 198 && echo "Success" \ 199 || echo "Failed" 200 201 grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBOTHERFILE" \ 202 && echo "Success" \ 203 || echo "Failed" 204 205 # Test acceptance and registration in the outgoing handler. 206 207 "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" "20141010T080000Z" 2>> $ERROR \ 208 | tee out9.tmp \ 209 | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR 210 211 grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBFILE" \ 212 && echo "Success" \ 213 || echo "Failed"