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 SENDER1="mailto:paul.boddie@example.com" 8 SENDER2="mailto:vincent.vole@example.com" 9 USER1ADDRESS="resource-car-porsche911@example.com" 10 USER2ADDRESS="resource-car-fiat500@example.com" 11 SENDER1ADDRESS="paul.boddie@example.com" 12 SENDER2ADDRESS="vincent.vole@example.com" 13 QUOTA=cars 14 OTHER_QUOTA=rooms 15 16 mkdir -p "$PREFS/$USER1" 17 echo 'Europe/Oslo' > "$PREFS/$USER1/TZID" 18 echo 'share' > "$PREFS/$USER1/freebusy_sharing" 19 cat > "$PREFS/$USER1/scheduling_function" <<EOF 20 schedule_for_delegate $QUOTA most-available 21 EOF 22 23 mkdir -p "$PREFS/$USER2" 24 echo 'Europe/Oslo' > "$PREFS/$USER2/TZID" 25 echo 'share' > "$PREFS/$USER2/freebusy_sharing" 26 cat > "$PREFS/$USER2/scheduling_function" <<EOF 27 schedule_for_delegate $QUOTA most-available 28 EOF 29 30 # Have a common group for all organisers when scheduling. 31 32 cat <<EOF | "$SET_QUOTA_GROUPS" "$QUOTA" $SET_QUOTA_GROUPS_ARGS 33 * all 34 EOF 35 36 # Set a common quota. 37 38 cat <<EOF | "$SET_QUOTA_LIMITS" "$QUOTA" $SET_QUOTA_LIMITS_ARGS 39 all * 40 EOF 41 42 # Allow cars to delegate to each other. 43 44 cat <<EOF | "$SET_DELEGATES" "$QUOTA" $SET_DELEGATES_ARGS 45 mailto:resource-car-porsche911@example.com 46 mailto:resource-car-fiat500@example.com 47 EOF 48 49 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-car.txt" 2>> $ERROR \ 50 | "$SHOWMAIL" \ 51 > out0.tmp 52 53 grep -q 'METHOD:REPLY' out0.tmp \ 54 && ! grep -q '^FREEBUSY' out0.tmp \ 55 && echo "Success" \ 56 || echo "Failed" 57 58 # Attempt to schedule an event. 59 60 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR 61 62 "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \ 63 | tee out0s.tmp \ 64 | grep -q "^20141126T150000Z${TAB}20141126T160000Z" \ 65 && echo "Success" \ 66 || echo "Failed" 67 68 # Present the request to the resource. 69 70 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR \ 71 | tee out1r.tmp \ 72 | "$SHOWMAIL" \ 73 > out1.tmp 74 75 grep -q 'METHOD:REPLY' out1.tmp \ 76 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out1.tmp \ 77 && echo "Success" \ 78 || echo "Failed" 79 80 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 81 | tee out1f.tmp \ 82 | grep -q "^20141126T150000Z${TAB}20141126T160000Z" \ 83 && echo "Success" \ 84 || echo "Failed" 85 86 # Check the quota (event is confirmed). 87 88 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "all" \ 89 | tee out1e.tmp \ 90 | grep -q "event21@example.com" \ 91 && echo "Success" \ 92 || echo "Failed" 93 94 # Attempt to schedule another event. 95 96 sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=5/;' "$TEMPLATES/event-request-cars-recurring.txt" \ 97 | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR 98 99 "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \ 100 > out2s.tmp 101 102 grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2s.tmp" \ 103 && grep -q "event21@example.com" "out2s.tmp" \ 104 && grep -q "event25@example.com" "out2s.tmp" \ 105 && echo "Success" \ 106 || echo "Failed" 107 108 # Present the request to the recipients. 109 110 sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=5/;' "$TEMPLATES/event-request-cars-recurring.txt" \ 111 | "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \ 112 > out2r.tmp 113 114 "$SHOWMAIL" < "out2r.tmp" \ 115 > out2p0.tmp 116 117 "$SHOWMAIL" 1 < "out2r.tmp" \ 118 > out2p1.tmp 119 120 grep -q 'METHOD:REPLY' out2p0.tmp \ 121 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out2p0.tmp \ 122 && echo "Success" \ 123 || echo "Failed" 124 125 grep -q 'METHOD:REPLY' out2p1.tmp \ 126 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out2p1.tmp \ 127 && echo "Success" \ 128 || echo "Failed" 129 130 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 131 > out2f0.tmp 132 133 grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f0.tmp" \ 134 && grep -q "event21@example.com" "out2f0.tmp" \ 135 && grep -q "event25@example.com" "out2f0.tmp" \ 136 && echo "Success" \ 137 || echo "Failed" 138 139 "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ 140 > out2f1.tmp 141 142 grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f1.tmp" \ 143 && grep -q "event25@example.com" "out2f1.tmp" \ 144 && echo "Success" \ 145 || echo "Failed" 146 147 # Check the quota (event is confirmed). 148 149 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "all" \ 150 | tee out2e.tmp \ 151 | grep -q "event25@example.com" \ 152 && echo "Success" \ 153 || echo "Failed" 154 155 # Attempt to schedule another event. 156 157 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-delegating.txt" 2>> $ERROR 158 159 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy" \ 160 | tee out3s.tmp \ 161 | grep -q "^20141126T153000Z${TAB}20141126T163000Z" \ 162 && echo "Success" \ 163 || echo "Failed" 164 165 # Present the request to the resource. 166 167 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-delegating.txt" 2>> $ERROR \ 168 > out3r.tmp 169 170 "$SHOWMAIL" < out3r.tmp \ 171 > out3p0.tmp 172 173 "$SHOWMAIL" 1 < out3r.tmp \ 174 > out3p1.tmp 175 176 if grep -q "To: $SENDER2ADDRESS" out3p0.tmp ; then 177 ORGFN=out3p0.tmp ; DELFN=out3p1.tmp 178 else 179 ORGFN=out3p1.tmp ; DELFN=out3p0.tmp 180 fi 181 182 # One of the responses will be a request sent to the delegate. 183 184 grep -q "To: $USER2ADDRESS" "$DELFN" \ 185 && grep -q 'METHOD:REQUEST' "$DELFN" \ 186 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$DELFN" \ 187 && grep -q 'ATTENDEE.*:'"$USER2" "$DELFN" \ 188 && echo "Success" \ 189 || echo "Failed" 190 191 # The other will be a reply to the organiser. 192 193 grep -q "To: $SENDER2ADDRESS" "$ORGFN" \ 194 && grep -q 'METHOD:REPLY' "$ORGFN" \ 195 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$ORGFN" \ 196 && grep -q 'ATTENDEE.*:'"$USER2" "$ORGFN" \ 197 && echo "Success" \ 198 || echo "Failed" 199 200 # Neither the delegator or the delegate will have changed their schedules. 201 202 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 203 > out4f1.tmp 204 205 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out4f1.tmp" \ 206 && echo "Success" \ 207 || echo "Failed" 208 209 "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ 210 > out4f2.tmp 211 212 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out4f2.tmp" \ 213 && echo "Success" \ 214 || echo "Failed" 215 216 # Check the quota (event is not confirmed). 217 218 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "all" \ 219 > out4e.tmp 220 221 grep -q "event21@example.com" "out4e.tmp" \ 222 && grep -q "event25@example.com" "out4e.tmp" \ 223 && ! grep -q "event27@example.com" "out4e.tmp" \ 224 && echo "Success" \ 225 || echo "Failed" 226 227 # Present the reply to the organiser. 228 229 "$PERSON_SCRIPT" $ARGS < "$ORGFN" 2>> "$ERROR" \ 230 | tee out5r.tmp \ 231 | "$SHOWMAIL" \ 232 > out5.tmp 233 234 # Check the free/busy status of the attendees at the organiser. 235 # Currently, neither are attending. 236 237 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER1" \ 238 > out5s0.tmp \ 239 240 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out5s0.tmp \ 241 && echo "Success" \ 242 || echo "Failed" 243 244 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER2" \ 245 > out5s1.tmp \ 246 247 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out5s1.tmp \ 248 && echo "Success" \ 249 || echo "Failed" 250 251 # Present the request to the delegate. 252 253 "$RESOURCE_SCRIPT" $ARGS < "$DELFN" 2>> "$ERROR" \ 254 > out6r.tmp 255 256 "$SHOWMAIL" < out6r.tmp \ 257 > out6p0.tmp 258 259 "$SHOWMAIL" 1 < out6r.tmp \ 260 > out6p1.tmp 261 262 if grep -q "To: $SENDER2ADDRESS" out6p0.tmp ; then 263 ORGFN=out6p0.tmp ; DELFN=out6p1.tmp 264 else 265 ORGFN=out6p1.tmp ; DELFN=out6p0.tmp 266 fi 267 268 # One of the responses will be a reply sent to the organiser. 269 270 grep -q "To: $SENDER2ADDRESS" "$ORGFN" \ 271 && grep -q 'METHOD:REPLY' "$ORGFN" \ 272 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$ORGFN" \ 273 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED.*:'"$USER2" "$ORGFN" \ 274 && echo "Success" \ 275 || echo "Failed" 276 277 # The other will be a reply to the delegator. 278 279 grep -q "To: $USER1ADDRESS" "$DELFN" \ 280 && grep -q 'METHOD:REPLY' "$DELFN" \ 281 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$DELFN" \ 282 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED.*:'"$USER2" "$DELFN" \ 283 && echo "Success" \ 284 || echo "Failed" 285 286 # The delegate should now have a changed schedule. 287 288 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 289 > out7f0.tmp 290 291 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out7f0.tmp" \ 292 && echo "Success" \ 293 || echo "Failed" 294 295 "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ 296 > out7f1.tmp 297 298 grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out7f1.tmp" \ 299 && grep -q "event27@example.com" "out7f1.tmp" \ 300 && echo "Success" \ 301 || echo "Failed" 302 303 # Present the reply to the organiser. 304 305 "$PERSON_SCRIPT" $ARGS < "$ORGFN" 2>> "$ERROR" \ 306 | tee out8r.tmp \ 307 | "$SHOWMAIL" \ 308 > out8.tmp 309 310 # Check the free/busy status of the attendees at the organiser. 311 # Now, the delegate is attending. 312 313 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER1" \ 314 > out8s0.tmp \ 315 316 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out8s0.tmp \ 317 && ! grep -q "event27@example.com" out8s0.tmp \ 318 && echo "Success" \ 319 || echo "Failed" 320 321 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER2" \ 322 > out8s1.tmp \ 323 324 grep -q "^20141126T153000Z${TAB}20141126T163000Z" out8s1.tmp \ 325 && grep -q "event27@example.com" out8s1.tmp \ 326 && echo "Success" \ 327 || echo "Failed" 328 329 # Present the reply to the delegator. 330 331 "$RESOURCE_SCRIPT" $ARGS < "$DELFN" 2>> "$ERROR" \ 332 > out9r.tmp