# HG changeset patch # User Paul Boddie # Date 1515860802 -3600 # Node ID 77bcb48a11e8747d22634c083ab668f408f1e4bd # Parent 1550293500d7b6608c2dd8aea12728db2e4e6837 Introduced common testing helper functions and some usage of the text client to automate interactions between test calendar users. diff -r 1550293500d7 -r 77bcb48a11e8 tests/common.sh --- a/tests/common.sh Sat Jan 13 17:25:04 2018 +0100 +++ b/tests/common.sh Sat Jan 13 17:26:42 2018 +0100 @@ -38,6 +38,106 @@ PYTHONPATH="$BASE_DIR" export PYTHONPATH + + +# Helper functions. + +failed() { + # [ ] + echo -n "Failed" + if [ "$1" ]; then + echo ": $1" + else + echo + fi +} + +success() { + echo "Success" +} + +is_absent() { + # [ ] + if [ "$2" ]; then + ! grep -q "$1" "$2" + else + ! grep -q "$1" + fi +} + +is_present() { + # [ ] + if [ "$2" ]; then + grep -q "$1" "$2" + else + grep -q "$1" + fi +} + +list_script() { + # ... + FILENAME=$1 + shift 1 + "$LIST_SCRIPT" $LIST_ARGS $* > "$FILENAME" +} + +outgoing_script() { + # [ ] + if [ "$1" ]; then + "$OUTGOING_SCRIPT" < "$1" $ARGS 2>> $ERROR + else + "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR + fi +} + +person_script() { + # [ ] + OUTFILE="$3" + "$PERSON_SCRIPT" $ARGS < "$1" 2>> $ERROR \ + | tee $OUTFILE \ + | "$SHOWMAIL" \ + > "$2" +} + +showmail() { + # + "$SHOWMAIL" < "$1" +} + +test_freebusy() { + # + is_present "^$1${TAB}$2" "$3" && success || failed "$3" +} + +test_freebusy_missing() { + # + is_absent "^$1${TAB}$2" "$3" && success || failed "$3" +} + +text_client() { + # [ ] + LOG=`basename "$2" .tmp`_log.tmp + if [ "$3" ]; then + "$TEXT_CLIENT" $ARGS -u "$1" -f "$3" --echo < "$2" > "$LOG" + else + "$TEXT_CLIENT" $ARGS -u "$1" --echo < "$2" > "$LOG" + fi +} + +text_client_specific() { + # [ ] + LOG=`basename "$2" .tmp`_log.tmp + if [ "$4" ]; then + "$TEXT_CLIENT" $ARGS -u "$1" --uid "$3" --recurrence-id "$4" --echo < "$2" > "$LOG" + else + "$TEXT_CLIENT" $ARGS -u "$1" --uid "$3" --echo < "$2" > "$LOG" + fi +} + + + +# Test environment initialisation. + if [ "$STORE_TYPE" = "file" ]; then rm -rf "$STORE" rm -rf "$JOURNAL" diff -r 1550293500d7 -r 77bcb48a11e8 tests/test_person_invitation.sh --- a/tests/test_person_invitation.sh Sat Jan 13 17:25:04 2018 +0100 +++ b/tests/test_person_invitation.sh Sat Jan 13 17:26:42 2018 +0100 @@ -11,33 +11,27 @@ # Present a free/busy request for all periods to the recipient. - "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \ -| "$SHOWMAIL" \ -> out0.tmp +person_script "$TEMPLATES/fb-request-person-all.txt" "out0.tmp" # Expect a reply with no periods. - grep -q 'METHOD:REPLY' out0.tmp \ -&& ! grep -q '^FREEBUSY' out0.tmp \ -&& echo "Success" \ -|| echo "Failed" + is_present 'METHOD:REPLY' "out0.tmp" \ +&& is_absent '^FREEBUSY' "out0.tmp" \ +&& success || failed "out0.tmp" # Present a free/busy request for periods of interest to the recipient. - "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person.txt" 2>> $ERROR \ -| "$SHOWMAIL" \ -> out1.tmp +person_script "$TEMPLATES/fb-request-person.txt" "out1.tmp" # Expect a reply with no periods. - grep -q 'METHOD:REPLY' out1.tmp \ -&& ! grep -q '^FREEBUSY' out1.tmp \ -&& echo "Success" \ -|| echo "Failed" + is_present 'METHOD:REPLY' "out1.tmp" \ +&& is_absent '^FREEBUSY' "out1.tmp" \ +&& success || failed "out1.tmp" # Make a new event. - cat > event_cmd.tmp < "event_cmd.tmp" < event_log.tmp +text_client "$SENDER" "event_cmd.tmp" # Obtain the event UID. - read UID1 < event_uid.tmp +read UID1 < "event_uid.tmp" # Register the event at the sender. - "$OUTGOING_SCRIPT" < event.tmp $ARGS 2>> $ERROR +outgoing_script "event_self.tmp" # Present the event to the recipient. - "$PERSON_SCRIPT" $ARGS < event.tmp 2>> $ERROR \ -| "$SHOWMAIL" \ -> out2.tmp +person_script "event.tmp" "out2.tmp" # Expect no reply because the recipient must handle the request. - ! grep -q 'METHOD:REPLY' out2.tmp \ -&& echo "Success" \ -|| echo "Failed" +is_absent 'METHOD:REPLY' "out2.tmp" && success || failed "out2.tmp" # Expect no free/busy periods for the recipient. - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ -> out2f.tmp - - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" out2f.tmp \ -&& echo "Success" \ -|| echo "Failed" +list_script "out2f.tmp" "$USER" "freebusy" +test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out2f.tmp" # Expect free/busy periods for the sender at the recipient. - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_other" "$SENDER" \ -> out2fo.tmp - - grep -q "^20141126T150000Z${TAB}20141126T160000Z" out2fo.tmp \ -&& echo "Success" \ -|| echo "Failed" +list_script "out2fo.tmp" "$USER" "freebusy_other" "$SENDER" +test_freebusy '20141126T150000Z' '20141126T160000Z' "out2fo.tmp" # Accept the invitation. - cat > event_accept_cmd.tmp < "event_accept_cmd.tmp" < event_accept_log.tmp +text_client_specific "$USER" "event_accept_cmd.tmp" "$UID1" # Register the acceptance at the recipient. - "$OUTGOING_SCRIPT" < event_accept.tmp $ARGS 2>> $ERROR +outgoing_script "event_accept.tmp" # Expect free/busy periods at the recipient. - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ -> out3f.tmp - - grep -q "^20141126T150000Z${TAB}20141126T160000Z" out3f.tmp \ -&& echo "Success" \ -|| echo "Failed" +list_script "out3f.tmp" "$USER" "freebusy" +test_freebusy '20141126T150000Z' '20141126T160000Z' "out3f.tmp" # Make another event at the same time. - sed \ +sed \ 's/summary Meeting at 4pm/summary A conflicting meeting at 4pm/;'\ 's/update event.tmp/update event_conflicting.tmp/;'\ -'s/UID event_uid.tmp/UID event_conflicting_uid.tmp/' event_cmd.tmp \ -> event_conflicting_cmd.tmp +'s/UID event_uid.tmp/UID event_conflicting_uid.tmp/' "event_cmd.tmp" \ +> "event_conflicting_cmd.tmp" - "$TEXT_CLIENT" $ARGS -u "$SENDER" --echo \ -< event_conflicting_cmd.tmp \ -> event_conflicting_log.tmp +text_client "$SENDER" "event_conflicting_cmd.tmp" # Obtain the event UID. - read UID2 < event_conflicting_uid.tmp +read UID2 < "event_conflicting_uid.tmp" # Present the event to the recipient. - "$PERSON_SCRIPT" $ARGS < event_conflicting.tmp 2>> $ERROR \ -| "$SHOWMAIL" \ -> out4.tmp +person_script "event_conflicting.tmp" "out4.tmp" # Expect no reply because the recipient must handle the request. - ! grep -q 'METHOD:REPLY' out4.tmp \ -&& echo "Success" \ -|| echo "Failed" +is_absent 'METHOD:REPLY' "out4.tmp" && success || failed "out4.tmp" # Expect no free/busy periods for the recipient for this event. - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ -> out4f.tmp - - ! grep -q "$UID2" out4f.tmp \ -&& echo "Success" \ -|| echo "Failed" +list_script "out4f.tmp" "$USER" "freebusy" +is_absent "$UID2" "out4f.tmp" && success || failed "out4f.tmp" # Expect free/busy periods for the sender at the recipient for this event. - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_other" "$SENDER" \ -> out4fo.tmp - - grep -q "$UID2" out4fo.tmp \ -&& echo "Success" \ -|| echo "Failed" +list_script "out4fo.tmp" "$USER" "freebusy_other" "$SENDER" +is_present "$UID2" "out4fo.tmp" && success || failed "out4fo.tmp" # Decline the invitation. - cat > event_decline_cmd.tmp < "event_decline_cmd.tmp" < event_decline_log.tmp +text_client_specific "$USER" "event_decline_cmd.tmp" "$UID2" # Register the rejection at the recipient. - "$OUTGOING_SCRIPT" < event_decline.tmp $ARGS 2>> $ERROR +outgoing_script "event_decline.tmp" # Expect free/busy periods only for the original event, not the last one. - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ -> out5f.tmp - - grep -q "$UID1" out5f.tmp \ -&& ! grep -q "$UID2" out5f.tmp \ -&& echo "Success" \ -|| echo "Failed" + list_script "out5f.tmp" "$USER" "freebusy" + is_present "$UID1" "out5f.tmp" \ +&& is_absent "$UID2" "out5f.tmp" \ +&& success || failed "out5f.tmp" # Cancel the event for a recipient. - cat > event_cancel_cmd.tmp < "event_cancel_cmd.tmp" < event_cancel_log.tmp +text_client_specific "$SENDER" "event_cancel_cmd.tmp" "$UID1" # Present the cancellation to the recipient. - "$PERSON_SCRIPT" $ARGS < event_cancel.tmp 2>> $ERROR \ -| "$SHOWMAIL" \ -> out6.tmp +person_script "event_cancel.tmp" "out6.tmp" # Expect no reply because the recipient must handle the request. - ! grep -q 'METHOD:REPLY' out6.tmp \ -&& echo "Success" \ -|| echo "Failed" +is_absent 'METHOD:REPLY' "out6.tmp" && success || failed "out6.tmp" # Expect no free/busy periods for the recipient. - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ -> out6f.tmp - - ! grep -q "$UID1" out6f.tmp \ -&& echo "Success" \ -|| echo "Failed" +list_script "out6f.tmp" "$USER" "freebusy" +is_absent "$UID1" "out6f.tmp" && success || failed "out6f.tmp" # Expect free/busy periods for the sender at the recipient for this event since # only the recipient was uninvited. - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_other" "$SENDER" \ -> out6fo.tmp - - grep -q "$UID1" out6fo.tmp \ -&& echo "Success" \ -|| echo "Failed" +list_script "out6fo.tmp" "$USER" "freebusy_other" "$SENDER" +is_present "$UID1" "out6fo.tmp" && success || failed "out6fo.tmp" # Cancel the event for all recipients. - cat > event_cancel_all_cmd.tmp < "event_cancel_all_cmd.tmp" < event_cancel_all_log.tmp +text_client_specific "$SENDER" "event_cancel_all_cmd.tmp" "$UID1" # Present the cancellation to the recipient. - "$PERSON_SCRIPT" $ARGS < "event_cancel_all.tmp" 2>> $ERROR \ -| "$SHOWMAIL" \ -> out7.tmp +person_script "event_cancel_all.tmp" "out7.tmp" # Expect no reply because the recipient must handle the request. - ! grep -q 'METHOD:REPLY' out7.tmp \ -&& echo "Success" \ -|| echo "Failed" +is_absent 'METHOD:REPLY' "out7.tmp" && success || failed "out7.tmp" # Expect no free/busy periods for the recipient. - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ -> out7f.tmp - - ! grep -q "$UID1" "out7f.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out7f.tmp" "$USER" "freebusy" +is_absent "$UID1" "out7f.tmp" && success || failed "out7f.tmp" # Expect no free/busy periods for the sender at the recipient for this event. - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_other" "$SENDER" \ -> out7fo.tmp - - ! grep -q "$UID1" "out7fo.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out7fo.tmp" "$USER" "freebusy_other" "$SENDER" +is_absent "$UID1" "out7fo.tmp" && success || failed "out7fo.tmp" # Create a message from another sender that is largely a copy of the original # event trying to organise the event using someone else's identity. - sed \ +sed \ 's/summary Meeting at 4pm/summary A spoofed meeting at 4pm/;'\ 's/update event.tmp/update event_spoofed.tmp/;'\ -'s/UID event_uid.tmp/UID event_spoofed_uid.tmp/' event_cmd.tmp \ -> event_spoofed_cmd.tmp +'s/UID event_uid.tmp/UID event_spoofed_uid.tmp/' "event_cmd.tmp" \ +> "event_spoofed_cmd.tmp" - "$TEXT_CLIENT" $ARGS -u "$SENDER" --echo \ -< event_spoofed_cmd.tmp \ -> event_spoofed_log.tmp +text_client "$SENDER" "event_spoofed_cmd.tmp" # Obtain the event UID. - read UID3 < event_spoofed_uid.tmp +read UID3 < "event_spoofed_uid.tmp" - sed 's/From: paul.boddie/From: harvey.horse/' event_spoofed.tmp \ -> event_spoofed_ready.tmp +sed 's/From: paul.boddie/From: harvey.horse/' "event_spoofed.tmp" \ +> "event_spoofed_ready.tmp" # Present the event to the recipient. - "$PERSON_SCRIPT" $ARGS < "event_spoofed_ready.tmp" 2>> $ERROR \ -| "$SHOWMAIL" \ -> out8.tmp +person_script "event_spoofed_ready.tmp" "out8.tmp" # Expect no reply because the recipient must handle the request. - ! grep -q 'METHOD:REPLY' out8.tmp \ -&& echo "Success" \ -|| echo "Failed" +is_absent 'METHOD:REPLY' "out8.tmp" && success || failed "out8.tmp" # Expect no free/busy periods for the recipient. - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ -> out8f.tmp - - ! grep -q "$UID3" "out8f.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out8f.tmp" "$USER" "freebusy" +is_absent "$UID3" "out8f.tmp" && success || failed "out8f.tmp" # Expect no free/busy periods for the sender at the recipient. - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_other" "$SENDER" \ -> out8fo.tmp - - ! grep -q "$UID3" "out8fo.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out8fo.tmp" "$USER" "freebusy_other" "$SENDER" +is_absent "$UID3" "out8fo.tmp" && success || failed "out8fo.tmp" diff -r 1550293500d7 -r 77bcb48a11e8 tests/test_person_invitation_add.sh --- a/tests/test_person_invitation_add.sh Sat Jan 13 17:25:04 2018 +0100 +++ b/tests/test_person_invitation_add.sh Sat Jan 13 17:26:42 2018 +0100 @@ -13,168 +13,183 @@ echo 'Europe/Oslo' > "$PREFS/$USER/TZID" echo 'always' > "$PREFS/$SENDER/event_refreshing" -# Test event request registration in the outgoing handler. - -"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring.txt" 2>> $ERROR - - "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ -> out1f.tmp - - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "out1f.tmp" \ -&& echo "Success" \ -|| echo "Failed" - -# Present the request to the recipient. - - "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring.txt" 2>> $ERROR \ -| "$SHOWMAIL" \ -> out2.tmp - - ! grep -q 'METHOD:REPLY' out2.tmp \ -&& echo "Success" \ -|| echo "Failed" - - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ -> out2f.tmp - - ! grep -q "^20141212T090000Z${TAB}20141212T100000Z" "out2f.tmp" \ -&& echo "Success" \ -|| echo "Failed" - - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_other" "$SENDER" \ -> out2fo.tmp - - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "out2fo.tmp" \ -&& echo "Success" \ -|| echo "Failed" - -# Test acceptance and registration in the outgoing handler. +# Make a new event. - "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" 2>> $ERROR \ -| tee out3.tmp \ -| "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR - - "$SHOWMAIL" < out3.tmp | grep -q 'METHOD:REPLY' \ -&& echo "Success" \ -|| echo "Failed" - - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ -> out3f.tmp - - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "out3f.tmp" \ -&& echo "Success" \ -|| echo "Failed" - -# Present the result to the recipient. +cat > "event_cmd.tmp" <> $ERROR \ -| "$SHOWMAIL" \ -> out4.tmp +text_client "$SENDER" "event_cmd.tmp" - "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy_other" "$USER" \ -> out4fo.tmp +# Obtain the event UID. - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "out4fo.tmp" \ -&& echo "Success" \ -|| echo "Failed" +read UID1 < "event_uid.tmp" -# Attempt to add an occurrence to the event. +# Register the event at the sender. -"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-add-person-recurring.txt" 2>> $ERROR +outgoing_script "event_self.tmp" - "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ -> out4f.tmp +# Expect free/busy periods for the sender. - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "out4f.tmp" \ -&& grep -q "^20150109T090000Z${TAB}20150109T100000Z" "out4f.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out1f.tmp" "$SENDER" "freebusy" +test_freebusy '20141212T090000Z' '20141212T100000Z' "out1f.tmp" # Present the request to the recipient. - "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-add-person-recurring.txt" 2>> $ERROR \ -| "$SHOWMAIL" \ -> out5.tmp +person_script "event.tmp" "out2.tmp" + +# Expect no reply because the recipient must handle the request. + +is_absent 'METHOD:REPLY' "out2.tmp" && success || failed "out2.tmp" + +# Expect no free/busy periods for the recipient. - grep -q 'METHOD:REFRESH' out5.tmp \ -&& echo "Success" \ -|| echo "Failed" +list_script "out2f.tmp" "$USER" "freebusy" +test_freebusy_missing '20141212T090000Z' '20141212T100000Z' "out2f.tmp" + +# Expect free/busy periods for the sender at the recipient. + +list_script "out2fo.tmp" "$USER" "freebusy_other" "$SENDER" +test_freebusy '20141212T090000Z' '20141212T100000Z' "out2fo.tmp" - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ -> out5f.tmp +# Accept the invitation. + +cat > "event_accept_cmd.tmp" < out5fo.tmp + showmail "event_accept.tmp" | is_present 'METHOD:REPLY' \ +&& success || failed "event_accept.tmp" + +# Expect free/busy periods at the recipient. + +list_script "out3f.tmp" "$USER" "freebusy" +test_freebusy '20141212T090000Z' '20141212T100000Z' "out3f.tmp" - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "out5fo.tmp" \ -&& ! grep -q "^20150109T090000Z${TAB}20150109T100000Z" "out5fo.tmp" \ -&& echo "Success" \ -|| echo "Failed" +# Present the result to the sender. + +person_script "event_accept.tmp" "out4.tmp" + +# Expect free/busy periods at the sender for the recipient. + +list_script "out4fo.tmp" "$SENDER" "freebusy_other" "$USER" +test_freebusy '20141212T090000Z' '20141212T100000Z' "out4fo.tmp" -# Present the refresh message to the organiser. +# Attempt to add an occurrence to the event. + +cat > "event_cmd2.tmp" <> $ERROR \ -| tee out6r.tmp \ -| "$SHOWMAIL" \ -> out6.tmp +# Register the new occurrence at the sender. + +outgoing_script "event_add.tmp" - grep -q 'METHOD:REQUEST' out6.tmp \ -&& echo "Success" \ -|| echo "Failed" +# Expect free/busy periods for the event at the sender. + +list_script "out4f.tmp" "$SENDER" "freebusy" +test_freebusy '20141212T090000Z' '20141212T100000Z' "out4f.tmp" +test_freebusy '20150109T090000Z' '20150109T100000Z' "out4f.tmp" # Present the request to the recipient. - "$PERSON_SCRIPT" $ARGS < out6r.tmp 2>> $ERROR \ -| "$SHOWMAIL" \ -> out7.tmp +person_script "event_add.tmp" "out5.tmp" + +# Expect a response demanding a refreshed event. + +is_present 'METHOD:REFRESH' "out5.tmp" && success || failed "out5.tmp" + +# Expect no new free/busy period for the event at the recipient. - ! grep -q 'METHOD:REPLY' out7.tmp \ -&& echo "Success" \ -|| echo "Failed" +list_script "out5f.tmp" "$USER" "freebusy" +test_freebusy '20141212T090000Z' '20141212T100000Z' "out5f.tmp" +test_freebusy_missing '20150109T090000Z' '20150109T100000Z' "out5f.tmp" - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ -> out7f.tmp +list_script "out5fo.tmp" "$USER" "freebusy_other" "$SENDER" +test_freebusy '20141212T090000Z' '20141212T100000Z' "out5fo.tmp" +test_freebusy_missing '20150109T090000Z' '20150109T100000Z' "out5fo.tmp" + +# Present the refresh message to the organiser. + +person_script "out5.tmp" "out6.tmp" "out6r.tmp" + +# Expect a new event request from the organiser. - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "out7f.tmp" \ -&& ! grep -q "^20150109T090000Z${TAB}20150109T100000Z" "out7f.tmp" \ -&& echo "Success" \ -|| echo "Failed" +is_present 'METHOD:REQUEST' "out6.tmp" && success || failed "out6.tmp" + +# Present the request to the recipient. + +person_script "out6r.tmp" "out7.tmp" + +# Expect no reply because the recipient must handle the request. + +is_absent 'METHOD:REPLY' "out7.tmp" && success || failed "out7.tmp" - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_other" "$SENDER" \ -> out7fo.tmp +# Expect no new free/busy period for the event at the recipient. + +list_script "out7f.tmp" "$USER" "freebusy" +test_freebusy '20141212T090000Z' '20141212T100000Z' "out7f.tmp" +test_freebusy_missing '20150109T090000Z' '20150109T100000Z' "out7f.tmp" - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "out7fo.tmp" \ -&& grep -q "^20150109T090000Z${TAB}20150109T100000Z" "out7fo.tmp" \ -&& echo "Success" \ -|| echo "Failed" +# Expect the new free/busy period for the sender at the recipient. + +list_script "out7fo.tmp" "$USER" "freebusy_other" "$SENDER" +test_freebusy '20141212T090000Z' '20141212T100000Z' "out7fo.tmp" +test_freebusy '20150109T090000Z' '20150109T100000Z' "out7fo.tmp" # Test acceptance and registration in the outgoing handler. - "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" 2>> $ERROR \ -| tee out8.tmp \ -| "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR +text_client_specific "$USER" "event_accept_cmd.tmp" "$UID1" +outgoing_script "event_accept.tmp" + +# Accept the invitation. - "$SHOWMAIL" < out8.tmp | grep -q 'METHOD:REPLY' \ -&& echo "Success" \ -|| echo "Failed" +cat > "event_accept_cmd2.tmp" <> $ERROR \ -| tee out9.tmp \ -| "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR +text_client_specific "$USER" "event_accept_cmd2.tmp" "$UID1" '20150109T090000Z' - "$SHOWMAIL" < out9.tmp | grep -q 'METHOD:REPLY' \ -&& echo "Success" \ -|| echo "Failed" +# Register the acceptance at the recipient. + +outgoing_script "event_accept2.tmp" + +# Test the nature of the acceptance message. - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ -> out9f.tmp + showmail "event_accept2.tmp" | is_present 'METHOD:REPLY' \ +&& success || failed "event_accept2.tmp" - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "out9f.tmp" \ -&& grep -q "^20150109T090000Z${TAB}20150109T100000Z" "out9f.tmp" \ -&& echo "Success" \ -|| echo "Failed" +# Expect the new free/busy period at the recipient. + +list_script "out9f.tmp" "$USER" "freebusy" +test_freebusy '20141212T090000Z' '20141212T100000Z' "out9f.tmp" +test_freebusy '20150109T090000Z' '20150109T100000Z' "out9f.tmp" diff -r 1550293500d7 -r 77bcb48a11e8 tests/test_person_invitation_counter.sh --- a/tests/test_person_invitation_counter.sh Sat Jan 13 17:25:04 2018 +0100 +++ b/tests/test_person_invitation_counter.sh Sat Jan 13 17:26:42 2018 +0100 @@ -4,189 +4,174 @@ USER="mailto:vincent.vole@example.com" SENDER="mailto:paul.boddie@example.com" +USERADDRESS="vincent.vole@example.com" +SENDERADDRESS="paul.boddie@example.com" mkdir -p "$PREFS/$USER" echo 'Europe/Oslo' > "$PREFS/$USER/TZID" echo 'share' > "$PREFS/$USER/freebusy_sharing" echo 'PT60S' > "$PREFS/$USER/freebusy_offers" - "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \ -| "$SHOWMAIL" \ -> out0.tmp +person_script "$TEMPLATES/fb-request-person-all.txt" "out0.tmp" - grep -q 'METHOD:REPLY' out0.tmp \ -&& ! grep -q '^FREEBUSY' out0.tmp \ -&& echo "Success" \ -|| echo "Failed" + is_present 'METHOD:REPLY' "out0.tmp" \ +&& is_absent '^FREEBUSY' "out0.tmp" \ +&& success || failed "out0.tmp" + +# Make a new event. -# Attempt to schedule an event. - -"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person.txt" 2>> $ERROR +cat > "event_cmd.tmp" < out0f.tmp +text_client "$SENDER" "event_cmd.tmp" + +# Obtain the event UID. + +read UID1 < "event_uid.tmp" - grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out0f.tmp" \ -&& echo "Success" \ -|| echo "Failed" +# Register the event at the sender. + +outgoing_script "event.tmp" + +# Expect free/busy periods at the sender. + +list_script "out0f.tmp" "$SENDER" "freebusy" +test_freebusy '20141126T150000Z' '20141126T160000Z' "out0f.tmp" # Present the request to the recipient. - "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person.txt" 2>> $ERROR \ -| "$SHOWMAIL" \ -> out1.tmp +person_script "event.tmp" "out1.tmp" + +# Expect no reply because the recipient must handle the request. - ! grep -q 'METHOD:REPLY' out1.tmp \ -&& echo "Success" \ -|| echo "Failed" +is_absent 'METHOD:REPLY' "out1.tmp" && success || failed "out1.tmp" + +# Expect no free/busy periods for the recipient. - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ -> out1f.tmp +list_script "out1f.tmp" "$USER" "freebusy" +test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out1f.tmp" - ! grep -q "event6@example.com" "out1f.tmp" \ -&& echo "Success" \ -|| echo "Failed" +# Expect free/busy periods for the sender at the recipient. - ! [ -e "$FBOTHERFILE" ] \ -|| ! grep -q "event6@example.com" "$FBOTHERFILE" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out1fo.tmp" "$USER" "freebusy_other" "$SENDER" +test_freebusy '20141126T150000Z' '20141126T160000Z' "out1fo.tmp" # Counter the invitation. - "$COUNTER_SCRIPT" $COUNTER_ARGS "$USER" 20141126T170000 20141126T180000 "event6@example.com" 2>> $ERROR \ -| tee out2r.tmp \ -| "$SHOWMAIL" \ -> out2.tmp +cat > "event_counter_cmd.tmp" < out2f.tmp - - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f.tmp" \ -&& ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out2f.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out2f.tmp" "$USER" "freebusy" +test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out2f.tmp" +test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out2f.tmp" - grep -q 'METHOD:COUNTER' out2.tmp \ -&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' out2.tmp \ -&& echo "Success" \ -|| echo "Failed" - - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \ -> out2o.tmp - - ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out2o.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out2fo.tmp" "$USER" "freebusy_offers" +test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out2fo.tmp" # Send the counter-proposal. -"$OUTGOING_SCRIPT" $ARGS < out2r.tmp 2>> $ERROR +outgoing_script "event_counter.tmp" - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ -> out2f2.tmp +# Expect no free/busy periods for the recipient. - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f2.tmp" \ -&& ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out2f2.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out2f2.tmp" "$USER" "freebusy" +test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out2f2.tmp" +test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out2f2.tmp" - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \ -> out2o2.tmp +# Expect a free/busy offer period. - grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out2o2.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out2o2.tmp" "$USER" "freebusy_offers" +test_freebusy '20141126T160000Z' '20141126T170000Z' "out2o2.tmp" # Present the response to the organiser. - "$PERSON_SCRIPT" $ARGS < out2r.tmp 2>> $ERROR \ -| tee out3r.tmp \ -| "$SHOWMAIL" \ -> out3.tmp +person_script "event_counter.tmp" "out3.tmp" - "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy_other" "$USER" \ -> out3f.tmp +# Expect no free/busy periods for the recipient at the sender. - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out3f.tmp" \ -&& ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out3f.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out3f.tmp" "$SENDER" "freebusy_other" "$USER" +test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out3f.tmp" +test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out3f.tmp" - "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "object" "event6@example.com" \ -> out3O.tmp +# Expect the original object at the sender. - grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T160000' "out3O.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out3O.tmp" "$SENDER" "object" "$UID1" + is_present 'DTSTART;TZID=Europe/Oslo.*:20141126T160000' "out3O.tmp" \ +&& success || failed "out3O.tmp" - "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "countered_object" "event6@example.com" "$USER" \ -> out3C.tmp +# Expect the countered object at the sender. - grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' "out3C.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out3C.tmp" "$SENDER" "countered_object" "$UID1" "$USER" + is_present 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' "out3C.tmp" \ +&& success || failed "out3C.tmp" - "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "requests" \ -> out3R.tmp +# Expect a request at the sender. - grep -q 'event6@example.com' "out3R.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out3R.tmp" "$SENDER" "requests" +is_present "$UID1" "out3R.tmp" && success || failed "out3R.tmp" # Check the free/busy state of the recipient so far. - "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \ -| "$SHOWMAIL" \ -> out4.tmp +person_script "$TEMPLATES/fb-request-person-all.txt" "out4.tmp" - grep -q 'METHOD:REPLY' out4.tmp \ -&& ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T150000Z/20141126T160000Z' out4.tmp \ -&& ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T160000Z/20141126T170000Z' out4.tmp \ -&& echo "Success" \ -|| echo "Failed" + is_present 'METHOD:REPLY' "out4.tmp" \ +&& is_absent '^FREEBUSY' "out4.tmp" \ +&& success || failed "out4.tmp" # Decline the counter-proposal. +# NOTE: Support this in the client. - sed 's/COUNTER/DECLINECOUNTER/' < out2.tmp \ -| sed 's/^From: calendar/To: vincent.vole/' \ -| sed 's/^To: paul.boddie/From: paul.boddie/' \ -> out5.tmp - -"$OUTGOING_SCRIPT" $ARGS < out5.tmp 2>> $ERROR + showmail "event_counter.tmp" \ +| sed 's/COUNTER/DECLINECOUNTER/' \ +| sed "s/^From: $USERADDRESS/To: $USERADDRESS/" \ +| sed "s/^To: $SENDERADDRESS/From: $SENDERADDRESS/" \ +> "event_declinecounter.tmp" - "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "countered_object" "event6@example.com" "$USER" \ -> out5C.tmp +outgoing_script "event_declinecounter.tmp" + +# The countered object should be removed at the sender. - ! grep -q 'event6@example.com' "out5C.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out5C.tmp" "$SENDER" "countered_object" "$UID1" "$USER" +is_absent "$UID1" "out5C.tmp" && success || failed "out5C.tmp" - "$LIST_SCRIPT" $LIST_ARGS "$USER" "requests" \ -> out5R.tmp +# The request should be removed at the sender. - ! grep -q 'event6@example.com' "out5R.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out5R.tmp" "$SENDER" "requests" +is_absent "$UID1" "out5R.tmp" && success || failed "out5R.tmp" - "$PERSON_SCRIPT" $ARGS < out5.tmp 2>> $ERROR \ -| "$SHOWMAIL" \ -> out6.tmp +# Present the decline message to the recipient. - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ -> out6f.tmp +person_script "event_declinecounter.tmp" "out6.tmp" + +# Expect no free/busy periods at the recipient. - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out6f.tmp" \ -&& ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out6f.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out6f.tmp" "$USER" "freebusy" +test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out6f.tmp" +test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out6f.tmp" - "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \ -> out6o.tmp +# Expect no free/busy offers at the recipient. - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out6o.tmp" \ -&& ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out6o.tmp" \ -&& echo "Success" \ -|| echo "Failed" +list_script "out6o.tmp" "$USER" "freebusy_offers" +test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out6o.tmp" +test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out6o.tmp"