1.1 --- a/tests/test_person_invitation_counter.sh Sat Jan 13 17:25:04 2018 +0100
1.2 +++ b/tests/test_person_invitation_counter.sh Sat Jan 13 17:26:42 2018 +0100
1.3 @@ -4,189 +4,174 @@
1.4
1.5 USER="mailto:vincent.vole@example.com"
1.6 SENDER="mailto:paul.boddie@example.com"
1.7 +USERADDRESS="vincent.vole@example.com"
1.8 +SENDERADDRESS="paul.boddie@example.com"
1.9
1.10 mkdir -p "$PREFS/$USER"
1.11 echo 'Europe/Oslo' > "$PREFS/$USER/TZID"
1.12 echo 'share' > "$PREFS/$USER/freebusy_sharing"
1.13 echo 'PT60S' > "$PREFS/$USER/freebusy_offers"
1.14
1.15 - "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \
1.16 -| "$SHOWMAIL" \
1.17 -> out0.tmp
1.18 +person_script "$TEMPLATES/fb-request-person-all.txt" "out0.tmp"
1.19
1.20 - grep -q 'METHOD:REPLY' out0.tmp \
1.21 -&& ! grep -q '^FREEBUSY' out0.tmp \
1.22 -&& echo "Success" \
1.23 -|| echo "Failed"
1.24 + is_present 'METHOD:REPLY' "out0.tmp" \
1.25 +&& is_absent '^FREEBUSY' "out0.tmp" \
1.26 +&& success || failed "out0.tmp"
1.27 +
1.28 +# Make a new event.
1.29
1.30 -# Attempt to schedule an event.
1.31 -
1.32 -"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person.txt" 2>> $ERROR
1.33 +cat > "event_cmd.tmp" <<EOF
1.34 +new
1.35 +period 0 edit 20141126 16 00 00 Europe/Oslo 20141126 17 00 00 Europe/Oslo
1.36 +attendance accept
1.37 +attendee mailto:vincent.vole@example.com
1.38 +summary Meeting at 4pm
1.39 +finish
1.40 +update event.tmp
1.41 +publish event_self.tmp
1.42 +UID event_uid.tmp
1.43 +EOF
1.44
1.45 - "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \
1.46 -> out0f.tmp
1.47 +text_client "$SENDER" "event_cmd.tmp"
1.48 +
1.49 +# Obtain the event UID.
1.50 +
1.51 +read UID1 < "event_uid.tmp"
1.52
1.53 - grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out0f.tmp" \
1.54 -&& echo "Success" \
1.55 -|| echo "Failed"
1.56 +# Register the event at the sender.
1.57 +
1.58 +outgoing_script "event.tmp"
1.59 +
1.60 +# Expect free/busy periods at the sender.
1.61 +
1.62 +list_script "out0f.tmp" "$SENDER" "freebusy"
1.63 +test_freebusy '20141126T150000Z' '20141126T160000Z' "out0f.tmp"
1.64
1.65 # Present the request to the recipient.
1.66
1.67 - "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person.txt" 2>> $ERROR \
1.68 -| "$SHOWMAIL" \
1.69 -> out1.tmp
1.70 +person_script "event.tmp" "out1.tmp"
1.71 +
1.72 +# Expect no reply because the recipient must handle the request.
1.73
1.74 - ! grep -q 'METHOD:REPLY' out1.tmp \
1.75 -&& echo "Success" \
1.76 -|| echo "Failed"
1.77 +is_absent 'METHOD:REPLY' "out1.tmp" && success || failed "out1.tmp"
1.78 +
1.79 +# Expect no free/busy periods for the recipient.
1.80
1.81 - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \
1.82 -> out1f.tmp
1.83 +list_script "out1f.tmp" "$USER" "freebusy"
1.84 +test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out1f.tmp"
1.85
1.86 - ! grep -q "event6@example.com" "out1f.tmp" \
1.87 -&& echo "Success" \
1.88 -|| echo "Failed"
1.89 +# Expect free/busy periods for the sender at the recipient.
1.90
1.91 - ! [ -e "$FBOTHERFILE" ] \
1.92 -|| ! grep -q "event6@example.com" "$FBOTHERFILE" \
1.93 -&& echo "Success" \
1.94 -|| echo "Failed"
1.95 +list_script "out1fo.tmp" "$USER" "freebusy_other" "$SENDER"
1.96 +test_freebusy '20141126T150000Z' '20141126T160000Z' "out1fo.tmp"
1.97
1.98 # Counter the invitation.
1.99
1.100 - "$COUNTER_SCRIPT" $COUNTER_ARGS "$USER" 20141126T170000 20141126T180000 "event6@example.com" 2>> $ERROR \
1.101 -| tee out2r.tmp \
1.102 -| "$SHOWMAIL" \
1.103 -> out2.tmp
1.104 +cat > "event_counter_cmd.tmp" <<EOF
1.105 +period 0 edit 20141126 17 00 00 Europe/Oslo 20141126 18 00 00 Europe/Oslo
1.106 +finish
1.107 +update event_counter.tmp
1.108 +EOF
1.109 +
1.110 +text_client_specific "$USER" "event_counter_cmd.tmp" "$UID1"
1.111 +
1.112 +# Expect a counter-proposal from the client.
1.113 +
1.114 + showmail "event_counter.tmp" | is_present 'METHOD:COUNTER' \
1.115 +&& success || failed "event_counter.tmp"
1.116
1.117 # Note that the invitation has only been prepared, not processed.
1.118
1.119 - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \
1.120 -> out2f.tmp
1.121 -
1.122 - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f.tmp" \
1.123 -&& ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out2f.tmp" \
1.124 -&& echo "Success" \
1.125 -|| echo "Failed"
1.126 +list_script "out2f.tmp" "$USER" "freebusy"
1.127 +test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out2f.tmp"
1.128 +test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out2f.tmp"
1.129
1.130 - grep -q 'METHOD:COUNTER' out2.tmp \
1.131 -&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' out2.tmp \
1.132 -&& echo "Success" \
1.133 -|| echo "Failed"
1.134 -
1.135 - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \
1.136 -> out2o.tmp
1.137 -
1.138 - ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out2o.tmp" \
1.139 -&& echo "Success" \
1.140 -|| echo "Failed"
1.141 +list_script "out2fo.tmp" "$USER" "freebusy_offers"
1.142 +test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out2fo.tmp"
1.143
1.144 # Send the counter-proposal.
1.145
1.146 -"$OUTGOING_SCRIPT" $ARGS < out2r.tmp 2>> $ERROR
1.147 +outgoing_script "event_counter.tmp"
1.148
1.149 - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \
1.150 -> out2f2.tmp
1.151 +# Expect no free/busy periods for the recipient.
1.152
1.153 - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f2.tmp" \
1.154 -&& ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out2f2.tmp" \
1.155 -&& echo "Success" \
1.156 -|| echo "Failed"
1.157 +list_script "out2f2.tmp" "$USER" "freebusy"
1.158 +test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out2f2.tmp"
1.159 +test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out2f2.tmp"
1.160
1.161 - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \
1.162 -> out2o2.tmp
1.163 +# Expect a free/busy offer period.
1.164
1.165 - grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out2o2.tmp" \
1.166 -&& echo "Success" \
1.167 -|| echo "Failed"
1.168 +list_script "out2o2.tmp" "$USER" "freebusy_offers"
1.169 +test_freebusy '20141126T160000Z' '20141126T170000Z' "out2o2.tmp"
1.170
1.171 # Present the response to the organiser.
1.172
1.173 - "$PERSON_SCRIPT" $ARGS < out2r.tmp 2>> $ERROR \
1.174 -| tee out3r.tmp \
1.175 -| "$SHOWMAIL" \
1.176 -> out3.tmp
1.177 +person_script "event_counter.tmp" "out3.tmp"
1.178
1.179 - "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy_other" "$USER" \
1.180 -> out3f.tmp
1.181 +# Expect no free/busy periods for the recipient at the sender.
1.182
1.183 - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out3f.tmp" \
1.184 -&& ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out3f.tmp" \
1.185 -&& echo "Success" \
1.186 -|| echo "Failed"
1.187 +list_script "out3f.tmp" "$SENDER" "freebusy_other" "$USER"
1.188 +test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out3f.tmp"
1.189 +test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out3f.tmp"
1.190
1.191 - "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "object" "event6@example.com" \
1.192 -> out3O.tmp
1.193 +# Expect the original object at the sender.
1.194
1.195 - grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T160000' "out3O.tmp" \
1.196 -&& echo "Success" \
1.197 -|| echo "Failed"
1.198 +list_script "out3O.tmp" "$SENDER" "object" "$UID1"
1.199 + is_present 'DTSTART;TZID=Europe/Oslo.*:20141126T160000' "out3O.tmp" \
1.200 +&& success || failed "out3O.tmp"
1.201
1.202 - "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "countered_object" "event6@example.com" "$USER" \
1.203 -> out3C.tmp
1.204 +# Expect the countered object at the sender.
1.205
1.206 - grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' "out3C.tmp" \
1.207 -&& echo "Success" \
1.208 -|| echo "Failed"
1.209 +list_script "out3C.tmp" "$SENDER" "countered_object" "$UID1" "$USER"
1.210 + is_present 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' "out3C.tmp" \
1.211 +&& success || failed "out3C.tmp"
1.212
1.213 - "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "requests" \
1.214 -> out3R.tmp
1.215 +# Expect a request at the sender.
1.216
1.217 - grep -q 'event6@example.com' "out3R.tmp" \
1.218 -&& echo "Success" \
1.219 -|| echo "Failed"
1.220 +list_script "out3R.tmp" "$SENDER" "requests"
1.221 +is_present "$UID1" "out3R.tmp" && success || failed "out3R.tmp"
1.222
1.223 # Check the free/busy state of the recipient so far.
1.224
1.225 - "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \
1.226 -| "$SHOWMAIL" \
1.227 -> out4.tmp
1.228 +person_script "$TEMPLATES/fb-request-person-all.txt" "out4.tmp"
1.229
1.230 - grep -q 'METHOD:REPLY' out4.tmp \
1.231 -&& ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T150000Z/20141126T160000Z' out4.tmp \
1.232 -&& ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T160000Z/20141126T170000Z' out4.tmp \
1.233 -&& echo "Success" \
1.234 -|| echo "Failed"
1.235 + is_present 'METHOD:REPLY' "out4.tmp" \
1.236 +&& is_absent '^FREEBUSY' "out4.tmp" \
1.237 +&& success || failed "out4.tmp"
1.238
1.239 # Decline the counter-proposal.
1.240 +# NOTE: Support this in the client.
1.241
1.242 - sed 's/COUNTER/DECLINECOUNTER/' < out2.tmp \
1.243 -| sed 's/^From: calendar/To: vincent.vole/' \
1.244 -| sed 's/^To: paul.boddie/From: paul.boddie/' \
1.245 -> out5.tmp
1.246 -
1.247 -"$OUTGOING_SCRIPT" $ARGS < out5.tmp 2>> $ERROR
1.248 + showmail "event_counter.tmp" \
1.249 +| sed 's/COUNTER/DECLINECOUNTER/' \
1.250 +| sed "s/^From: $USERADDRESS/To: $USERADDRESS/" \
1.251 +| sed "s/^To: $SENDERADDRESS/From: $SENDERADDRESS/" \
1.252 +> "event_declinecounter.tmp"
1.253
1.254 - "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "countered_object" "event6@example.com" "$USER" \
1.255 -> out5C.tmp
1.256 +outgoing_script "event_declinecounter.tmp"
1.257 +
1.258 +# The countered object should be removed at the sender.
1.259
1.260 - ! grep -q 'event6@example.com' "out5C.tmp" \
1.261 -&& echo "Success" \
1.262 -|| echo "Failed"
1.263 +list_script "out5C.tmp" "$SENDER" "countered_object" "$UID1" "$USER"
1.264 +is_absent "$UID1" "out5C.tmp" && success || failed "out5C.tmp"
1.265
1.266 - "$LIST_SCRIPT" $LIST_ARGS "$USER" "requests" \
1.267 -> out5R.tmp
1.268 +# The request should be removed at the sender.
1.269
1.270 - ! grep -q 'event6@example.com' "out5R.tmp" \
1.271 -&& echo "Success" \
1.272 -|| echo "Failed"
1.273 +list_script "out5R.tmp" "$SENDER" "requests"
1.274 +is_absent "$UID1" "out5R.tmp" && success || failed "out5R.tmp"
1.275
1.276 - "$PERSON_SCRIPT" $ARGS < out5.tmp 2>> $ERROR \
1.277 -| "$SHOWMAIL" \
1.278 -> out6.tmp
1.279 +# Present the decline message to the recipient.
1.280
1.281 - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \
1.282 -> out6f.tmp
1.283 +person_script "event_declinecounter.tmp" "out6.tmp"
1.284 +
1.285 +# Expect no free/busy periods at the recipient.
1.286
1.287 - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out6f.tmp" \
1.288 -&& ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out6f.tmp" \
1.289 -&& echo "Success" \
1.290 -|| echo "Failed"
1.291 +list_script "out6f.tmp" "$USER" "freebusy"
1.292 +test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out6f.tmp"
1.293 +test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out6f.tmp"
1.294
1.295 - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \
1.296 -> out6o.tmp
1.297 +# Expect no free/busy offers at the recipient.
1.298
1.299 - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out6o.tmp" \
1.300 -&& ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out6o.tmp" \
1.301 -&& echo "Success" \
1.302 -|| echo "Failed"
1.303 +list_script "out6o.tmp" "$USER" "freebusy_offers"
1.304 +test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out6o.tmp"
1.305 +test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out6o.tmp"