paul@746 | 1 | #!/bin/sh |
paul@746 | 2 | |
paul@746 | 3 | THIS_DIR=`dirname $0` |
paul@746 | 4 | |
paul@746 | 5 | TEMPLATES="$THIS_DIR/templates" |
paul@746 | 6 | PERSON_SCRIPT="$THIS_DIR/../imip_person.py" |
paul@746 | 7 | RESOURCE_SCRIPT="$THIS_DIR/../imip_resource.py" |
paul@746 | 8 | SHOWMAIL="$THIS_DIR/../tools/showmail.py" |
paul@746 | 9 | STORE=/tmp/store |
paul@746 | 10 | STATIC=/tmp/static |
paul@746 | 11 | PREFS=/tmp/prefs |
paul@746 | 12 | ARGS="-S $STORE -P $STATIC -p $PREFS -d" |
paul@746 | 13 | USER="mailto:resource-room-sauna@example.com" |
paul@746 | 14 | SENDER="mailto:paul.boddie@example.com" |
paul@746 | 15 | RIVALSENDER="mailto:vincent.vole@example.com" |
paul@746 | 16 | FBFILE="$STORE/$USER/freebusy" |
paul@746 | 17 | FBOFFERFILE="$STORE/$USER/freebusy-offers" |
paul@746 | 18 | FBSENDERFILE="$STORE/$SENDER/freebusy" |
paul@746 | 19 | FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER" |
paul@747 | 20 | FBSENDERREQUESTS="$STORE/$SENDER/requests" |
paul@746 | 21 | FBRIVALSENDERFILE="$STORE/$RIVALSENDER/freebusy" |
paul@746 | 22 | TAB=`printf '\t'` |
paul@746 | 23 | |
paul@746 | 24 | OUTGOING_SCRIPT="$THIS_DIR/../imip_person_outgoing.py" |
paul@746 | 25 | |
paul@746 | 26 | ERROR=err.tmp |
paul@746 | 27 | |
paul@746 | 28 | rm -r $STORE |
paul@746 | 29 | rm -r $STATIC |
paul@746 | 30 | rm -r $PREFS |
paul@746 | 31 | rm $ERROR |
paul@746 | 32 | rm out*.tmp |
paul@746 | 33 | |
paul@746 | 34 | mkdir -p "$PREFS/$USER" |
paul@746 | 35 | echo 'Europe/Oslo' > "$PREFS/$USER/TZID" |
paul@746 | 36 | echo 'share' > "$PREFS/$USER/freebusy_sharing" |
paul@746 | 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@746 | 39 | |
paul@746 | 40 | "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \ |
paul@746 | 41 | | "$SHOWMAIL" \ |
paul@746 | 42 | > out0.tmp |
paul@746 | 43 | |
paul@746 | 44 | grep -q 'METHOD:REPLY' out0.tmp \ |
paul@746 | 45 | && ! grep -q '^FREEBUSY' out0.tmp \ |
paul@746 | 46 | && echo "Success" \ |
paul@746 | 47 | || echo "Failed" |
paul@746 | 48 | |
paul@746 | 49 | # Attempt to schedule an event. |
paul@746 | 50 | |
paul@746 | 51 | "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-bad.txt" 2>> $ERROR |
paul@746 | 52 | |
paul@746 | 53 | grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ |
paul@746 | 54 | && echo "Success" \ |
paul@746 | 55 | || echo "Failed" |
paul@746 | 56 | |
paul@746 | 57 | # Present the request to the resource. |
paul@746 | 58 | |
paul@746 | 59 | "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-bad.txt" 2>> $ERROR \ |
paul@746 | 60 | | "$SHOWMAIL" \ |
paul@746 | 61 | > out1.tmp |
paul@746 | 62 | |
paul@746 | 63 | grep -q 'METHOD:COUNTER' out1.tmp \ |
paul@746 | 64 | && grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161500' out1.tmp \ |
paul@746 | 65 | && echo "Success" \ |
paul@746 | 66 | || echo "Failed" |
paul@746 | 67 | |
paul@746 | 68 | ! [ -e "$FBFILE" ] \ |
paul@746 | 69 | || ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBFILE" \ |
paul@746 | 70 | && echo "Success" \ |
paul@746 | 71 | || echo "Failed" |
paul@746 | 72 | |
paul@746 | 73 | grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ |
paul@746 | 74 | && echo "Success" \ |
paul@746 | 75 | || echo "Failed" |
paul@746 | 76 | |
paul@746 | 77 | # Present the response to the organiser. |
paul@746 | 78 | |
paul@746 | 79 | "$PERSON_SCRIPT" $ARGS < out1.tmp 2>> $ERROR \ |
paul@746 | 80 | | tee out2r.tmp \ |
paul@746 | 81 | | "$SHOWMAIL" \ |
paul@746 | 82 | > out2.tmp |
paul@746 | 83 | |
paul@746 | 84 | [ ! -e "$FBSENDEROTHERFILE" ] \ |
paul@746 | 85 | || ( ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDEROTHERFILE" \ |
paul@746 | 86 | && ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBSENDEROTHERFILE" ) \ |
paul@746 | 87 | && echo "Success" \ |
paul@746 | 88 | || echo "Failed" |
paul@746 | 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@746 | 99 | && echo "Success" \ |
paul@746 | 100 | || echo "Failed" |
paul@746 | 101 | |
paul@746 | 102 | # Decline the counter-proposal. |
paul@746 | 103 | |
paul@746 | 104 | sed 's/COUNTER/DECLINECOUNTER/' < out1.tmp \ |
paul@746 | 105 | | sed 's/^From: calendar/To: resource-room-sauna/' \ |
paul@746 | 106 | | sed 's/^To: paul.boddie/From: paul.boddie/' \ |
paul@746 | 107 | > out3.tmp |
paul@746 | 108 | |
paul@746 | 109 | "$OUTGOING_SCRIPT" $ARGS < out3.tmp 2>> $ERROR |
paul@746 | 110 | |
paul@746 | 111 | "$RESOURCE_SCRIPT" $ARGS < out3.tmp 2>> $ERROR \ |
paul@746 | 112 | | "$SHOWMAIL" \ |
paul@746 | 113 | > out4.tmp |
paul@746 | 114 | |
paul@746 | 115 | ! [ -e "$FBFILE" ] \ |
paul@746 | 116 | || ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBFILE" \ |
paul@746 | 117 | && echo "Success" \ |
paul@746 | 118 | || echo "Failed" |
paul@746 | 119 | |
paul@746 | 120 | ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ |
paul@746 | 121 | && echo "Success" \ |
paul@746 | 122 | || echo "Failed" |
paul@746 | 123 | |
paul@746 | 124 | # Attempt to schedule an event in the proposed period. |
paul@746 | 125 | |
paul@746 | 126 | "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-rival.txt" 2>> $ERROR |
paul@746 | 127 | |
paul@746 | 128 | ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ |
paul@746 | 129 | && grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ |
paul@746 | 130 | && echo "Success" \ |
paul@746 | 131 | || echo "Failed" |
paul@746 | 132 | |
paul@746 | 133 | # Present the request to the resource. |
paul@746 | 134 | |
paul@746 | 135 | "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-rival.txt" 2>> $ERROR \ |
paul@746 | 136 | | "$SHOWMAIL" \ |
paul@746 | 137 | > out5.tmp |
paul@746 | 138 | |
paul@746 | 139 | grep -q 'METHOD:REPLY' out5.tmp \ |
paul@746 | 140 | && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out5.tmp \ |
paul@746 | 141 | && echo "Success" \ |
paul@746 | 142 | || echo "Failed" |
paul@746 | 143 | |
paul@746 | 144 | grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBFILE" \ |
paul@746 | 145 | && echo "Success" \ |
paul@746 | 146 | || echo "Failed" |
paul@746 | 147 | |
paul@746 | 148 | ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ |
paul@746 | 149 | && echo "Success" \ |
paul@746 | 150 | || echo "Failed" |
paul@746 | 151 | |
paul@746 | 152 | # Present the response to the organiser. |
paul@746 | 153 | |
paul@746 | 154 | "$PERSON_SCRIPT" $ARGS < out5.tmp 2>> $ERROR \ |
paul@746 | 155 | | "$SHOWMAIL" \ |
paul@746 | 156 | > out6.tmp |
paul@746 | 157 | |
paul@746 | 158 | ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ |
paul@746 | 159 | && ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ |
paul@746 | 160 | && grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ |
paul@746 | 161 | && echo "Success" \ |
paul@746 | 162 | || echo "Failed" |
paul@746 | 163 | |
paul@746 | 164 | grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' "$STORE/$RIVALSENDER/objects/event18@example.com" \ |
paul@746 | 165 | && echo "Success" \ |
paul@746 | 166 | || echo "Failed" |
paul@746 | 167 | |
paul@746 | 168 | # Check the free/busy state of the resource so far. |
paul@746 | 169 | |
paul@746 | 170 | "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \ |
paul@746 | 171 | | "$SHOWMAIL" \ |
paul@746 | 172 | > out7.tmp |
paul@746 | 173 | |
paul@746 | 174 | grep -q 'METHOD:REPLY' out7.tmp \ |
paul@746 | 175 | && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151000Z/20141126T154500Z' out7.tmp \ |
paul@746 | 176 | && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151500Z/20141126T154500Z' out7.tmp \ |
paul@746 | 177 | && grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T153000Z/20141126T154500Z' out7.tmp \ |
paul@746 | 178 | && echo "Success" \ |
paul@746 | 179 | || echo "Failed" |