2015-10-17 | Paul Boddie | raw annotate files changeset graph | Consolidated descriptions of events for both REFRESH requests and for messages sent by the manager, bundling the necessary REQUEST and CANCEL payloads to describe events and their recurrences. Changed organiser-sent messages in the manager to be also sent to the user's own address, not the people-outgoing version of that address, adding support for self-sent CANCEL messages in the person handler. Added the removal of cancelled recurrences to restore periods in events edited in the manager. Otherwise, such periods can never be restored. Expanded the REFRESH method tests. |
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 FBOFFERFILE="$STORE/$USER/freebusy-offers" 16 FBSENDERFILE="$STORE/$SENDER/freebusy" 17 FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER" 18 FBSENDERREQUESTS="$STORE/$SENDER/requests" 19 TAB=`printf '\t'` 20 21 OUTGOING_SCRIPT="$THIS_DIR/../imip_person_outgoing.py" 22 23 PYTHONPATH="$THIS_DIR/.." 24 export PYTHONPATH 25 26 ACCEPT_SCRIPT="$THIS_DIR/test_handle.py" 27 ACCEPT_ARGS="accept $STORE" 28 29 COUNTER_SCRIPT="$THIS_DIR/test_handle.py" 30 COUNTER_ARGS="counter $STORE" 31 32 DECLINE_SCRIPT="$THIS_DIR/test_handle.py" 33 DECLINE_ARGS="decline $STORE" 34 35 ERROR=err.tmp 36 37 rm -r $STORE 38 rm -r $STATIC 39 rm -r $PREFS 40 rm $ERROR 41 rm out*.tmp 42 43 mkdir -p "$PREFS/$USER" 44 echo 'Europe/Oslo' > "$PREFS/$USER/TZID" 45 echo 'share' > "$PREFS/$USER/freebusy_sharing" 46 echo 'PT60S' > "$PREFS/$USER/freebusy_offers" 47 48 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \ 49 | "$SHOWMAIL" \ 50 > out0.tmp 51 52 grep -q 'METHOD:REPLY' out0.tmp \ 53 && ! grep -q '^FREEBUSY' out0.tmp \ 54 && echo "Success" \ 55 || echo "Failed" 56 57 # Attempt to schedule an event. 58 59 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person.txt" 2>> $ERROR 60 61 grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE" \ 62 && echo "Success" \ 63 || echo "Failed" 64 65 # Present the request to the recipient. 66 67 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person.txt" 2>> $ERROR \ 68 | "$SHOWMAIL" \ 69 > out1.tmp 70 71 ! grep -q 'METHOD:REPLY' out1.tmp \ 72 && echo "Success" \ 73 || echo "Failed" 74 75 ! [ -e "$FBFILE" ] \ 76 || ! grep -q "event6@example.com" "$FBFILE" \ 77 && echo "Success" \ 78 || echo "Failed" 79 80 ! [ -e "$FBOTHERFILE" ] \ 81 || ! grep -q "event6@example.com" "$FBOTHERFILE" \ 82 && echo "Success" \ 83 || echo "Failed" 84 85 # Counter the invitation. 86 87 "$COUNTER_SCRIPT" $COUNTER_ARGS "$USER" 20141126T170000 20141126T180000 "event6@example.com" 2>> $ERROR \ 88 | tee out2r.tmp \ 89 | "$SHOWMAIL" \ 90 > out2.tmp 91 92 # Note that the invitation has only been prepared, not processed. 93 94 ! [ -e "$FBFILE" ] \ 95 || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ 96 && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBFILE" ) \ 97 && echo "Success" \ 98 || echo "Failed" 99 100 grep -q 'METHOD:COUNTER' out2.tmp \ 101 && grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' out2.tmp \ 102 && echo "Success" \ 103 || echo "Failed" 104 105 ! [ -e "$FBOFFERFILE" ] \ 106 || ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBOFFERFILE" \ 107 && echo "Success" \ 108 || echo "Failed" 109 110 # Send the counter-proposal. 111 112 "$OUTGOING_SCRIPT" $ARGS < out2r.tmp 2>> $ERROR 113 114 ! [ -e "$FBFILE" ] \ 115 || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ 116 && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBFILE" ) \ 117 && echo "Success" \ 118 || echo "Failed" 119 120 grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBOFFERFILE" \ 121 && echo "Success" \ 122 || echo "Failed" 123 124 # Present the response to the organiser. 125 126 "$PERSON_SCRIPT" $ARGS < out2r.tmp 2>> $ERROR \ 127 | tee out3r.tmp \ 128 | "$SHOWMAIL" \ 129 > out3.tmp 130 131 ! [ -e "$FBSENDEROTHERFILE" ] \ 132 || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDEROTHERFILE" \ 133 && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBSENDEROTHERFILE" ) \ 134 && echo "Success" \ 135 || echo "Failed" 136 137 grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' "$STORE/$SENDER/objects/event6@example.com" \ 138 && grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T160000' "$STORE/$SENDER/objects/event6@example.com" \ 139 && echo "Success" \ 140 || echo "Failed" 141 142 grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' "$STORE/$SENDER/counters/objects/event6@example.com/$USER" \ 143 && echo "Success" \ 144 || echo "Failed" 145 146 grep -q 'event6@example.com' "$FBSENDERREQUESTS" \ 147 && echo "Success" \ 148 || echo "Failed" 149 150 # Check the free/busy state of the recipient so far. 151 152 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \ 153 | "$SHOWMAIL" \ 154 > out4.tmp 155 156 grep -q 'METHOD:REPLY' out4.tmp \ 157 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T150000Z/20141126T160000Z' out4.tmp \ 158 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T160000Z/20141126T170000Z' out4.tmp \ 159 && echo "Success" \ 160 || echo "Failed" 161 162 # Decline the counter-proposal. 163 164 sed 's/COUNTER/DECLINECOUNTER/' < out2.tmp \ 165 | sed 's/^From: calendar/To: vincent.vole/' \ 166 | sed 's/^To: paul.boddie/From: paul.boddie/' \ 167 > out5.tmp 168 169 "$OUTGOING_SCRIPT" $ARGS < out5.tmp 2>> $ERROR 170 171 ! [ -e "$STORE/$SENDER/counters/objects/event6@example.com/$USER" ] \ 172 && echo "Success" \ 173 || echo "Failed" 174 175 ! grep -q 'event6@example.com' "$FBSENDERREQUESTS" \ 176 && echo "Success" \ 177 || echo "Failed" 178 179 "$PERSON_SCRIPT" $ARGS < out5.tmp 2>> $ERROR \ 180 | "$SHOWMAIL" \ 181 > out6.tmp 182 183 ! [ -e "$FBFILE" ] \ 184 || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ 185 && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBFILE" ) \ 186 && echo "Success" \ 187 || echo "Failed" 188 189 ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBOFFERFILE" \ 190 && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBOFFERFILE" \ 191 && echo "Success" \ 192 || echo "Failed"