1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/next_time.py Thu Sep 10 22:09:38 2015 +0200
1.3 @@ -0,0 +1,41 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"""
1.7 +Increment the hour in a datetime string, wrapping round within any given range.
1.8 +"""
1.9 +
1.10 +import sys
1.11 +
1.12 +try:
1.13 + dt_str = sys.argv[1]
1.14 + first, last = (sys.argv[2:4] + [None, None])[:2]
1.15 +except (IndexError, ValueError):
1.16 + sys.exit(1)
1.17 +
1.18 +if not dt_str:
1.19 + sys.exit(1)
1.20 +
1.21 +try:
1.22 + date_str = dt_str[:9]
1.23 + hour = int(dt_str[9:11])
1.24 + min_sec_str = dt_str[11:]
1.25 +except ValueError:
1.26 + sys.exit(1)
1.27 +
1.28 +if not first:
1.29 + first = 0
1.30 +else:
1.31 + first = int(first)
1.32 +
1.33 +if not last:
1.34 + last = 23
1.35 +else:
1.36 + last = int(last)
1.37 +
1.38 +hour += 1
1.39 +if hour > last:
1.40 + hour = first
1.41 +
1.42 +print '%s%02d%s' % (date_str, hour, min_sec_str)
1.43 +
1.44 +# vim: tabstop=4 expandtab shiftwidth=4
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/tests/resource_request.sh Thu Sep 10 22:09:38 2015 +0200
2.3 @@ -0,0 +1,44 @@
2.4 +#!/bin/sh
2.5 +
2.6 +THIS_DIR=`dirname $0`
2.7 +
2.8 +TEMPLATES="$THIS_DIR/templates"
2.9 +RESOURCE_SCRIPT="$THIS_DIR/../imip_resource.py"
2.10 +SHOWMAIL="$THIS_DIR/../tools/showmail.py"
2.11 +STORE=/tmp/store
2.12 +STATIC=/tmp/static
2.13 +PREFS=/tmp/prefs
2.14 +ARGS="-S $STORE -P $STATIC -p $PREFS -d"
2.15 +
2.16 +ERROR=err.tmp
2.17 +
2.18 +export N=$1
2.19 +export START=20141126T090000
2.20 +export END=20141126T100000
2.21 +export SENDERADDRESS="person-$N@example.com"
2.22 +export SENDER="mailto:person-$N@example.com"
2.23 +
2.24 +# Exit if a previous result indicates acceptance of a request.
2.25 +
2.26 + [ -e "outP${N}.tmp" ] \
2.27 +&& `grep 'PARTSTAT' "outP${N}.tmp" | grep -q 'ACCEPTED'` \
2.28 +&& exit 0
2.29 +
2.30 +FBRESULT=$2
2.31 +
2.32 +# Find the end of a busy period or use the initial start.
2.33 +
2.34 +FBSTART=`grep 'FREEBUSY' "$FBRESULT" | grep -v 'VFREEBUSY' | tail -n 1 | cut -d: -f2 | cut -d/ -f2 | tr -d '\\r'`
2.35 +FBEND=`python "$THIS_DIR/next_time.py" "$FBSTART" 09 16`
2.36 +START=${FBSTART:-$START}
2.37 +END=${FBEND:-$END}
2.38 +
2.39 +echo "Try for $N with $START and $END..."
2.40 +
2.41 +# Request a resource on behalf of a numbered person identity.
2.42 +
2.43 + envsubst < "$TEMPLATES/event-request-group.txt" \
2.44 +| tee "inP${N}.tmp" \
2.45 +| "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \
2.46 +| "$SHOWMAIL" 2>> $ERROR \
2.47 +> "outP${N}.tmp"
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/tests/templates/event-request-group.txt Thu Sep 10 22:09:38 2015 +0200
3.3 @@ -0,0 +1,34 @@
3.4 +Content-Type: multipart/alternative; boundary="===============0047278175=="
3.5 +MIME-Version: 1.0
3.6 +From: $SENDERADDRESS
3.7 +To: resource-room-confroom@example.com
3.8 +Subject: Invitation!
3.9 +
3.10 +--===============0047278175==
3.11 +Content-Type: text/plain; charset="us-ascii"
3.12 +MIME-Version: 1.0
3.13 +Content-Transfer-Encoding: 7bit
3.14 +
3.15 +This message contains an event.
3.16 +--===============0047278175==
3.17 +MIME-Version: 1.0
3.18 +Content-Transfer-Encoding: 7bit
3.19 +Content-Type: text/calendar; charset="us-ascii"; method="REQUEST"
3.20 +
3.21 +BEGIN:VCALENDAR
3.22 +PRODID:-//imip-agent/test//EN
3.23 +METHOD:REQUEST
3.24 +VERSION:2.0
3.25 +BEGIN:VEVENT
3.26 +ORGANIZER:$SENDER
3.27 +ATTENDEE;ROLE=CHAIR:$SENDER
3.28 +ATTENDEE;RSVP=TRUE:mailto:resource-room-confroom@example.com
3.29 +DTSTAMP:20141125T004600Z
3.30 +DTSTART;TZID=Europe/Oslo:$START
3.31 +DTEND;TZID=Europe/Oslo:$END
3.32 +SUMMARY:Meeting
3.33 +UID:eventP${N}@example.com
3.34 +END:VEVENT
3.35 +END:VCALENDAR
3.36 +
3.37 +--===============0047278175==--
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/tests/templates/fb-request-group.txt Thu Sep 10 22:09:38 2015 +0200
4.3 @@ -0,0 +1,31 @@
4.4 +Content-Type: multipart/alternative; boundary="===============0945993647=="
4.5 +MIME-Version: 1.0
4.6 +From: $SENDERADDRESS
4.7 +To: resource-room-confroom@example.com
4.8 +
4.9 +--===============0945993647==
4.10 +Content-Type: text/plain; charset="us-ascii"
4.11 +MIME-Version: 1.0
4.12 +Content-Transfer-Encoding: 7bit
4.13 +
4.14 +This message contains a free/busy request.
4.15 +--===============0945993647==
4.16 +Content-Type: text/calendar; charset="us-ascii"; method="REQUEST"
4.17 +MIME-Version: 1.0
4.18 +Content-Transfer-Encoding: 7bit
4.19 +
4.20 +BEGIN:VCALENDAR
4.21 +PRODID:-//imip-agent/test//EN
4.22 +METHOD:REQUEST
4.23 +VERSION:2.0
4.24 +BEGIN:VFREEBUSY
4.25 +ORGANIZER:$SENDER
4.26 +ATTENDEE:mailto:resource-room-confroom@example.com
4.27 +DTSTAMP:20141125T164400Z
4.28 +DTSTART;TZID=Europe/Oslo:20141126T090000
4.29 +DTEND;TZID=Europe/Oslo:20141126T180000
4.30 +UID:fbP${N}@example.com
4.31 +END:VFREEBUSY
4.32 +END:VCALENDAR
4.33 +
4.34 +--===============0945993647==--
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/tests/test_resource_invitation_group.sh Thu Sep 10 22:09:38 2015 +0200
5.3 @@ -0,0 +1,76 @@
5.4 +#!/bin/sh
5.5 +
5.6 +THIS_DIR=`dirname $0`
5.7 +
5.8 +TEMPLATES="$THIS_DIR/templates"
5.9 +RESOURCE_SCRIPT="$THIS_DIR/../imip_resource.py"
5.10 +SHOWMAIL="$THIS_DIR/../tools/showmail.py"
5.11 +STORE=/tmp/store
5.12 +STATIC=/tmp/static
5.13 +PREFS=/tmp/prefs
5.14 +ARGS="-S $STORE -P $STATIC -p $PREFS -d"
5.15 +USER="mailto:resource-room-confroom@example.com"
5.16 +
5.17 +ERROR=err.tmp
5.18 +
5.19 +rm -r $STORE
5.20 +rm -r $STATIC
5.21 +rm -r $PREFS
5.22 +rm $ERROR
5.23 +rm out*.tmp
5.24 +
5.25 +mkdir -p "$PREFS/$USER"
5.26 +echo 'Europe/Oslo' > "$PREFS/$USER/TZID"
5.27 +echo 'share' > "$PREFS/$USER/freebusy_sharing"
5.28 +
5.29 +for N in `seq 1 5` ; do
5.30 + SENDER="mailto:person-$N@example.com"
5.31 + mkdir -p "$PREFS/$SENDER"
5.32 + echo 'Europe/Oslo' > "$PREFS/$SENDER/TZID"
5.33 +done
5.34 +
5.35 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-all.txt" 2>> $ERROR \
5.36 +| "$SHOWMAIL" \
5.37 +> out0.tmp
5.38 +
5.39 + grep -q 'METHOD:REPLY' out0.tmp \
5.40 +&& ! grep -q '^FREEBUSY' out0.tmp \
5.41 +&& echo "Success" \
5.42 +|| echo "Failed"
5.43 +
5.44 + "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request.txt" 2>> $ERROR \
5.45 +| "$SHOWMAIL" \
5.46 +> out1.tmp
5.47 +
5.48 + grep -q 'METHOD:REPLY' out1.tmp \
5.49 +&& ! grep -q '^FREEBUSY' out1.tmp \
5.50 +&& echo "Success" \
5.51 +|| echo "Failed"
5.52 +
5.53 +# Loop until all requests have been satisfied.
5.54 +
5.55 +while [ ! -e outP1.tmp ] || [ `grep 'PARTSTAT' outP*.tmp | grep 'ACCEPTED' | wc -l` != '5' ] ; do
5.56 +
5.57 + # Request free/busy information.
5.58 +
5.59 + FBRESULT="outfbP.tmp"
5.60 + export SENDER="mailto:person-N@example.com"
5.61 + export SENDERADDRESS="person-N@example.com"
5.62 +
5.63 + envsubst < "$TEMPLATES/fb-request-group.txt" \
5.64 + | tee "infbP.tmp" \
5.65 + | "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \
5.66 + | "$SHOWMAIL" 2>> $ERROR \
5.67 + > "$FBRESULT"
5.68 +
5.69 + # Set the requesters on a race to book with this information.
5.70 +
5.71 + seq 1 5 | xargs -P0 -I{} "$THIS_DIR/resource_request.sh" {} "$FBRESULT"
5.72 + wait
5.73 + echo "Accepted: `grep 'ACCEPTED' outP*.tmp | wc -l`"
5.74 +
5.75 +done
5.76 +
5.77 + [ `grep 'PARTSTAT' outP*.tmp | grep 'ACCEPTED' | wc -l` = '5' ] \
5.78 +&& echo "Success" \
5.79 +|| echo "Failed"