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