# HG changeset patch # User Paul Boddie # Date 1454970388 -3600 # Node ID 9d7567e5675c1f88cf89dd280d6de541b8644882 # Parent 55e081ac6f189b9e141892115637cc04cd975213 Added a test of simultaneous resource booking with recurring events and differing organiser quota limits. diff -r 55e081ac6f18 -r 9d7567e5675c tests/templates/event-cancel-cars-recurring.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/templates/event-cancel-cars-recurring.txt Mon Feb 08 23:26:28 2016 +0100 @@ -0,0 +1,38 @@ +Content-Type: multipart/alternative; boundary="===============0047278175==" +MIME-Version: 1.0 +From: paul.boddie@example.com +To: resource-car-porsche911@example.com, resource-car-fiat500@example.com +Subject: Cancellation! + +Cancel the event completely. + +--===============0047278175== +Content-Type: text/plain; charset="us-ascii" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit + +This message contains an event. +--===============0047278175== +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/calendar; charset="us-ascii"; method="CANCEL" + +BEGIN:VCALENDAR +PRODID:-//imip-agent/test//EN +METHOD:CANCEL +VERSION:2.0 +BEGIN:VEVENT +ORGANIZER:mailto:paul.boddie@example.com +ATTENDEE:mailto:paul.boddie@example.com +ATTENDEE;RSVP=TRUE:mailto:resource-car-porsche911@example.com +ATTENDEE;RSVP=TRUE:mailto:resource-car-fiat500@example.com +DTSTAMP:20141125T004600Z +DTSTART;TZID=Europe/Oslo:20141126T160000 +DTEND;TZID=Europe/Oslo:20141126T170000 +RRULE:FREQ=DAILY +SUMMARY:Test drives +UID:event25@example.com +END:VEVENT +END:VCALENDAR + +--===============0047278175==-- diff -r 55e081ac6f18 -r 9d7567e5675c tests/templates/event-request-cars-recurring.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/templates/event-request-cars-recurring.txt Mon Feb 08 23:26:28 2016 +0100 @@ -0,0 +1,37 @@ +Content-Type: multipart/alternative; boundary="===============0047278175==" +MIME-Version: 1.0 +From: paul.boddie@example.com +To: resource-car-porsche911@example.com, resource-car-fiat500@example.com +Subject: Invitation! + +--===============0047278175== +Content-Type: text/plain; charset="us-ascii" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit + +This message contains a recurring event reserving two resources at once. + +--===============0047278175== +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/calendar; charset="us-ascii"; method="REQUEST" + +BEGIN:VCALENDAR +PRODID:-//imip-agent/test//EN +METHOD:REQUEST +VERSION:2.0 +BEGIN:VEVENT +ORGANIZER:mailto:paul.boddie@example.com +ATTENDEE;ROLE=CHAIR:mailto:paul.boddie@example.com +ATTENDEE;RSVP=TRUE:mailto:resource-car-porsche911@example.com +ATTENDEE;RSVP=TRUE:mailto:resource-car-fiat500@example.com +DTSTAMP:20141125T004600Z +DTSTART;TZID=Europe/Oslo:20141126T160000 +DTEND;TZID=Europe/Oslo:20141126T170000 +RRULE:FREQ=DAILY +SUMMARY:Test drives +UID:event25@example.com +END:VEVENT +END:VCALENDAR + +--===============0047278175==-- diff -r 55e081ac6f18 -r 9d7567e5675c tests/test_resource_invitation_constraints_quota_recurring_limits.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_resource_invitation_constraints_quota_recurring_limits.sh Mon Feb 08 23:26:28 2016 +0100 @@ -0,0 +1,240 @@ +#!/bin/sh + +. "`dirname \"$0\"`/common.sh" + +USER1="mailto:resource-car-porsche911@example.com" +USER2="mailto:resource-car-fiat500@example.com" +SENDER1="mailto:paul.boddie@example.com" +SENDER2="mailto:vincent.vole@example.com" +SENDERADDRESS1="paul.boddie@example.com" +SENDERADDRESS2="vincent.vole@example.com" +FBFILE1="$STORE/$USER1/freebusy" +FBFILE2="$STORE/$USER2/freebusy" +FBSENDERFILE1="$STORE/$SENDER1/freebusy" +FBSENDERFILE2="$STORE/$SENDER2/freebusy" +QUOTA=cars +JOURNALFILE1="$JOURNAL/$QUOTA/journal/$SENDER1" +JOURNALFILE2="$JOURNAL/$QUOTA/journal/$SENDER2" + +mkdir -p "$PREFS/$USER1" +echo 'Europe/Oslo' > "$PREFS/$USER1/TZID" +echo 'share' > "$PREFS/$USER1/freebusy_sharing" +cat > "$PREFS/$USER1/scheduling_function" < "$PREFS/$USER1/confirmation_function" < "$PREFS/$USER1/retraction_function" < "$PREFS/$USER2/TZID" +echo 'share' > "$PREFS/$USER2/freebusy_sharing" +cat > "$PREFS/$USER2/scheduling_function" < "$PREFS/$USER2/confirmation_function" < "$PREFS/$USER2/retraction_function" < "$JOURNAL/$QUOTA/limits" <> $ERROR \ +| "$SHOWMAIL" \ +> out0.tmp + + grep -q 'METHOD:REPLY' out0.tmp \ +&& ! grep -q '^FREEBUSY' out0.tmp \ +&& echo "Success" \ +|| echo "Failed" + +# Attempt to schedule an event. + +"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-cars-recurring.txt" 2>> $ERROR + + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE1" \ +&& grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBSENDERFILE1" \ +&& echo "Success" \ +|| echo "Failed" + +# Present the request to the resource. + + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-cars-recurring.txt" 2>> $ERROR \ +| tee out1r.tmp \ +| "$SHOWMAIL" \ +> out1.tmp + + grep -q 'METHOD:REPLY' out1.tmp \ +&& grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out1.tmp \ +&& echo "Success" \ +|| echo "Failed" + + ( ! [ -e "$FBFILE1" ] \ + || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE1" \ + && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBFILE1" )) \ +&& ( ! [ -e "$FBFILE2" ] \ + || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE2" \ + && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBFILE2" )) \ +&& echo "Success" \ +|| echo "Failed" + +# Check the quota (event is not confirmed). + + ! [ -e "$JOURNALFILE1" ] \ +|| ! grep -q "event25@example.com" "$JOURNALFILE1" \ +&& echo "Success" \ +|| echo "Failed" + +# Modify the event and attempt to schedule it again. + + sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=5/;' "$TEMPLATES/event-request-cars-recurring.txt" \ +| "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR + + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE1" \ +&& grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBSENDERFILE1" \ +&& echo "Success" \ +|| echo "Failed" + +# Present the request to the resource. + + sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=5/;' "$TEMPLATES/event-request-cars-recurring.txt" \ +| "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \ +| tee out2r.tmp \ +| "$SHOWMAIL" \ +> out2.tmp + +# Since the email module used by showmail.py cannot stop after reading a single +# message, the second message is obtained. + + grep -n '^From ' out2r.tmp \ +| tail -n 1 \ +| cut -d ':' -f 1 \ +| xargs -I{} tail -n +'{}' out2r.tmp \ +| "$SHOWMAIL" \ +>> out2.tmp + + grep -q 'METHOD:REPLY' out2.tmp \ +&& grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out2.tmp \ +&& grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out2.tmp \ +&& echo "Success" \ +|| echo "Failed" + + (( ! [ -e "$FBFILE1" ] \ + || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE1" \ + && ! grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBFILE1" )) \ + && [ -e "$FBFILE2" ] \ + && grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE2" \ + && grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBFILE2" ) \ +|| (( ! [ -e "$FBFILE2" ] \ + || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE2" \ + && ! grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBFILE2" )) \ + && [ -e "$FBFILE1" ] \ + && grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE1" \ + && grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBFILE1" ) \ +&& echo "Success" \ +|| echo "Failed" + +# Check the quota (event is confirmed for one resource). + + ! [ -e "$JOURNALFILE1" ] \ +|| grep -q "event25@example.com" "$JOURNALFILE1" \ +&& echo "Success" \ +|| echo "Failed" + +# Cancel the event. + +"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-cars-recurring.txt" 2>> $ERROR + + ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE1" \ +&& ! grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBSENDERFILE1" \ +&& echo "Success" \ +|| echo "Failed" + +# Present the request to the resource. + + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-cars-recurring.txt" 2>> $ERROR \ +| tee out3r.tmp \ +| "$SHOWMAIL" \ +> out3.tmp + + ! grep -q 'METHOD:REPLY' out3.tmp \ +&& echo "Success" \ +|| echo "Failed" + + ( ! [ -e "$FBFILE1" ] \ + || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE1" \ + && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBFILE1" )) \ +&& ( ! [ -e "$FBFILE2" ] \ + || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE2" \ + && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBFILE2" )) \ +&& echo "Success" \ +|| echo "Failed" + +# Check the quota (event is retracted). + + ! [ -e "$JOURNALFILE1" ] \ +|| [ `grep "event25@example.com" "$JOURNALFILE1" | wc -l` = '2' ] \ +&& echo "Success" \ +|| echo "Failed" + +# Modify the event and attempt to schedule it again. + + sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=5/;' "$TEMPLATES/event-request-cars-recurring.txt" \ +| sed "s/$SENDERADDRESS1/$SENDERADDRESS2/;" \ +| "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR + + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE2" \ +&& grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBSENDERFILE2" \ +&& echo "Success" \ +|| echo "Failed" + +# Present the request to the resource. + + sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=5/;' "$TEMPLATES/event-request-cars-recurring.txt" \ +| sed "s/$SENDERADDRESS1/$SENDERADDRESS2/;" \ +| "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \ +| tee out4r.tmp \ +| "$SHOWMAIL" \ +> out4.tmp + +# Since the email module used by showmail.py cannot stop after reading a single +# message, the second message is obtained. + + grep -n '^From ' out4r.tmp \ +| tail -n 1 \ +| cut -d ':' -f 1 \ +| xargs -I{} tail -n +'{}' out4r.tmp \ +| "$SHOWMAIL" \ +>> out4.tmp + + grep -q 'METHOD:REPLY' out4.tmp \ +&& [ `grep 'ATTENDEE.*;PARTSTAT=ACCEPTED' out4.tmp | wc -l` = '2' ] \ +&& echo "Success" \ +|| echo "Failed" + + [ -e "$FBFILE1" ] \ +&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE1" \ +&& grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBFILE1" \ +&& [ -e "$FBFILE2" ] \ +&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE2" \ +&& grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBFILE2" \ +&& echo "Success" \ +|| echo "Failed" + +# Check the quota (event is confirmed for both resources). + + [ -e "$JOURNALFILE2" ] \ +&& [ `grep "event25@example.com" "$JOURNALFILE2" | wc -l` = '1' ] \ +&& echo "Success" \ +|| echo "Failed"