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