1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/test_resource_invitation_constraints_quota_delegation_policy.sh Fri May 13 22:48:45 2016 +0200
1.3 @@ -0,0 +1,332 @@
1.4 +#!/bin/sh
1.5 +
1.6 +. "`dirname \"$0\"`/common.sh"
1.7 +
1.8 +USER1="mailto:resource-car-porsche911@example.com"
1.9 +USER2="mailto:resource-car-fiat500@example.com"
1.10 +SENDER1="mailto:paul.boddie@example.com"
1.11 +SENDER2="mailto:vincent.vole@example.com"
1.12 +USER1ADDRESS="resource-car-porsche911@example.com"
1.13 +USER2ADDRESS="resource-car-fiat500@example.com"
1.14 +SENDER1ADDRESS="paul.boddie@example.com"
1.15 +SENDER2ADDRESS="vincent.vole@example.com"
1.16 +QUOTA=cars
1.17 +OTHER_QUOTA=rooms
1.18 +
1.19 +mkdir -p "$PREFS/$USER1"
1.20 +echo 'Europe/Oslo' > "$PREFS/$USER1/TZID"
1.21 +echo 'share' > "$PREFS/$USER1/freebusy_sharing"
1.22 +cat > "$PREFS/$USER1/scheduling_function" <<EOF
1.23 +schedule_for_delegate $QUOTA most-available
1.24 +EOF
1.25 +
1.26 +mkdir -p "$PREFS/$USER2"
1.27 +echo 'Europe/Oslo' > "$PREFS/$USER2/TZID"
1.28 +echo 'share' > "$PREFS/$USER2/freebusy_sharing"
1.29 +cat > "$PREFS/$USER2/scheduling_function" <<EOF
1.30 +schedule_for_delegate $QUOTA most-available
1.31 +EOF
1.32 +
1.33 +# Have a common group for all organisers when scheduling.
1.34 +
1.35 +cat <<EOF | "$SET_QUOTA_GROUPS" "$QUOTA" $SET_QUOTA_GROUPS_ARGS
1.36 +* all
1.37 +EOF
1.38 +
1.39 +# Set a common quota.
1.40 +
1.41 +cat <<EOF | "$SET_QUOTA_LIMITS" "$QUOTA" $SET_QUOTA_LIMITS_ARGS
1.42 +all *
1.43 +EOF
1.44 +
1.45 +# Allow cars to delegate to each other.
1.46 +
1.47 +cat <<EOF | "$SET_DELEGATES" "$QUOTA" $SET_DELEGATES_ARGS
1.48 +mailto:resource-car-porsche911@example.com
1.49 +mailto:resource-car-fiat500@example.com
1.50 +EOF
1.51 +
1.52 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-car.txt" 2>> $ERROR \
1.53 +| "$SHOWMAIL" \
1.54 +> out0.tmp
1.55 +
1.56 + grep -q 'METHOD:REPLY' out0.tmp \
1.57 +&& ! grep -q '^FREEBUSY' out0.tmp \
1.58 +&& echo "Success" \
1.59 +|| echo "Failed"
1.60 +
1.61 +# Attempt to schedule an event.
1.62 +
1.63 +"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR
1.64 +
1.65 + "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \
1.66 +| tee out0s.tmp \
1.67 +| grep -q "^20141126T150000Z${TAB}20141126T160000Z" \
1.68 +&& echo "Success" \
1.69 +|| echo "Failed"
1.70 +
1.71 +# Present the request to the resource.
1.72 +
1.73 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR \
1.74 +| tee out1r.tmp \
1.75 +| "$SHOWMAIL" \
1.76 +> out1.tmp
1.77 +
1.78 + grep -q 'METHOD:REPLY' out1.tmp \
1.79 +&& grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out1.tmp \
1.80 +&& echo "Success" \
1.81 +|| echo "Failed"
1.82 +
1.83 + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \
1.84 +| tee out1f.tmp \
1.85 +| grep -q "^20141126T150000Z${TAB}20141126T160000Z" \
1.86 +&& echo "Success" \
1.87 +|| echo "Failed"
1.88 +
1.89 +# Check the quota (event is confirmed).
1.90 +
1.91 + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "all" \
1.92 +| tee out1e.tmp \
1.93 +| grep -q "event21@example.com" \
1.94 +&& echo "Success" \
1.95 +|| echo "Failed"
1.96 +
1.97 +# Attempt to schedule another event.
1.98 +
1.99 + sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=5/;' "$TEMPLATES/event-request-cars-recurring.txt" \
1.100 +| "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR
1.101 +
1.102 + "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \
1.103 +> out2s.tmp
1.104 +
1.105 + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2s.tmp" \
1.106 +&& grep -q "event21@example.com" "out2s.tmp" \
1.107 +&& grep -q "event25@example.com" "out2s.tmp" \
1.108 +&& echo "Success" \
1.109 +|| echo "Failed"
1.110 +
1.111 +# Present the request to the recipients.
1.112 +
1.113 + sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=5/;' "$TEMPLATES/event-request-cars-recurring.txt" \
1.114 +| "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \
1.115 +> out2r.tmp
1.116 +
1.117 + "$SHOWMAIL" < "out2r.tmp" \
1.118 +> out2p0.tmp
1.119 +
1.120 + "$SHOWMAIL" 1 < "out2r.tmp" \
1.121 +> out2p1.tmp
1.122 +
1.123 + grep -q 'METHOD:REPLY' out2p0.tmp \
1.124 +&& grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out2p0.tmp \
1.125 +&& echo "Success" \
1.126 +|| echo "Failed"
1.127 +
1.128 + grep -q 'METHOD:REPLY' out2p1.tmp \
1.129 +&& grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out2p1.tmp \
1.130 +&& echo "Success" \
1.131 +|| echo "Failed"
1.132 +
1.133 + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \
1.134 +> out2f0.tmp
1.135 +
1.136 + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f0.tmp" \
1.137 +&& grep -q "event21@example.com" "out2f0.tmp" \
1.138 +&& grep -q "event25@example.com" "out2f0.tmp" \
1.139 +&& echo "Success" \
1.140 +|| echo "Failed"
1.141 +
1.142 + "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \
1.143 +> out2f1.tmp
1.144 +
1.145 + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f1.tmp" \
1.146 +&& grep -q "event25@example.com" "out2f1.tmp" \
1.147 +&& echo "Success" \
1.148 +|| echo "Failed"
1.149 +
1.150 +# Check the quota (event is confirmed).
1.151 +
1.152 + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "all" \
1.153 +| tee out2e.tmp \
1.154 +| grep -q "event25@example.com" \
1.155 +&& echo "Success" \
1.156 +|| echo "Failed"
1.157 +
1.158 +# Attempt to schedule another event.
1.159 +
1.160 +"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-delegating.txt" 2>> $ERROR
1.161 +
1.162 + "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy" \
1.163 +| tee out3s.tmp \
1.164 +| grep -q "^20141126T153000Z${TAB}20141126T163000Z" \
1.165 +&& echo "Success" \
1.166 +|| echo "Failed"
1.167 +
1.168 +# Present the request to the resource.
1.169 +
1.170 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-delegating.txt" 2>> $ERROR \
1.171 +> out3r.tmp
1.172 +
1.173 + "$SHOWMAIL" < out3r.tmp \
1.174 +> out3p0.tmp
1.175 +
1.176 + "$SHOWMAIL" 1 < out3r.tmp \
1.177 +> out3p1.tmp
1.178 +
1.179 +if grep -q "To: $SENDER2ADDRESS" out3p0.tmp ; then
1.180 + ORGFN=out3p0.tmp ; DELFN=out3p1.tmp
1.181 +else
1.182 + ORGFN=out3p1.tmp ; DELFN=out3p0.tmp
1.183 +fi
1.184 +
1.185 +# One of the responses will be a request sent to the delegate.
1.186 +
1.187 + grep -q "To: $USER2ADDRESS" "$DELFN" \
1.188 +&& grep -q 'METHOD:REQUEST' "$DELFN" \
1.189 +&& grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$DELFN" \
1.190 +&& grep -q 'ATTENDEE.*:'"$USER2" "$DELFN" \
1.191 +&& echo "Success" \
1.192 +|| echo "Failed"
1.193 +
1.194 +# The other will be a reply to the organiser.
1.195 +
1.196 + grep -q "To: $SENDER2ADDRESS" "$ORGFN" \
1.197 +&& grep -q 'METHOD:REPLY' "$ORGFN" \
1.198 +&& grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$ORGFN" \
1.199 +&& grep -q 'ATTENDEE.*:'"$USER2" "$ORGFN" \
1.200 +&& echo "Success" \
1.201 +|| echo "Failed"
1.202 +
1.203 +# Neither the delegator or the delegate will have changed their schedules.
1.204 +
1.205 + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \
1.206 +> out4f1.tmp
1.207 +
1.208 + ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out4f1.tmp" \
1.209 +&& echo "Success" \
1.210 +|| echo "Failed"
1.211 +
1.212 + "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \
1.213 +> out4f2.tmp
1.214 +
1.215 + ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out4f2.tmp" \
1.216 +&& echo "Success" \
1.217 +|| echo "Failed"
1.218 +
1.219 +# Check the quota (event is not confirmed).
1.220 +
1.221 + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "all" \
1.222 +> out4e.tmp
1.223 +
1.224 + grep -q "event21@example.com" "out4e.tmp" \
1.225 +&& grep -q "event25@example.com" "out4e.tmp" \
1.226 +&& ! grep -q "event27@example.com" "out4e.tmp" \
1.227 +&& echo "Success" \
1.228 +|| echo "Failed"
1.229 +
1.230 +# Present the reply to the organiser.
1.231 +
1.232 + "$PERSON_SCRIPT" $ARGS < "$ORGFN" 2>> "$ERROR" \
1.233 +| tee out5r.tmp \
1.234 +| "$SHOWMAIL" \
1.235 +> out5.tmp
1.236 +
1.237 +# Check the free/busy status of the attendees at the organiser.
1.238 +# Currently, neither are attending.
1.239 +
1.240 + "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER1" \
1.241 +> out5s0.tmp \
1.242 +
1.243 + ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out5s0.tmp \
1.244 +&& echo "Success" \
1.245 +|| echo "Failed"
1.246 +
1.247 + "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER2" \
1.248 +> out5s1.tmp \
1.249 +
1.250 + ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out5s1.tmp \
1.251 +&& echo "Success" \
1.252 +|| echo "Failed"
1.253 +
1.254 +# Present the request to the delegate.
1.255 +
1.256 + "$RESOURCE_SCRIPT" $ARGS < "$DELFN" 2>> "$ERROR" \
1.257 +> out6r.tmp
1.258 +
1.259 + "$SHOWMAIL" < out6r.tmp \
1.260 +> out6p0.tmp
1.261 +
1.262 + "$SHOWMAIL" 1 < out6r.tmp \
1.263 +> out6p1.tmp
1.264 +
1.265 +if grep -q "To: $SENDER2ADDRESS" out6p0.tmp ; then
1.266 + ORGFN=out6p0.tmp ; DELFN=out6p1.tmp
1.267 +else
1.268 + ORGFN=out6p1.tmp ; DELFN=out6p0.tmp
1.269 +fi
1.270 +
1.271 +# One of the responses will be a reply sent to the organiser.
1.272 +
1.273 + grep -q "To: $SENDER2ADDRESS" "$ORGFN" \
1.274 +&& grep -q 'METHOD:REPLY' "$ORGFN" \
1.275 +&& grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$ORGFN" \
1.276 +&& grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED.*:'"$USER2" "$ORGFN" \
1.277 +&& echo "Success" \
1.278 +|| echo "Failed"
1.279 +
1.280 +# The other will be a reply to the delegator.
1.281 +
1.282 + grep -q "To: $USER1ADDRESS" "$DELFN" \
1.283 +&& grep -q 'METHOD:REPLY' "$DELFN" \
1.284 +&& grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$DELFN" \
1.285 +&& grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED.*:'"$USER2" "$DELFN" \
1.286 +&& echo "Success" \
1.287 +|| echo "Failed"
1.288 +
1.289 +# The delegate should now have a changed schedule.
1.290 +
1.291 + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \
1.292 +> out7f0.tmp
1.293 +
1.294 + ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out7f0.tmp" \
1.295 +&& echo "Success" \
1.296 +|| echo "Failed"
1.297 +
1.298 + "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \
1.299 +> out7f1.tmp
1.300 +
1.301 + grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out7f1.tmp" \
1.302 +&& grep -q "event27@example.com" "out7f1.tmp" \
1.303 +&& echo "Success" \
1.304 +|| echo "Failed"
1.305 +
1.306 +# Present the reply to the organiser.
1.307 +
1.308 + "$PERSON_SCRIPT" $ARGS < "$ORGFN" 2>> "$ERROR" \
1.309 +| tee out8r.tmp \
1.310 +| "$SHOWMAIL" \
1.311 +> out8.tmp
1.312 +
1.313 +# Check the free/busy status of the attendees at the organiser.
1.314 +# Now, the delegate is attending.
1.315 +
1.316 + "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER1" \
1.317 +> out8s0.tmp \
1.318 +
1.319 + ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out8s0.tmp \
1.320 +&& ! grep -q "event27@example.com" out8s0.tmp \
1.321 +&& echo "Success" \
1.322 +|| echo "Failed"
1.323 +
1.324 + "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER2" \
1.325 +> out8s1.tmp \
1.326 +
1.327 + grep -q "^20141126T153000Z${TAB}20141126T163000Z" out8s1.tmp \
1.328 +&& grep -q "event27@example.com" out8s1.tmp \
1.329 +&& echo "Success" \
1.330 +|| echo "Failed"
1.331 +
1.332 +# Present the reply to the delegator.
1.333 +
1.334 + "$RESOURCE_SCRIPT" $ARGS < "$DELFN" 2>> "$ERROR" \
1.335 +> out9r.tmp