1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/test_resource_invitation_constraints_quota_recurring_unlimited.sh Sun Jun 05 19:36:32 2016 +0200
1.3 @@ -0,0 +1,263 @@
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 +SENDERADDRESS1="paul.boddie@example.com"
1.12 +QUOTA=cars
1.13 +
1.14 +# Test quota enforcement on two resources, first checking whether the resources
1.15 +# can schedule an incoming reservation, then checking whether the reservation
1.16 +# would exceed the organiser's quota applying collectively to both resources.
1.17 +
1.18 +# The result should be the first scheduling attempt being declined because it
1.19 +# attempts to reserve an indefinite amount of time that obviously exceeds the
1.20 +# quota, with the second attempt succeeding once the quota has been removed.
1.21 +
1.22 +# The event is then cancelled for one resource and the effect evaluated.
1.23 +
1.24 +mkdir -p "$PREFS/$USER1"
1.25 +echo 'Europe/Oslo' > "$PREFS/$USER1/TZID"
1.26 +echo 'share' > "$PREFS/$USER1/freebusy_sharing"
1.27 +cat > "$PREFS/$USER1/scheduling_function" <<EOF
1.28 +schedule_in_freebusy
1.29 +check_quota $QUOTA
1.30 +EOF
1.31 +
1.32 +mkdir -p "$PREFS/$USER2"
1.33 +echo 'Europe/Oslo' > "$PREFS/$USER2/TZID"
1.34 +echo 'share' > "$PREFS/$USER2/freebusy_sharing"
1.35 +cat > "$PREFS/$USER2/scheduling_function" <<EOF
1.36 +schedule_in_freebusy
1.37 +check_quota $QUOTA
1.38 +EOF
1.39 +
1.40 +cat <<EOF | "$SET_QUOTA_LIMITS" "$QUOTA" $SET_QUOTA_LIMITS_ARGS
1.41 +* PT10H
1.42 +EOF
1.43 +
1.44 +# Allow cars to delegate to each other. This defines the possible attendees for
1.45 +# recurring events.
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-all.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-cars-recurring.txt" 2>> $ERROR
1.64 +
1.65 + "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \
1.66 +> out0f.tmp
1.67 +
1.68 + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out0f.tmp" \
1.69 +&& grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out0f.tmp" \
1.70 +&& echo "Success" \
1.71 +|| echo "Failed"
1.72 +
1.73 +# Present the request to the resource.
1.74 +
1.75 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-cars-recurring.txt" 2>> $ERROR \
1.76 +| tee out1r.tmp \
1.77 +| "$SHOWMAIL" \
1.78 +> out1.tmp
1.79 +
1.80 + grep -q 'METHOD:REPLY' out1.tmp \
1.81 +&& grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out1.tmp \
1.82 +&& echo "Success" \
1.83 +|| echo "Failed"
1.84 +
1.85 + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \
1.86 +> out1f.tmp
1.87 +
1.88 + "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \
1.89 +> out1f2.tmp
1.90 +
1.91 + ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out1f.tmp" \
1.92 +&& ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out1f.tmp" \
1.93 +&& ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out1f2.tmp" \
1.94 +&& ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out1f2.tmp" \
1.95 +&& echo "Success" \
1.96 +|| echo "Failed"
1.97 +
1.98 +# Check the quota (event is not confirmed).
1.99 +
1.100 + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER1" \
1.101 +> out1e.tmp
1.102 +
1.103 + ! grep -q "event25@example.com" "out1e.tmp" \
1.104 +&& echo "Success" \
1.105 +|| echo "Failed"
1.106 +
1.107 +# Modify the quota and attempt to schedule the event again.
1.108 +
1.109 +cat <<EOF | "$SET_QUOTA_LIMITS" "$QUOTA" $SET_QUOTA_LIMITS_ARGS
1.110 +* *
1.111 +EOF
1.112 +
1.113 +"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-cars-recurring.txt" 2>> $ERROR
1.114 +
1.115 + "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \
1.116 +> out1s.tmp
1.117 +
1.118 + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out1s.tmp" \
1.119 +&& grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out1s.tmp" \
1.120 +&& grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out1s.tmp" \
1.121 +&& echo "Success" \
1.122 +|| echo "Failed"
1.123 +
1.124 +# Present the request to the resource.
1.125 +
1.126 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-cars-recurring.txt" 2>> $ERROR \
1.127 +| tee out2r.tmp \
1.128 +| "$SHOWMAIL" \
1.129 +> out2.tmp
1.130 +
1.131 +# Since the email module used by showmail.py cannot stop after reading a single
1.132 +# message, the second message is obtained.
1.133 +
1.134 + "$SHOWMAIL" 1 < out2r.tmp \
1.135 +>> out2.tmp
1.136 +
1.137 + grep -q 'METHOD:REPLY' out2.tmp \
1.138 +&& grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out2.tmp \
1.139 +&& grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out2.tmp \
1.140 +&& echo "Success" \
1.141 +|| echo "Failed"
1.142 +
1.143 + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \
1.144 +> out2f.tmp
1.145 +
1.146 + "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \
1.147 +> out2f2.tmp
1.148 +
1.149 + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f.tmp" \
1.150 +&& grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out2f.tmp" \
1.151 +&& grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out2f.tmp" \
1.152 +&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f2.tmp" \
1.153 +&& grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out2f2.tmp" \
1.154 +&& grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out2f2.tmp" \
1.155 +&& echo "Success" \
1.156 +|| echo "Failed"
1.157 +
1.158 +# Check the quota (event is confirmed for both resources).
1.159 +
1.160 + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER1" \
1.161 +> out2e.tmp
1.162 +
1.163 + grep -q "event25@example.com" "out2e.tmp" \
1.164 +&& grep -q "$USER1" "out2e.tmp" \
1.165 +&& grep -q "$USER2" "out2e.tmp" \
1.166 +&& echo "Success" \
1.167 +|| echo "Failed"
1.168 +
1.169 +# Check the journal's event store.
1.170 +
1.171 + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "journal_object" "event25@example.com" \
1.172 +> out2o.tmp
1.173 +
1.174 + grep -q "event25@example.com" "out2o.tmp" \
1.175 +&& grep -q "$USER1" "out2o.tmp" \
1.176 +&& grep -q "$USER2" "out2o.tmp" \
1.177 +&& echo "Success" \
1.178 +|| echo "Failed"
1.179 +
1.180 +# Run the free/busy maintenance script and check that the event provides
1.181 +# recurrences.
1.182 +
1.183 +"$FREEBUSY_SCRIPT" "$QUOTA" '*' $FREEBUSY_QUOTA_ARGS $ARGS 2>> $ERROR
1.184 +
1.185 + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "journal_freebusy_providers" \
1.186 +| tee out2p.tmp \
1.187 +| grep -q 'event25@example.com' \
1.188 +&& echo "Success" \
1.189 +|| echo "Failed"
1.190 +
1.191 +# Cancel the event for one of the resources.
1.192 +
1.193 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-car-recurring.txt" 2>> $ERROR
1.194 +echo "Cancel..."
1.195 +
1.196 +# Check the quota (event is confirmed for one resource).
1.197 +
1.198 + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER1" \
1.199 +> out3e.tmp
1.200 +
1.201 + grep -q "event25@example.com" "out3e.tmp" \
1.202 +&& grep -q "$USER1" "out3e.tmp" \
1.203 +&& ! grep -q "$USER2" "out3e.tmp" \
1.204 +&& echo "Success" \
1.205 +|| echo "Failed"
1.206 +
1.207 +# Check the journal's event store.
1.208 +
1.209 + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "journal_object" "event25@example.com" \
1.210 +> out3o.tmp
1.211 +
1.212 + grep -q "event25@example.com" "out3o.tmp" \
1.213 +&& grep -q "$USER1" "out3o.tmp" \
1.214 +&& ! grep -q "$USER2" "out3o.tmp" \
1.215 +&& echo "Success" \
1.216 +|| echo "Failed"
1.217 +
1.218 +# Run the free/busy maintenance script and check that the event still provides
1.219 +# recurrences.
1.220 +
1.221 +"$FREEBUSY_SCRIPT" "$QUOTA" '*' $FREEBUSY_QUOTA_ARGS $ARGS 2>> $ERROR
1.222 +
1.223 + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "journal_freebusy_providers" \
1.224 +| tee out3p.tmp \
1.225 +| grep -q 'event25@example.com' \
1.226 +&& echo "Success" \
1.227 +|| echo "Failed"
1.228 +
1.229 +# Cancel the event completely.
1.230 +
1.231 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-cars-recurring.txt" 2>> $ERROR
1.232 +echo "Cancel..."
1.233 +
1.234 +# Check the quota (event is confirmed for no resources).
1.235 +
1.236 + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER1" \
1.237 +> out4e.tmp
1.238 +
1.239 + ! grep -q "event25@example.com" "out4e.tmp" \
1.240 +&& ! grep -q "$USER1" "out4e.tmp" \
1.241 +&& ! grep -q "$USER2" "out4e.tmp" \
1.242 +&& echo "Success" \
1.243 +|| echo "Failed"
1.244 +
1.245 +# Check the journal's event store.
1.246 +
1.247 + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "journal_object" "event25@example.com" \
1.248 +> out4o.tmp
1.249 +
1.250 + ! grep -q "event25@example.com" "out4o.tmp" \
1.251 +&& ! grep -q "$USER1" "out4o.tmp" \
1.252 +&& ! grep -q "$USER2" "out4o.tmp" \
1.253 +&& echo "Success" \
1.254 +|| echo "Failed"
1.255 +
1.256 +# Run the free/busy maintenance script and check that the event no longer
1.257 +# provides recurrences.
1.258 +
1.259 +"$FREEBUSY_SCRIPT" "$QUOTA" '*' $FREEBUSY_QUOTA_ARGS $ARGS 2>> $ERROR
1.260 +
1.261 + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "journal_freebusy_providers" \
1.262 +> out4p.tmp
1.263 +
1.264 + ! grep -q 'event25@example.com' "out4p.tmp" \
1.265 +&& echo "Success" \
1.266 +|| echo "Failed"