1 #!/bin/sh 2 3 THIS_DIR=`dirname $0` 4 5 TEMPLATES="$THIS_DIR/templates" 6 PERSON_SCRIPT="$THIS_DIR/../imip_person.py" 7 RESOURCE_SCRIPT="$THIS_DIR/../imip_resource.py" 8 SHOWMAIL="$THIS_DIR/../tools/showmail.py" 9 STORE=/tmp/store 10 STATIC=/tmp/static 11 PREFS=/tmp/prefs 12 ARGS="-S $STORE -P $STATIC -p $PREFS -d" 13 USER="mailto:resource-room-sauna@example.com" 14 SENDER="mailto:paul.boddie@example.com" 15 RIVALSENDER="mailto:vincent.vole@example.com" 16 FBFILE="$STORE/$USER/freebusy" 17 FBOFFERFILE="$STORE/$USER/freebusy-offers" 18 FBSENDERFILE="$STORE/$SENDER/freebusy" 19 FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER" 20 FBSENDERREQUESTS="$STORE/$SENDER/requests" 21 FBRIVALSENDERFILE="$STORE/$RIVALSENDER/freebusy" 22 TAB=`printf '\t'` 23 24 OUTGOING_SCRIPT="$THIS_DIR/../imip_person_outgoing.py" 25 26 ERROR=err.tmp 27 28 rm -r $STORE 29 rm -r $STATIC 30 rm -r $PREFS 31 rm $ERROR 32 rm out*.tmp 33 34 mkdir -p "$PREFS/$USER" 35 echo 'Europe/Oslo' > "$PREFS/$USER/TZID" 36 echo 'share' > "$PREFS/$USER/freebusy_sharing" 37 echo 'schedule_next_available_in_freebusy' > "$PREFS/$USER/scheduling_function" 38 echo 'PT60S' > "$PREFS/$USER/freebusy_offers" 39 40 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \ 41 | "$SHOWMAIL" \ 42 > out0.tmp 43 44 grep -q 'METHOD:REPLY' out0.tmp \ 45 && ! grep -q '^FREEBUSY' out0.tmp \ 46 && echo "Success" \ 47 || echo "Failed" 48 49 # Let the rival sender book the resource. 50 51 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-busy.txt" 2>> $ERROR 52 53 [ `grep "event19@example.com" "$FBRIVALSENDERFILE" | wc -l` = '5' ] \ 54 && grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBRIVALSENDERFILE" \ 55 && echo "Success" \ 56 || echo "Failed" 57 58 # Present the request to the resource. 59 60 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-busy.txt" 2>> $ERROR \ 61 | tee out1r.tmp \ 62 | "$SHOWMAIL" \ 63 > out1.tmp 64 65 grep -q 'METHOD:REPLY' out1.tmp \ 66 && grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T160000' out1.tmp \ 67 && echo "Success" \ 68 || echo "Failed" 69 70 [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \ 71 && grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ 72 && echo "Success" \ 73 || echo "Failed" 74 75 # Present the response to the rival sender. 76 77 "$PERSON_SCRIPT" $ARGS < out1r.tmp 2>> $ERROR \ 78 | tee out2r.tmp \ 79 | "$SHOWMAIL" \ 80 > out2.tmp 81 82 # Attempt to schedule an event with the resource. 83 84 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR 85 86 grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ 87 && echo "Success" \ 88 || echo "Failed" 89 90 # Present the request to the resource. This should cause the event to be 91 # proposed one hour later. 92 93 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR \ 94 | tee out6r.tmp \ 95 | "$SHOWMAIL" \ 96 > out6.tmp 97 98 grep -q 'METHOD:COUNTER' out6.tmp \ 99 && ! grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out6.tmp \ 100 && echo "Success" \ 101 || echo "Failed" 102 103 ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ 104 && grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \ 105 && echo "Success" \ 106 || echo "Failed" 107 108 # Present the response to the organiser. 109 110 "$PERSON_SCRIPT" $ARGS < out6r.tmp 2>> $ERROR \ 111 | tee out7r.tmp \ 112 | "$SHOWMAIL" \ 113 > out7.tmp 114 115 grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ 116 && ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBSENDERFILE" \ 117 && echo "Success" \ 118 || echo "Failed" 119 120 [ -e "$STORE/$SENDER/counters/objects/event13@example.com/$USER" ] \ 121 && echo "Success" \ 122 || echo "Failed" 123 124 grep -q 'event13@example.com' "$FBSENDERREQUESTS" \ 125 && echo "Success" \ 126 || echo "Failed" 127 128 # Reschedule the event by accepting the counter-proposal. 129 130 sed 's/COUNTER/REQUEST/' < out6.tmp \ 131 | sed 's/^From: calendar/To: resource-room-sauna/' \ 132 | sed 's/^To: paul.boddie/From: paul.boddie/' \ 133 > out8.tmp 134 135 "$OUTGOING_SCRIPT" $ARGS < out8.tmp 2>> $ERROR 136 137 ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ 138 && grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBSENDERFILE" \ 139 && echo "Success" \ 140 || echo "Failed" 141 142 ! [ -e "$STORE/$SENDER/counters/objects/event13@example.com/$USER" ] \ 143 && echo "Success" \ 144 || echo "Failed" 145 146 ! grep -q 'event13@example.com' "$FBSENDERREQUESTS" \ 147 && echo "Success" \ 148 || echo "Failed" 149 150 "$RESOURCE_SCRIPT" $ARGS < out8.tmp 2>> $ERROR \ 151 | "$SHOWMAIL" \ 152 > out9.tmp 153 154 grep -q 'METHOD:REPLY' out9.tmp \ 155 && grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' out9.tmp \ 156 && echo "Success" \ 157 || echo "Failed" 158 159 ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ 160 && ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \ 161 && echo "Success" \ 162 || echo "Failed" 163 164 [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \ 165 && [ `grep "event13@example.com" "$FBFILE" | wc -l` = '1' ] \ 166 && grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBFILE" \ 167 && echo "Success" \ 168 || echo "Failed"