1 #!/bin/sh 2 3 . "`dirname \"$0\"`/common.sh" 4 5 USER1="mailto:resource-car-porsche911@example.com" 6 USER2="mailto:resource-car-fiat500@example.com" 7 SENDER="mailto:paul.boddie@example.com" 8 QUOTA=cars 9 10 mkdir -p "$PREFS/$USER1" 11 echo 'Europe/Oslo' > "$PREFS/$USER1/TZID" 12 echo 'share' > "$PREFS/$USER1/freebusy_sharing" 13 cat > "$PREFS/$USER1/scheduling_function" <<EOF 14 schedule_in_freebusy 15 check_quota $QUOTA 16 EOF 17 18 mkdir -p "$PREFS/$USER2" 19 echo 'Europe/Oslo' > "$PREFS/$USER2/TZID" 20 echo 'share' > "$PREFS/$USER2/freebusy_sharing" 21 cat > "$PREFS/$USER2/scheduling_function" <<EOF 22 schedule_in_freebusy 23 check_quota $QUOTA 24 EOF 25 26 "$SET_QUOTA_LIMIT" "$QUOTA" '*' 'PT1H' $SET_QUOTA_LIMIT_ARGS 27 28 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-car.txt" 2>> $ERROR \ 29 | "$SHOWMAIL" \ 30 > out0.tmp 31 32 grep -q 'METHOD:REPLY' out0.tmp \ 33 && ! grep -q '^FREEBUSY' out0.tmp \ 34 && echo "Success" \ 35 || echo "Failed" 36 37 # Attempt to schedule an event. 38 39 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR 40 41 "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ 42 | tee out0s.tmp \ 43 | grep -q "^20141126T150000Z${TAB}20141126T160000Z" \ 44 && echo "Success" \ 45 || echo "Failed" 46 47 # Present the request to the resource. 48 49 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR \ 50 | tee out1r.tmp \ 51 | "$SHOWMAIL" \ 52 > out1.tmp 53 54 grep -q 'METHOD:REPLY' out1.tmp \ 55 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out1.tmp \ 56 && echo "Success" \ 57 || echo "Failed" 58 59 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 60 | tee out1f.tmp \ 61 | grep -q "^20141126T150000Z${TAB}20141126T160000Z" \ 62 && echo "Success" \ 63 || echo "Failed" 64 65 # Check the quota (event is confirmed). 66 67 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ 68 | tee out1e.tmp \ 69 | grep -q "event21@example.com" \ 70 && echo "Success" \ 71 || echo "Failed" 72 73 # Attempt to schedule another event. 74 75 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-conflict.txt" 2>> $ERROR 76 77 "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ 78 | tee out1s.tmp \ 79 | grep -q "^20141126T153000Z${TAB}20141126T163000Z" \ 80 && echo "Success" \ 81 || echo "Failed" 82 83 # Present the request to the resource. 84 85 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-conflict.txt" 2>> $ERROR \ 86 | tee out2r.tmp \ 87 | "$SHOWMAIL" \ 88 > out2.tmp 89 90 grep -q 'METHOD:REPLY' out2.tmp \ 91 && grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out2.tmp \ 92 && echo "Success" \ 93 || echo "Failed" 94 95 "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ 96 > out2f.tmp 97 98 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out2f.tmp" \ 99 && echo "Success" \ 100 || echo "Failed" 101 102 # Check the quota (event is not confirmed). 103 104 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ 105 > out2e.tmp 106 107 grep -q "event21@example.com" "out2e.tmp" \ 108 && ! grep -q "event22@example.com" "out2e.tmp" \ 109 && echo "Success" \ 110 || echo "Failed" 111 112 # Increase the quota. 113 114 "$SET_QUOTA_LIMIT" "$QUOTA" '*' 'PT2H' $SET_QUOTA_LIMIT_ARGS 115 116 # Attempt to schedule the event again. 117 118 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-conflict.txt" 2>> $ERROR 119 120 "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ 121 | tee out2s.tmp \ 122 | grep -q "^20141126T153000Z${TAB}20141126T163000Z" \ 123 && echo "Success" \ 124 || echo "Failed" 125 126 # Present the request to the resource. 127 128 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-conflict.txt" 2>> $ERROR \ 129 | tee out3r.tmp \ 130 | "$SHOWMAIL" \ 131 > out3.tmp 132 133 grep -q 'METHOD:REPLY' out3.tmp \ 134 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out3.tmp \ 135 && echo "Success" \ 136 || echo "Failed" 137 138 "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ 139 | tee out3f.tmp \ 140 | grep -q "^20141126T153000Z${TAB}20141126T163000Z" \ 141 && echo "Success" \ 142 || echo "Failed" 143 144 # Check the quota (event is confirmed). 145 146 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ 147 > out3e.tmp 148 149 grep -q "event21@example.com" "out3e.tmp" \ 150 && grep -q "event22@example.com" "out3e.tmp" \ 151 && echo "Success" \ 152 || echo "Failed" 153 154 # Cancel the first event. 155 156 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-car.txt" 2>> $ERROR 157 158 "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ 159 > out3s.tmp 160 161 ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out3s.tmp" \ 162 && echo "Success" \ 163 || echo "Failed" 164 165 # Present the request to the resource. 166 167 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-car.txt" 2>> $ERROR \ 168 | tee out4r.tmp \ 169 | "$SHOWMAIL" \ 170 > out4.tmp 171 172 ! grep -q 'METHOD:REPLY' out4.tmp \ 173 && echo "Success" \ 174 || echo "Failed" 175 176 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 177 > out4f.tmp 178 179 ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out4f.tmp" \ 180 && echo "Success" \ 181 || echo "Failed" 182 183 # Check the quota (event is retracted). 184 185 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ 186 > out4e.tmp 187 188 ! grep -q "event21@example.com" "out4e.tmp" \ 189 && grep -q "event22@example.com" "out4e.tmp" \ 190 && echo "Success" \ 191 || echo "Failed" 192 193 # Add collective scheduling tests. 194 195 cat > "$PREFS/$USER1/scheduling_function" <<EOF 196 schedule_in_freebusy 197 schedule_across_quota $QUOTA 198 check_quota $QUOTA 199 EOF 200 201 cat > "$PREFS/$USER2/scheduling_function" <<EOF 202 schedule_in_freebusy 203 schedule_across_quota $QUOTA 204 check_quota $QUOTA 205 EOF 206 207 # Remind the resource about the second event. 208 209 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-conflict.txt" 2>> $ERROR \ 210 | tee out5r.tmp \ 211 | "$SHOWMAIL" \ 212 > out5.tmp 213 214 grep -q 'METHOD:REPLY' out5.tmp \ 215 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out5.tmp \ 216 && echo "Success" \ 217 || echo "Failed" 218 219 "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ 220 | tee out5f.tmp \ 221 | grep -q "^20141126T153000Z${TAB}20141126T163000Z" \ 222 && echo "Success" \ 223 || echo "Failed" 224 225 # Check the quota (event is still confirmed). 226 227 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ 228 > out5e.tmp 229 230 ! grep -q "event21@example.com" "out5e.tmp" \ 231 && grep -q "event22@example.com" "out5e.tmp" \ 232 && echo "Success" \ 233 || echo "Failed" 234 235 # Attempt to schedule the first event. 236 237 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR 238 239 "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ 240 | tee out5s.tmp \ 241 | grep -q "^20141126T150000Z${TAB}20141126T160000Z" \ 242 && echo "Success" \ 243 || echo "Failed" 244 245 # Present the request to the resource. 246 247 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR \ 248 | tee out6r.tmp \ 249 | "$SHOWMAIL" \ 250 > out6.tmp 251 252 grep -q 'METHOD:REPLY' out6.tmp \ 253 && grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out6.tmp \ 254 && echo "Success" \ 255 || echo "Failed" 256 257 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 258 > out6f.tmp 259 260 ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out6f.tmp" \ 261 && echo "Success" \ 262 || echo "Failed" 263 264 # Check the quota (event is still retracted and not newly confirmed). 265 266 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ 267 > out6e.tmp 268 269 ! grep -q "event21@example.com" "out6e.tmp" \ 270 && grep -q "event22@example.com" "out6e.tmp" \ 271 && echo "Success" \ 272 || echo "Failed" 273 274 # Attempt to schedule the first event moved earlier. 275 276 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-moved.txt" 2>> $ERROR 277 278 "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ 279 > out6s.tmp 280 281 ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out6s.tmp" \ 282 && grep -q "^20141126T143000Z${TAB}20141126T153000Z" "out6s.tmp" \ 283 && echo "Success" \ 284 || echo "Failed" 285 286 # Present the request to the resource. 287 288 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-moved.txt" 2>> $ERROR \ 289 | tee out7r.tmp \ 290 | "$SHOWMAIL" \ 291 > out7.tmp 292 293 grep -q 'METHOD:REPLY' out7.tmp \ 294 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out7.tmp \ 295 && echo "Success" \ 296 || echo "Failed" 297 298 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 299 | tee out7f.tmp \ 300 | grep -q "^20141126T143000Z${TAB}20141126T153000Z" \ 301 && echo "Success" \ 302 || echo "Failed" 303 304 # Check the quota (event is newly confirmed). 305 306 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ 307 > out7e.tmp 308 309 grep -q "event21@example.com" "out7e.tmp" \ 310 && grep -q "event22@example.com" "out7e.tmp" \ 311 && echo "Success" \ 312 || echo "Failed" 313 314 # Increase the quota. 315 316 "$SET_QUOTA_LIMIT" "$QUOTA" '*' 'PT3H' $SET_QUOTA_LIMIT_ARGS 317 318 # Attempt to schedule an event involving both resources. 319 320 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-cars.txt" 2>> $ERROR 321 322 "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ 323 | tee out7s.tmp \ 324 | grep -q "^20141127T150000Z${TAB}20141127T160000Z" \ 325 && echo "Success" \ 326 || echo "Failed" 327 328 # Present the request to both resources. 329 330 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-cars.txt" 2>> $ERROR \ 331 | tee out8r.tmp \ 332 | "$SHOWMAIL" \ 333 > out8.tmp 334 335 # Since the email module used by showmail.py cannot stop after reading a single 336 # message, the second message is obtained. 337 338 grep -n '^From ' out8r.tmp \ 339 | tail -n 1 \ 340 | cut -d ':' -f 1 \ 341 | xargs -I{} tail -n +'{}' out8r.tmp \ 342 | "$SHOWMAIL" \ 343 >> out8.tmp 344 345 grep -q 'METHOD:REPLY' out8.tmp \ 346 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out8.tmp \ 347 && grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out8.tmp \ 348 && echo "Success" \ 349 || echo "Failed" 350 351 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 352 > out8f.tmp 353 354 "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ 355 > out8f2.tmp 356 357 ( grep -q "^20141127T150000Z${TAB}20141127T160000Z" "out8f.tmp" \ 358 && ! grep -q "^20141127T150000Z${TAB}20141127T160000Z" "out8f2.tmp" ) \ 359 || ( ! grep -q "^20141127T150000Z${TAB}20141127T160000Z" "out8f.tmp" \ 360 && grep -q "^20141127T150000Z${TAB}20141127T160000Z" "out8f2.tmp" ) \ 361 && echo "Success" \ 362 || echo "Failed" 363 364 # Check the quota (event is confirmed, but only for one resource). 365 366 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ 367 | tee out8e.tmp \ 368 | grep -q "event23@example.com" \ 369 && echo "Success" \ 370 || echo "Failed"