1 #!/bin/sh 2 3 . "`dirname \"$0\"`/common.sh" 4 5 USER="mailto:vincent.vole@example.com" 6 SENDER="mailto:paul.boddie@example.com" 7 8 mkdir -p "$PREFS/$USER" 9 echo 'Europe/Oslo' > "$PREFS/$USER/TZID" 10 echo 'share' > "$PREFS/$USER/freebusy_sharing" 11 12 # Present a free/busy request for all periods to the recipient. 13 14 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \ 15 | "$SHOWMAIL" \ 16 > out0.tmp 17 18 # Expect a reply with no periods. 19 20 grep -q 'METHOD:REPLY' out0.tmp \ 21 && ! grep -q '^FREEBUSY' out0.tmp \ 22 && echo "Success" \ 23 || echo "Failed" 24 25 # Present a free/busy request for periods of interest to the recipient. 26 27 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person.txt" 2>> $ERROR \ 28 | "$SHOWMAIL" \ 29 > out1.tmp 30 31 # Expect a reply with no periods. 32 33 grep -q 'METHOD:REPLY' out1.tmp \ 34 && ! grep -q '^FREEBUSY' out1.tmp \ 35 && echo "Success" \ 36 || echo "Failed" 37 38 # Make a new event. 39 40 cat > event_cmd.tmp <<EOF 41 new 42 period 0 edit 20141126 16 00 00 Europe/Oslo 20141126 17 00 00 Europe/Oslo 43 attendance accept 44 attendee mailto:vincent.vole@example.com 45 summary Meeting at 4pm 46 finish 47 update event.tmp 48 publish event_self.tmp 49 UID event_uid.tmp 50 EOF 51 52 "$TEXT_CLIENT" $ARGS -u "$SENDER" --echo \ 53 < event_cmd.tmp \ 54 > event_log.tmp 55 56 # Obtain the event UID. 57 58 read UID1 < event_uid.tmp 59 60 # Register the event at the sender. 61 62 "$OUTGOING_SCRIPT" < event.tmp $ARGS 2>> $ERROR 63 64 # Present the event to the recipient. 65 66 "$PERSON_SCRIPT" $ARGS < event.tmp 2>> $ERROR \ 67 | "$SHOWMAIL" \ 68 > out2.tmp 69 70 # Expect no reply because the recipient must handle the request. 71 72 ! grep -q 'METHOD:REPLY' out2.tmp \ 73 && echo "Success" \ 74 || echo "Failed" 75 76 # Expect no free/busy periods for the recipient. 77 78 "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ 79 > out2f.tmp 80 81 ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" out2f.tmp \ 82 && echo "Success" \ 83 || echo "Failed" 84 85 # Expect free/busy periods for the sender at the recipient. 86 87 "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_other" "$SENDER" \ 88 > out2fo.tmp 89 90 grep -q "^20141126T150000Z${TAB}20141126T160000Z" out2fo.tmp \ 91 && echo "Success" \ 92 || echo "Failed" 93 94 # Accept the invitation. 95 96 cat > event_accept_cmd.tmp <<EOF 97 0 98 attendance accept 99 finish 100 update event_accept.tmp 101 EOF 102 103 "$TEXT_CLIENT" $ARGS -u "$USER" -f event.tmp --echo \ 104 < event_accept_cmd.tmp \ 105 > event_accept_log.tmp 106 107 # Register the acceptance at the recipient. 108 109 "$OUTGOING_SCRIPT" < event_accept.tmp $ARGS 2>> $ERROR 110 111 # Expect free/busy periods at the recipient. 112 113 "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ 114 > out3f.tmp 115 116 grep -q "^20141126T150000Z${TAB}20141126T160000Z" out3f.tmp \ 117 && echo "Success" \ 118 || echo "Failed" 119 120 # Make another event at the same time. 121 122 sed \ 123 's/summary Meeting at 4pm/summary A conflicting meeting at 4pm/;'\ 124 's/update event.tmp/update event_conflicting.tmp/;'\ 125 's/UID event_uid.tmp/UID event_conflicting_uid.tmp/' event_cmd.tmp \ 126 > event_conflicting_cmd.tmp 127 128 "$TEXT_CLIENT" $ARGS -u "$SENDER" --echo \ 129 < event_conflicting_cmd.tmp \ 130 > event_conflicting_log.tmp 131 132 # Obtain the event UID. 133 134 read UID2 < event_conflicting_uid.tmp 135 136 # Present the event to the recipient. 137 138 "$PERSON_SCRIPT" $ARGS < event_conflicting.tmp 2>> $ERROR \ 139 | "$SHOWMAIL" \ 140 > out4.tmp 141 142 # Expect no reply because the recipient must handle the request. 143 144 ! grep -q 'METHOD:REPLY' out4.tmp \ 145 && echo "Success" \ 146 || echo "Failed" 147 148 # Expect no free/busy periods for the recipient for this event. 149 150 "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ 151 > out4f.tmp 152 153 ! grep -q "$UID2" out4f.tmp \ 154 && echo "Success" \ 155 || echo "Failed" 156 157 # Expect free/busy periods for the sender at the recipient for this event. 158 159 "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_other" "$SENDER" \ 160 > out4fo.tmp 161 162 grep -q "$UID2" out4fo.tmp \ 163 && echo "Success" \ 164 || echo "Failed" 165 166 # Decline the invitation. 167 168 cat > event_decline_cmd.tmp <<EOF 169 0 170 attendance decline 171 finish 172 update event_decline.tmp 173 EOF 174 175 "$TEXT_CLIENT" $ARGS -u "$USER" -f event_conflicting.tmp --echo \ 176 < event_decline_cmd.tmp \ 177 > event_decline_log.tmp 178 179 # Register the rejection at the recipient. 180 181 "$OUTGOING_SCRIPT" < event_decline.tmp $ARGS 2>> $ERROR 182 183 # Expect free/busy periods only for the original event, not the last one. 184 185 "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ 186 > out5f.tmp 187 188 grep -q "$UID1" out5f.tmp \ 189 && ! grep -q "$UID2" out5f.tmp \ 190 && echo "Success" \ 191 || echo "Failed" 192 193 # Cancel the event for a recipient. 194 195 cat > event_cancel_cmd.tmp <<EOF 196 0 197 attendee mailto:vincent.vole@example.com remove 198 finish 199 cancel event_cancel.tmp 200 EOF 201 202 "$TEXT_CLIENT" $ARGS -u "$SENDER" --echo -f event.tmp \ 203 < event_cancel_cmd.tmp \ 204 > event_cancel_log.tmp 205 206 # Present the cancellation to the recipient. 207 208 "$PERSON_SCRIPT" $ARGS < event_cancel.tmp 2>> $ERROR \ 209 | "$SHOWMAIL" \ 210 > out6.tmp 211 212 # Expect no reply because the recipient must handle the request. 213 214 ! grep -q 'METHOD:REPLY' out6.tmp \ 215 && echo "Success" \ 216 || echo "Failed" 217 218 # Expect no free/busy periods for the recipient. 219 220 "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ 221 > out6f.tmp 222 223 ! grep -q "$UID1" out6f.tmp \ 224 && echo "Success" \ 225 || echo "Failed" 226 227 # Expect free/busy periods for the sender at the recipient for this event since 228 # only the recipient was uninvited. 229 230 "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_other" "$SENDER" \ 231 > out6fo.tmp 232 233 grep -q "$UID1" out6fo.tmp \ 234 && echo "Success" \ 235 || echo "Failed" 236 237 # Cancel the event for all recipients. 238 239 cat > event_cancel_all_cmd.tmp <<EOF 240 0 241 finish 242 cancel event_cancel_all.tmp 243 EOF 244 245 "$TEXT_CLIENT" $ARGS -u "$SENDER" --echo -f event.tmp \ 246 < event_cancel_all_cmd.tmp \ 247 > event_cancel_all_log.tmp 248 249 # Present the cancellation to the recipient. 250 251 "$PERSON_SCRIPT" $ARGS < "event_cancel_all.tmp" 2>> $ERROR \ 252 | "$SHOWMAIL" \ 253 > out7.tmp 254 255 # Expect no reply because the recipient must handle the request. 256 257 ! grep -q 'METHOD:REPLY' out7.tmp \ 258 && echo "Success" \ 259 || echo "Failed" 260 261 # Expect no free/busy periods for the recipient. 262 263 "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ 264 > out7f.tmp 265 266 ! grep -q "$UID1" "out7f.tmp" \ 267 && echo "Success" \ 268 || echo "Failed" 269 270 # Expect no free/busy periods for the sender at the recipient for this event. 271 272 "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_other" "$SENDER" \ 273 > out7fo.tmp 274 275 ! grep -q "$UID1" "out7fo.tmp" \ 276 && echo "Success" \ 277 || echo "Failed" 278 279 # Create a message from another sender that is largely a copy of the original 280 # event trying to organise the event using someone else's identity. 281 282 sed \ 283 's/summary Meeting at 4pm/summary A spoofed meeting at 4pm/;'\ 284 's/update event.tmp/update event_spoofed.tmp/;'\ 285 's/UID event_uid.tmp/UID event_spoofed_uid.tmp/' event_cmd.tmp \ 286 > event_spoofed_cmd.tmp 287 288 "$TEXT_CLIENT" $ARGS -u "$SENDER" --echo \ 289 < event_spoofed_cmd.tmp \ 290 > event_spoofed_log.tmp 291 292 # Obtain the event UID. 293 294 read UID3 < event_spoofed_uid.tmp 295 296 sed 's/From: paul.boddie/From: harvey.horse/' event_spoofed.tmp \ 297 > event_spoofed_ready.tmp 298 299 # Present the event to the recipient. 300 301 "$PERSON_SCRIPT" $ARGS < "event_spoofed_ready.tmp" 2>> $ERROR \ 302 | "$SHOWMAIL" \ 303 > out8.tmp 304 305 # Expect no reply because the recipient must handle the request. 306 307 ! grep -q 'METHOD:REPLY' out8.tmp \ 308 && echo "Success" \ 309 || echo "Failed" 310 311 # Expect no free/busy periods for the recipient. 312 313 "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ 314 > out8f.tmp 315 316 ! grep -q "$UID3" "out8f.tmp" \ 317 && echo "Success" \ 318 || echo "Failed" 319 320 # Expect no free/busy periods for the sender at the recipient. 321 322 "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_other" "$SENDER" \ 323 > out8fo.tmp 324 325 ! grep -q "$UID3" "out8fo.tmp" \ 326 && echo "Success" \ 327 || echo "Failed"