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