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 -rf $STORE 29 rm -rf $STATIC 30 rm -rf $PREFS 31 rm -f $ERROR 32 rm -f 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_corrected_in_freebusy' > "$PREFS/$USER/scheduling_function" 38 echo '10,12,14,16,18:0,15,30,45' > "$PREFS/$USER/permitted_times" 39 echo 'PT60S' > "$PREFS/$USER/freebusy_offers" 40 41 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \ 42 | "$SHOWMAIL" \ 43 > out0.tmp 44 45 grep -q 'METHOD:REPLY' out0.tmp \ 46 && ! grep -q '^FREEBUSY' out0.tmp \ 47 && echo "Success" \ 48 || echo "Failed" 49 50 # Attempt to schedule an event. 51 52 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-bad.txt" 2>> $ERROR 53 54 grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ 55 && echo "Success" \ 56 || echo "Failed" 57 58 # Present the request to the resource. 59 60 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-bad.txt" 2>> $ERROR \ 61 | tee out1r.tmp \ 62 | "$SHOWMAIL" \ 63 > out1.tmp 64 65 grep -q 'METHOD:COUNTER' out1.tmp \ 66 && grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161500' out1.tmp \ 67 && echo "Success" \ 68 || echo "Failed" 69 70 ! [ -e "$FBFILE" ] \ 71 || ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBFILE" \ 72 && echo "Success" \ 73 || echo "Failed" 74 75 grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ 76 && echo "Success" \ 77 || echo "Failed" 78 79 # Present the response to the organiser. 80 81 "$PERSON_SCRIPT" $ARGS < out1r.tmp 2>> $ERROR \ 82 | tee out2r.tmp \ 83 | "$SHOWMAIL" \ 84 > out2.tmp 85 86 ( ! [ -e "$FBSENDEROTHERFILE" ] \ 87 || ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDEROTHERFILE") \ 88 && echo "Success" \ 89 || echo "Failed" 90 91 grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161000' "$STORE/$SENDER/objects/event13@example.com" \ 92 && echo "Success" \ 93 || echo "Failed" 94 95 grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161500' "$STORE/$SENDER/counters/objects/event13@example.com/$USER" \ 96 && echo "Success" \ 97 || echo "Failed" 98 99 grep -q 'event13@example.com' "$FBSENDERREQUESTS" \ 100 && echo "Success" \ 101 || echo "Failed" 102 103 # Attempt to schedule an event in the proposed period. 104 105 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-rival.txt" 2>> $ERROR 106 107 ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ 108 && grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ 109 && echo "Success" \ 110 || echo "Failed" 111 112 # Present the request to the resource. 113 114 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-rival.txt" 2>> $ERROR \ 115 | "$SHOWMAIL" \ 116 > out3.tmp 117 118 grep -q 'METHOD:REPLY' out3.tmp \ 119 && grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out3.tmp \ 120 && echo "Success" \ 121 || echo "Failed" 122 123 # Present the response to the organiser. 124 125 "$PERSON_SCRIPT" $ARGS < out3.tmp 2>> $ERROR \ 126 | tee out4r.tmp \ 127 | "$SHOWMAIL" \ 128 > out4.tmp 129 130 ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ 131 && grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ 132 && echo "Success" \ 133 || echo "Failed" 134 135 grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' "$STORE/$RIVALSENDER/objects/event18@example.com" \ 136 && echo "Success" \ 137 || echo "Failed" 138 139 # Check the free/busy state of the resource so far. 140 141 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \ 142 | "$SHOWMAIL" \ 143 > out5.tmp 144 145 grep -q 'METHOD:REPLY' out5.tmp \ 146 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151000Z/20141126T154500Z' out5.tmp \ 147 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151500Z/20141126T154500Z' out5.tmp \ 148 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T153000Z/20141126T154500Z' out5.tmp \ 149 && echo "Success" \ 150 || echo "Failed" 151 152 # Attempt to schedule again in response to the counter-proposal. 153 154 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR 155 156 ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ 157 && ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ 158 && ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ 159 && echo "Success" \ 160 || echo "Failed" 161 162 [ ! -e "$STORE/$SENDER/counters/objects/event13@example.com/$USER" ] \ 163 && echo "Success" \ 164 || echo "Failed" 165 166 ! grep -q 'event13@example.com' "$FBSENDERREQUESTS" \ 167 && echo "Success" \ 168 || echo "Failed" 169 170 # Present the request to the resource. 171 172 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR \ 173 | "$SHOWMAIL" \ 174 > out6.tmp 175 176 grep -q 'METHOD:REPLY' out6.tmp \ 177 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out6.tmp \ 178 && echo "Success" \ 179 || echo "Failed" 180 181 grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBFILE" \ 182 && echo "Success" \ 183 || echo "Failed" 184 185 ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ 186 && ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ 187 && ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ 188 && echo "Success" \ 189 || echo "Failed" 190 191 # Present the response to the organiser. 192 193 "$PERSON_SCRIPT" $ARGS < out6.tmp 2>> $ERROR \ 194 | tee out7r.tmp \ 195 | "$SHOWMAIL" \ 196 > out7.tmp 197 198 grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ 199 && ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ 200 && ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ 201 && ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ 202 && echo "Success" \ 203 || echo "Failed" 204 205 [ ! -e "$STORE/$SENDER/counters/objects/event13@example.com/$USER" ] \ 206 && echo "Success" \ 207 || echo "Failed" 208 209 ! grep -q 'event13@example.com' "$FBSENDERREQUESTS" \ 210 && echo "Success" \ 211 || echo "Failed" 212 213 # Check the free/busy state of the resource again. 214 215 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \ 216 | "$SHOWMAIL" \ 217 > out6.tmp 218 219 grep -q 'METHOD:REPLY' out6.tmp \ 220 && grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T150000Z/20141126T154500Z' out6.tmp \ 221 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151000Z/20141126T154500Z' out6.tmp \ 222 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151500Z/20141126T154500Z' out6.tmp \ 223 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T153000Z/20141126T154500Z' out6.tmp \ 224 && echo "Success" \ 225 || echo "Failed"