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