1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/test_resource_invitation_constraints_next_free.sh Tue Oct 27 00:26:59 2015 +0100
1.3 @@ -0,0 +1,168 @@
1.4 +#!/bin/sh
1.5 +
1.6 +THIS_DIR=`dirname $0`
1.7 +
1.8 +TEMPLATES="$THIS_DIR/templates"
1.9 +PERSON_SCRIPT="$THIS_DIR/../imip_person.py"
1.10 +RESOURCE_SCRIPT="$THIS_DIR/../imip_resource.py"
1.11 +SHOWMAIL="$THIS_DIR/../tools/showmail.py"
1.12 +STORE=/tmp/store
1.13 +STATIC=/tmp/static
1.14 +PREFS=/tmp/prefs
1.15 +ARGS="-S $STORE -P $STATIC -p $PREFS -d"
1.16 +USER="mailto:resource-room-sauna@example.com"
1.17 +SENDER="mailto:paul.boddie@example.com"
1.18 +RIVALSENDER="mailto:vincent.vole@example.com"
1.19 +FBFILE="$STORE/$USER/freebusy"
1.20 +FBOFFERFILE="$STORE/$USER/freebusy-offers"
1.21 +FBSENDERFILE="$STORE/$SENDER/freebusy"
1.22 +FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER"
1.23 +FBSENDERREQUESTS="$STORE/$SENDER/requests"
1.24 +FBRIVALSENDERFILE="$STORE/$RIVALSENDER/freebusy"
1.25 +TAB=`printf '\t'`
1.26 +
1.27 +OUTGOING_SCRIPT="$THIS_DIR/../imip_person_outgoing.py"
1.28 +
1.29 +ERROR=err.tmp
1.30 +
1.31 +rm -r $STORE
1.32 +rm -r $STATIC
1.33 +rm -r $PREFS
1.34 +rm $ERROR
1.35 +rm out*.tmp
1.36 +
1.37 +mkdir -p "$PREFS/$USER"
1.38 +echo 'Europe/Oslo' > "$PREFS/$USER/TZID"
1.39 +echo 'share' > "$PREFS/$USER/freebusy_sharing"
1.40 +echo 'schedule_next_available_in_freebusy' > "$PREFS/$USER/scheduling_function"
1.41 +echo 'PT60S' > "$PREFS/$USER/freebusy_offers"
1.42 +
1.43 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \
1.44 +| "$SHOWMAIL" \
1.45 +> out0.tmp
1.46 +
1.47 + grep -q 'METHOD:REPLY' out0.tmp \
1.48 +&& ! grep -q '^FREEBUSY' out0.tmp \
1.49 +&& echo "Success" \
1.50 +|| echo "Failed"
1.51 +
1.52 +# Let the rival sender book the resource.
1.53 +
1.54 +"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-busy.txt" 2>> $ERROR
1.55 +
1.56 + [ `grep "event19@example.com" "$FBRIVALSENDERFILE" | wc -l` = '5' ] \
1.57 +&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBRIVALSENDERFILE" \
1.58 +&& echo "Success" \
1.59 +|| echo "Failed"
1.60 +
1.61 +# Present the request to the resource.
1.62 +
1.63 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-busy.txt" 2>> $ERROR \
1.64 +| tee out1r.tmp \
1.65 +| "$SHOWMAIL" \
1.66 +> out1.tmp
1.67 +
1.68 + grep -q 'METHOD:REPLY' out1.tmp \
1.69 +&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T160000' out1.tmp \
1.70 +&& echo "Success" \
1.71 +|| echo "Failed"
1.72 +
1.73 + [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \
1.74 +&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \
1.75 +&& echo "Success" \
1.76 +|| echo "Failed"
1.77 +
1.78 +# Present the response to the rival sender.
1.79 +
1.80 + "$PERSON_SCRIPT" $ARGS < out1r.tmp 2>> $ERROR \
1.81 +| tee out2r.tmp \
1.82 +| "$SHOWMAIL" \
1.83 +> out2.tmp
1.84 +
1.85 +# Attempt to schedule an event with the resource.
1.86 +
1.87 +"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR
1.88 +
1.89 + grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \
1.90 +&& echo "Success" \
1.91 +|| echo "Failed"
1.92 +
1.93 +# Present the request to the resource. This should cause the event to be
1.94 +# proposed one hour later.
1.95 +
1.96 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR \
1.97 +| tee out6r.tmp \
1.98 +| "$SHOWMAIL" \
1.99 +> out6.tmp
1.100 +
1.101 + grep -q 'METHOD:COUNTER' out6.tmp \
1.102 +&& ! grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out6.tmp \
1.103 +&& echo "Success" \
1.104 +|| echo "Failed"
1.105 +
1.106 + ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \
1.107 +&& grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \
1.108 +&& echo "Success" \
1.109 +|| echo "Failed"
1.110 +
1.111 +# Present the response to the organiser.
1.112 +
1.113 + "$PERSON_SCRIPT" $ARGS < out6r.tmp 2>> $ERROR \
1.114 +| tee out7r.tmp \
1.115 +| "$SHOWMAIL" \
1.116 +> out7.tmp
1.117 +
1.118 + grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \
1.119 +&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBSENDERFILE" \
1.120 +&& echo "Success" \
1.121 +|| echo "Failed"
1.122 +
1.123 + [ -e "$STORE/$SENDER/counters/objects/event13@example.com/$USER" ] \
1.124 +&& echo "Success" \
1.125 +|| echo "Failed"
1.126 +
1.127 + grep -q 'event13@example.com' "$FBSENDERREQUESTS" \
1.128 +&& echo "Success" \
1.129 +|| echo "Failed"
1.130 +
1.131 +# Reschedule the event by accepting the counter-proposal.
1.132 +
1.133 + sed 's/COUNTER/REQUEST/' < out6.tmp \
1.134 +| sed 's/^From: calendar/To: resource-room-sauna/' \
1.135 +| sed 's/^To: paul.boddie/From: paul.boddie/' \
1.136 +> out8.tmp
1.137 +
1.138 +"$OUTGOING_SCRIPT" $ARGS < out8.tmp 2>> $ERROR
1.139 +
1.140 + ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \
1.141 +&& grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBSENDERFILE" \
1.142 +&& echo "Success" \
1.143 +|| echo "Failed"
1.144 +
1.145 + ! [ -e "$STORE/$SENDER/counters/objects/event13@example.com/$USER" ] \
1.146 +&& echo "Success" \
1.147 +|| echo "Failed"
1.148 +
1.149 + ! grep -q 'event13@example.com' "$FBSENDERREQUESTS" \
1.150 +&& echo "Success" \
1.151 +|| echo "Failed"
1.152 +
1.153 + "$RESOURCE_SCRIPT" $ARGS < out8.tmp 2>> $ERROR \
1.154 +| "$SHOWMAIL" \
1.155 +> out9.tmp
1.156 +
1.157 + grep -q 'METHOD:REPLY' out9.tmp \
1.158 +&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' out9.tmp \
1.159 +&& echo "Success" \
1.160 +|| echo "Failed"
1.161 +
1.162 + ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \
1.163 +&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \
1.164 +&& echo "Success" \
1.165 +|| echo "Failed"
1.166 +
1.167 + [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \
1.168 +&& [ `grep "event13@example.com" "$FBFILE" | wc -l` = '1' ] \
1.169 +&& grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBFILE" \
1.170 +&& echo "Success" \
1.171 +|| echo "Failed"