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 21 schedule_in_freebusy 22 EOF 23 24 mkdir -p "$PREFS/$USER2" 25 echo 'Europe/Oslo' > "$PREFS/$USER2/TZID" 26 echo 'share' > "$PREFS/$USER2/freebusy_sharing" 27 cat > "$PREFS/$USER2/scheduling_function" <<EOF 28 schedule_for_delegate $QUOTA 29 schedule_in_freebusy 30 EOF 31 32 # Have a common group for all organisers when scheduling. 33 34 cat <<EOF | "$SET_QUOTA_GROUPS" "$QUOTA" $SET_QUOTA_GROUPS_ARGS 35 * all 36 EOF 37 38 # Set a common quota. 39 40 cat <<EOF | "$SET_QUOTA_LIMITS" "$QUOTA" $SET_QUOTA_LIMITS_ARGS 41 all * 42 EOF 43 44 # Allow cars to delegate to each other. 45 46 cat <<EOF | "$SET_DELEGATES" "$QUOTA" $SET_DELEGATES_ARGS 47 mailto:resource-car-porsche911@example.com 48 mailto:resource-car-fiat500@example.com 49 EOF 50 51 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-car.txt" 2>> $ERROR \ 52 | "$SHOWMAIL" \ 53 > out0.tmp 54 55 grep -q 'METHOD:REPLY' out0.tmp \ 56 && ! grep -q '^FREEBUSY' out0.tmp \ 57 && echo "Success" \ 58 || echo "Failed" 59 60 # Attempt to schedule an event. 61 62 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR 63 64 "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \ 65 | tee out0s.tmp \ 66 | grep -q "^20141126T150000Z${TAB}20141126T160000Z" \ 67 && echo "Success" \ 68 || echo "Failed" 69 70 # Present the request to the resource. 71 72 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR \ 73 | tee out1r.tmp \ 74 | "$SHOWMAIL" \ 75 > out1.tmp 76 77 grep -q 'METHOD:REPLY' out1.tmp \ 78 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out1.tmp \ 79 && echo "Success" \ 80 || echo "Failed" 81 82 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 83 | tee out1f.tmp \ 84 | grep -q "^20141126T150000Z${TAB}20141126T160000Z" \ 85 && echo "Success" \ 86 || echo "Failed" 87 88 # Check the quota (event is confirmed). 89 90 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "all" \ 91 | tee out1e.tmp \ 92 | grep -q "event21@example.com" \ 93 && echo "Success" \ 94 || echo "Failed" 95 96 # Attempt to schedule another event. 97 98 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-delegating.txt" 2>> $ERROR 99 100 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy" \ 101 | tee out1s.tmp \ 102 | grep -q "^20141126T153000Z${TAB}20141126T163000Z" \ 103 && echo "Success" \ 104 || echo "Failed" 105 106 # Present the request to the resource. 107 108 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-delegating.txt" 2>> $ERROR \ 109 > out2r.tmp 110 111 "$SHOWMAIL" < out2r.tmp \ 112 > out2p0.tmp 113 114 "$SHOWMAIL" 1 < out2r.tmp \ 115 > out2p1.tmp 116 117 if grep -q "To: $SENDER2ADDRESS" out2p0.tmp ; then 118 ORGFN=out2p0.tmp ; DELFN=out2p1.tmp 119 else 120 ORGFN=out2p1.tmp ; DELFN=out2p0.tmp 121 fi 122 123 # One of the responses will be a request sent to the delegate. 124 125 grep -q "To: $USER2ADDRESS" "$DELFN" \ 126 && grep -q 'METHOD:REQUEST' "$DELFN" \ 127 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$DELFN" \ 128 && grep -q 'ATTENDEE.*:'"$USER2" "$DELFN" \ 129 && echo "Success" \ 130 || echo "Failed" 131 132 # The other will be a reply to the organiser. 133 134 grep -q "To: $SENDER2ADDRESS" "$ORGFN" \ 135 && grep -q 'METHOD:REPLY' "$ORGFN" \ 136 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$ORGFN" \ 137 && grep -q 'ATTENDEE.*:'"$USER2" "$ORGFN" \ 138 && echo "Success" \ 139 || echo "Failed" 140 141 # Neither the delegator or the delegate will have changed their schedules. 142 143 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 144 > out2f1.tmp 145 146 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out2f1.tmp" \ 147 && echo "Success" \ 148 || echo "Failed" 149 150 "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ 151 > out2f2.tmp 152 153 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out2f2.tmp" \ 154 && echo "Success" \ 155 || echo "Failed" 156 157 # Check the quota (event is not confirmed). 158 159 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "all" \ 160 > out2e.tmp 161 162 grep -q "event21@example.com" "out2e.tmp" \ 163 && ! grep -q "event27@example.com" "out2e.tmp" \ 164 && echo "Success" \ 165 || echo "Failed" 166 167 # Present the reply to the organiser. 168 169 "$PERSON_SCRIPT" $ARGS < "$ORGFN" 2>> "$ERROR" \ 170 | tee out3r.tmp \ 171 | "$SHOWMAIL" \ 172 > out3.tmp 173 174 # Check the free/busy status of the attendees at the organiser. 175 # Currently, neither are attending. 176 177 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER1" \ 178 > out3s0.tmp \ 179 180 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out3s0.tmp \ 181 && echo "Success" \ 182 || echo "Failed" 183 184 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER2" \ 185 > out3s1.tmp \ 186 187 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out3s1.tmp \ 188 && echo "Success" \ 189 || echo "Failed" 190 191 # Present the request to the delegate. 192 193 "$RESOURCE_SCRIPT" $ARGS < "$DELFN" 2>> "$ERROR" \ 194 > out4r.tmp 195 196 "$SHOWMAIL" < out4r.tmp \ 197 > out4p0.tmp 198 199 "$SHOWMAIL" 1 < out4r.tmp \ 200 > out4p1.tmp 201 202 if grep -q "To: $SENDER2ADDRESS" out4p0.tmp ; then 203 ORGFN=out4p0.tmp ; DELFN=out4p1.tmp 204 else 205 ORGFN=out4p1.tmp ; DELFN=out4p0.tmp 206 fi 207 208 # One of the responses will be a reply sent to the organiser. 209 210 grep -q "To: $SENDER2ADDRESS" "$ORGFN" \ 211 && grep -q 'METHOD:REPLY' "$ORGFN" \ 212 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$ORGFN" \ 213 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED.*:'"$USER2" "$ORGFN" \ 214 && echo "Success" \ 215 || echo "Failed" 216 217 # The other will be a reply to the delegator. 218 219 grep -q "To: $USER1ADDRESS" "$DELFN" \ 220 && grep -q 'METHOD:REPLY' "$DELFN" \ 221 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$DELFN" \ 222 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED.*:'"$USER2" "$DELFN" \ 223 && echo "Success" \ 224 || echo "Failed" 225 226 # The delegate should now have a changed schedule. 227 228 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 229 > out4f1.tmp 230 231 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out4f1.tmp" \ 232 && echo "Success" \ 233 || echo "Failed" 234 235 "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ 236 > out4f2.tmp 237 238 grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out4f2.tmp" \ 239 && echo "Success" \ 240 || echo "Failed" 241 242 # Present the reply to the organiser. 243 244 "$PERSON_SCRIPT" $ARGS < "$ORGFN" 2>> "$ERROR" \ 245 | tee out5r.tmp \ 246 | "$SHOWMAIL" \ 247 > out5.tmp 248 249 # Check the free/busy status of the attendees at the organiser. 250 # Now, the delegate is attending. 251 252 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER1" \ 253 > out5s0.tmp \ 254 255 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out5s0.tmp \ 256 && echo "Success" \ 257 || echo "Failed" 258 259 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER2" \ 260 > out5s1.tmp \ 261 262 grep -q "^20141126T153000Z${TAB}20141126T163000Z" out5s1.tmp \ 263 && echo "Success" \ 264 || echo "Failed" 265 266 # Present the reply to the delegator. 267 268 "$RESOURCE_SCRIPT" $ARGS < "$DELFN" 2>> "$ERROR" \ 269 > out6r.tmp