1 #!/bin/sh 2 3 . "`dirname \"$0\"`/common.sh" 4 5 USER="mailto:resource-room-sauna@example.com" 6 SENDER="mailto:paul.boddie@example.com" 7 RIVALSENDER="mailto:vincent.vole@example.com" 8 FBFILE="$STORE/$USER/freebusy" 9 FBOTHERFILE="$STORE/$USER/freebusy-other/$SENDER" 10 FBOFFERFILE="$STORE/$USER/freebusy-offers" 11 FBSENDERFILE="$STORE/$SENDER/freebusy" 12 FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER" 13 FBSENDERREQUESTS="$STORE/$SENDER/requests" 14 FBRIVALSENDERFILE="$STORE/$RIVALSENDER/freebusy" 15 16 mkdir -p "$PREFS/$USER" 17 echo 'Europe/Oslo' > "$PREFS/$USER/TZID" 18 echo 'share' > "$PREFS/$USER/freebusy_sharing" 19 echo 'schedule_next_available_in_freebusy' > "$PREFS/$USER/scheduling_function" 20 echo 'PT60S' > "$PREFS/$USER/freebusy_offers" 21 22 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \ 23 | "$SHOWMAIL" \ 24 > out0.tmp 25 26 grep -q 'METHOD:REPLY' out0.tmp \ 27 && ! grep -q '^FREEBUSY' out0.tmp \ 28 && echo "Success" \ 29 || echo "Failed" 30 31 # Let the rival sender book the resource. 32 33 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-busy.txt" 2>> $ERROR 34 35 [ `grep "event19@example.com" "$FBRIVALSENDERFILE" | wc -l` = '5' ] \ 36 && grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBRIVALSENDERFILE" \ 37 && echo "Success" \ 38 || echo "Failed" 39 40 # Present the request to the resource. 41 42 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-busy.txt" 2>> $ERROR \ 43 | tee out1r.tmp \ 44 | "$SHOWMAIL" \ 45 > out1.tmp 46 47 grep -q 'METHOD:REPLY' out1.tmp \ 48 && grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T160000' out1.tmp \ 49 && echo "Success" \ 50 || echo "Failed" 51 52 [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \ 53 && grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ 54 && echo "Success" \ 55 || echo "Failed" 56 57 # Present the response to the rival sender. 58 59 "$PERSON_SCRIPT" $ARGS < out1r.tmp 2>> $ERROR \ 60 | tee out2r.tmp \ 61 | "$SHOWMAIL" \ 62 > out2.tmp 63 64 # Publish some conflicting periods as busy. 65 66 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-publish-conflicts.txt" 2>> $ERROR \ 67 | "$SHOWMAIL" \ 68 > out3.tmp 69 70 grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBOTHERFILE" \ 71 && grep -q "^20141126T180000Z${TAB}20141126T190000Z" "$FBOTHERFILE" \ 72 && echo "Success" \ 73 || echo "Failed" 74 75 # Attempt to schedule an event with the resource. 76 77 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR 78 79 grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ 80 && echo "Success" \ 81 || echo "Failed" 82 83 # Present the request to the resource. This should cause the event to be 84 # proposed not just after the requested period, but also after the busy periods 85 # published to the resource. 86 87 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR \ 88 | tee out6r.tmp \ 89 | "$SHOWMAIL" \ 90 > out6.tmp 91 92 grep -q 'METHOD:COUNTER' out6.tmp \ 93 && ! grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out6.tmp \ 94 && echo "Success" \ 95 || echo "Failed" 96 97 ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ 98 && ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \ 99 && ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "$FBOFFERFILE" \ 100 && ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "$FBOFFERFILE" \ 101 && ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "$FBOFFERFILE" \ 102 && grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBOFFERFILE" \ 103 && echo "Success" \ 104 || echo "Failed" 105 106 # Present the response to the organiser. 107 108 "$PERSON_SCRIPT" $ARGS < out6r.tmp 2>> $ERROR \ 109 | tee out7r.tmp \ 110 | "$SHOWMAIL" \ 111 > out7.tmp 112 113 grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ 114 && ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBSENDERFILE" \ 115 && echo "Success" \ 116 || echo "Failed" 117 118 [ -e "$STORE/$SENDER/counters/objects/event13@example.com/$USER" ] \ 119 && echo "Success" \ 120 || echo "Failed" 121 122 grep -q 'event13@example.com' "$FBSENDERREQUESTS" \ 123 && echo "Success" \ 124 || echo "Failed" 125 126 # Reschedule the event by accepting the counter-proposal. 127 128 sed 's/COUNTER/REQUEST/' < out6.tmp \ 129 | sed 's/^From: calendar/To: resource-room-sauna/' \ 130 | sed 's/^To: paul.boddie/From: paul.boddie/' \ 131 > out8.tmp 132 133 "$OUTGOING_SCRIPT" $ARGS < out8.tmp 2>> $ERROR 134 135 ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ 136 && grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBSENDERFILE" \ 137 && echo "Success" \ 138 || echo "Failed" 139 140 ! [ -e "$STORE/$SENDER/counters/objects/event13@example.com/$USER" ] \ 141 && echo "Success" \ 142 || echo "Failed" 143 144 ! grep -q 'event13@example.com' "$FBSENDERREQUESTS" \ 145 && echo "Success" \ 146 || echo "Failed" 147 148 "$RESOURCE_SCRIPT" $ARGS < out8.tmp 2>> $ERROR \ 149 | "$SHOWMAIL" \ 150 > out9.tmp 151 152 grep -q 'METHOD:REPLY' out9.tmp \ 153 && grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T210000' out9.tmp \ 154 && echo "Success" \ 155 || echo "Failed" 156 157 ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ 158 && ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \ 159 && ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "$FBOFFERFILE" \ 160 && ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "$FBOFFERFILE" \ 161 && ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "$FBOFFERFILE" \ 162 && ! grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBOFFERFILE" \ 163 && echo "Success" \ 164 || echo "Failed" 165 166 [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \ 167 && [ `grep "event13@example.com" "$FBFILE" | wc -l` = '1' ] \ 168 && grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBFILE" \ 169 && echo "Success" \ 170 || echo "Failed" 171 172 # Test updating the event to see if the resource can handle this. 173 174 "$RESOURCE_SCRIPT" $ARGS < out8.tmp 2>> $ERROR \ 175 | "$SHOWMAIL" \ 176 > out10.tmp 177 178 grep -q 'METHOD:REPLY' out10.tmp \ 179 && grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T210000' out10.tmp \ 180 && echo "Success" \ 181 || echo "Failed" 182 183 ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ 184 && ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \ 185 && ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "$FBOFFERFILE" \ 186 && ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "$FBOFFERFILE" \ 187 && ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "$FBOFFERFILE" \ 188 && ! grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBOFFERFILE" \ 189 && echo "Success" \ 190 || echo "Failed" 191 192 [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \ 193 && [ `grep "event13@example.com" "$FBFILE" | wc -l` = '1' ] \ 194 && grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBFILE" \ 195 && echo "Success" \ 196 || echo "Failed" 197 198 # Test scheduling again with a different period. This should disregard the 199 # existing event periods when computing availability in order to be able to 200 # offer them again. Otherwise, an offer would be made for even later periods. 201 202 sed 's/20141126T160000/20141126T161500/' < "$TEMPLATES/event-request-sauna-good.txt" \ 203 | tee out11.tmp \ 204 | "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \ 205 | "$SHOWMAIL" \ 206 > out12.tmp 207 208 grep -q 'METHOD:COUNTER' out12.tmp \ 209 && grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T210000' out12.tmp \ 210 && echo "Success" \ 211 || echo "Failed" 212 213 # Note that the duration is different now. 214 215 ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ 216 && ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \ 217 && ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "$FBOFFERFILE" \ 218 && ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "$FBOFFERFILE" \ 219 && ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "$FBOFFERFILE" \ 220 && grep -q "^20141126T200000Z${TAB}20141126T203000Z" "$FBOFFERFILE" \ 221 && echo "Success" \ 222 || echo "Failed" 223 224 [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \ 225 && [ `grep "event13@example.com" "$FBFILE" | wc -l` = '1' ] \ 226 && grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBFILE" \ 227 && echo "Success" \ 228 || echo "Failed"