1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/test_resource_invitation_constraints_quota_delegation.sh Thu May 12 23:15:18 2016 +0200
1.3 @@ -0,0 +1,264 @@
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 +SENDER="mailto:paul.boddie@example.com"
1.11 +USER1ADDRESS="resource-car-porsche911@example.com"
1.12 +USER2ADDRESS="resource-car-fiat500@example.com"
1.13 +SENDERADDRESS="paul.boddie@example.com"
1.14 +QUOTA=cars
1.15 +OTHER_QUOTA=rooms
1.16 +
1.17 +mkdir -p "$PREFS/$USER1"
1.18 +echo 'Europe/Oslo' > "$PREFS/$USER1/TZID"
1.19 +echo 'share' > "$PREFS/$USER1/freebusy_sharing"
1.20 +cat > "$PREFS/$USER1/scheduling_function" <<EOF
1.21 +schedule_for_delegate $QUOTA
1.22 +schedule_in_freebusy
1.23 +check_quota $QUOTA
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
1.31 +schedule_in_freebusy
1.32 +check_quota $QUOTA
1.33 +EOF
1.34 +
1.35 +cat <<EOF | "$SET_QUOTA_LIMIT" "$QUOTA" $SET_QUOTA_LIMIT_ARGS
1.36 +* PT2H
1.37 +EOF
1.38 +cat <<EOF | "$SET_QUOTA_LIMIT" "$OTHER_QUOTA" $SET_QUOTA_LIMIT_ARGS
1.39 +* PT2H
1.40 +EOF
1.41 +
1.42 +# Allow cars to delegate to each other.
1.43 +
1.44 +cat <<EOF | "$SET_DELEGATES" "$QUOTA" $SET_DELEGATES_ARGS
1.45 +mailto:resource-car-porsche911@example.com
1.46 +mailto:resource-car-fiat500@example.com
1.47 +EOF
1.48 +
1.49 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-car.txt" 2>> $ERROR \
1.50 +| "$SHOWMAIL" \
1.51 +> out0.tmp
1.52 +
1.53 + grep -q 'METHOD:REPLY' out0.tmp \
1.54 +&& ! grep -q '^FREEBUSY' out0.tmp \
1.55 +&& echo "Success" \
1.56 +|| echo "Failed"
1.57 +
1.58 +# Attempt to schedule an event.
1.59 +
1.60 +"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR
1.61 +
1.62 + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \
1.63 +| tee out0s.tmp \
1.64 +| grep -q "^20141126T150000Z${TAB}20141126T160000Z" \
1.65 +&& echo "Success" \
1.66 +|| echo "Failed"
1.67 +
1.68 +# Present the request to the resource.
1.69 +
1.70 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR \
1.71 +| tee out1r.tmp \
1.72 +| "$SHOWMAIL" \
1.73 +> out1.tmp
1.74 +
1.75 + grep -q 'METHOD:REPLY' out1.tmp \
1.76 +&& grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out1.tmp \
1.77 +&& echo "Success" \
1.78 +|| echo "Failed"
1.79 +
1.80 + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \
1.81 +| tee out1f.tmp \
1.82 +| grep -q "^20141126T150000Z${TAB}20141126T160000Z" \
1.83 +&& echo "Success" \
1.84 +|| echo "Failed"
1.85 +
1.86 +# Check the quota (event is confirmed).
1.87 +
1.88 + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \
1.89 +| tee out1e.tmp \
1.90 +| grep -q "event21@example.com" \
1.91 +&& echo "Success" \
1.92 +|| echo "Failed"
1.93 +
1.94 +# Attempt to schedule another event.
1.95 +
1.96 +"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-delegating.txt" 2>> $ERROR
1.97 +
1.98 + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \
1.99 +| tee out1s.tmp \
1.100 +| grep -q "^20141126T153000Z${TAB}20141126T163000Z" \
1.101 +&& echo "Success" \
1.102 +|| echo "Failed"
1.103 +
1.104 +# Present the request to the resource.
1.105 +
1.106 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-delegating.txt" 2>> $ERROR \
1.107 +> out2r.tmp
1.108 +
1.109 + "$SHOWMAIL" < out2r.tmp \
1.110 +> out2p0.tmp
1.111 +
1.112 + "$SHOWMAIL" 1 < out2r.tmp \
1.113 +> out2p1.tmp
1.114 +
1.115 +if grep -q "To: $SENDERADDRESS" out2p0.tmp ; then
1.116 + ORGFN=out2p0.tmp ; DELFN=out2p1.tmp
1.117 +else
1.118 + ORGFN=out2p1.tmp ; DELFN=out2p0.tmp
1.119 +fi
1.120 +
1.121 +# One of the responses will be a request sent to the delegate.
1.122 +
1.123 + grep -q "To: $USER2ADDRESS" "$DELFN" \
1.124 +&& grep -q 'METHOD:REQUEST' "$DELFN" \
1.125 +&& grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$DELFN" \
1.126 +&& grep -q 'ATTENDEE.*:'"$USER2" "$DELFN" \
1.127 +&& echo "Success" \
1.128 +|| echo "Failed"
1.129 +
1.130 +# The other will be a reply to the organiser.
1.131 +
1.132 + grep -q "To: $SENDERADDRESS" "$ORGFN" \
1.133 +&& grep -q 'METHOD:REPLY' "$ORGFN" \
1.134 +&& grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$ORGFN" \
1.135 +&& grep -q 'ATTENDEE.*:'"$USER2" "$ORGFN" \
1.136 +&& echo "Success" \
1.137 +|| echo "Failed"
1.138 +
1.139 +# Neither the delegator or the delegate will have changed their schedules.
1.140 +
1.141 + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \
1.142 +> out2f1.tmp
1.143 +
1.144 + ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out2f1.tmp" \
1.145 +&& echo "Success" \
1.146 +|| echo "Failed"
1.147 +
1.148 + "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \
1.149 +> out2f2.tmp
1.150 +
1.151 + ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out2f2.tmp" \
1.152 +&& echo "Success" \
1.153 +|| echo "Failed"
1.154 +
1.155 +# Check the quota (event is not confirmed).
1.156 +
1.157 + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \
1.158 +> out2e.tmp
1.159 +
1.160 + grep -q "event21@example.com" "out2e.tmp" \
1.161 +&& ! grep -q "event27@example.com" "out2e.tmp" \
1.162 +&& echo "Success" \
1.163 +|| echo "Failed"
1.164 +
1.165 +# Present the reply to the organiser.
1.166 +
1.167 + "$PERSON_SCRIPT" $ARGS < "$ORGFN" 2>> "$ERROR" \
1.168 +| tee out3r.tmp \
1.169 +| "$SHOWMAIL" \
1.170 +> out3.tmp
1.171 +
1.172 +# Check the free/busy status of the attendees at the organiser.
1.173 +# Currently, neither are attending.
1.174 +
1.175 + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy_other" "$USER1" \
1.176 +> out3s0.tmp \
1.177 +
1.178 + ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out3s0.tmp \
1.179 +&& echo "Success" \
1.180 +|| echo "Failed"
1.181 +
1.182 + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy_other" "$USER2" \
1.183 +> out3s1.tmp \
1.184 +
1.185 + ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out3s1.tmp \
1.186 +&& echo "Success" \
1.187 +|| echo "Failed"
1.188 +
1.189 +# Present the request to the delegate.
1.190 +
1.191 + "$RESOURCE_SCRIPT" $ARGS < "$DELFN" 2>> "$ERROR" \
1.192 +> out4r.tmp
1.193 +
1.194 + "$SHOWMAIL" < out4r.tmp \
1.195 +> out4p0.tmp
1.196 +
1.197 + "$SHOWMAIL" 1 < out4r.tmp \
1.198 +> out4p1.tmp
1.199 +
1.200 +if grep -q "To: $SENDERADDRESS" out4p0.tmp ; then
1.201 + ORGFN=out4p0.tmp ; DELFN=out4p1.tmp
1.202 +else
1.203 + ORGFN=out4p1.tmp ; DELFN=out4p0.tmp
1.204 +fi
1.205 +
1.206 +# One of the responses will be a reply sent to the organiser.
1.207 +
1.208 + grep -q "To: $SENDERADDRESS" "$ORGFN" \
1.209 +&& grep -q 'METHOD:REPLY' "$ORGFN" \
1.210 +&& grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$ORGFN" \
1.211 +&& grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED.*:'"$USER2" "$ORGFN" \
1.212 +&& echo "Success" \
1.213 +|| echo "Failed"
1.214 +
1.215 +# The other will be a reply to the delegator.
1.216 +
1.217 + grep -q "To: $USER1ADDRESS" "$DELFN" \
1.218 +&& grep -q 'METHOD:REPLY' "$DELFN" \
1.219 +&& grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$DELFN" \
1.220 +&& grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED.*:'"$USER2" "$DELFN" \
1.221 +&& echo "Success" \
1.222 +|| echo "Failed"
1.223 +
1.224 +# The delegate should now have a changed schedule.
1.225 +
1.226 + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \
1.227 +> out4f1.tmp
1.228 +
1.229 + ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out4f1.tmp" \
1.230 +&& echo "Success" \
1.231 +|| echo "Failed"
1.232 +
1.233 + "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \
1.234 +> out4f2.tmp
1.235 +
1.236 + grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out4f2.tmp" \
1.237 +&& echo "Success" \
1.238 +|| echo "Failed"
1.239 +
1.240 +# Present the reply to the organiser.
1.241 +
1.242 + "$PERSON_SCRIPT" $ARGS < "$ORGFN" 2>> "$ERROR" \
1.243 +| tee out5r.tmp \
1.244 +| "$SHOWMAIL" \
1.245 +> out5.tmp
1.246 +
1.247 +# Check the free/busy status of the attendees at the organiser.
1.248 +# Now, the delegate is attending.
1.249 +
1.250 + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy_other" "$USER1" \
1.251 +> out5s0.tmp \
1.252 +
1.253 + ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out5s0.tmp \
1.254 +&& echo "Success" \
1.255 +|| echo "Failed"
1.256 +
1.257 + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy_other" "$USER2" \
1.258 +> out5s1.tmp \
1.259 +
1.260 + grep -q "^20141126T153000Z${TAB}20141126T163000Z" out5s1.tmp \
1.261 +&& echo "Success" \
1.262 +|| echo "Failed"
1.263 +
1.264 +# Present the reply to the delegator.
1.265 +
1.266 + "$RESOURCE_SCRIPT" $ARGS < "$DELFN" 2>> "$ERROR" \
1.267 +> out6r.tmp