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 USERADDRESS="vincent.vole@example.com" 8 SENDERADDRESS="paul.boddie@example.com" 9 10 mkdir -p "$PREFS/$USER" 11 echo 'Europe/Oslo' > "$PREFS/$USER/TZID" 12 echo 'share' > "$PREFS/$USER/freebusy_sharing" 13 echo 'PT60S' > "$PREFS/$USER/freebusy_offers" 14 15 person_script "$TEMPLATES/fb-request-person-all.txt" "out0.tmp" 16 17 is_present 'METHOD:REPLY' "out0.tmp" \ 18 && is_absent '^FREEBUSY' "out0.tmp" \ 19 && success || failed "out0.tmp" 20 21 # Make a new event. 22 23 cat > "event_cmd.tmp" <<EOF 24 new 25 period 0 edit 20141126 16 00 00 Europe/Oslo 20141126 17 00 00 Europe/Oslo 26 attendance accept 27 attendee mailto:vincent.vole@example.com 28 summary Meeting at 4pm 29 finish 30 update event.tmp 31 publish event_self.tmp 32 UID event_uid.tmp 33 EOF 34 35 text_client "$SENDER" "event_cmd.tmp" 36 37 # Obtain the event UID. 38 39 read UID1 < "event_uid.tmp" 40 41 # Register the event at the sender. 42 43 outgoing_script "event.tmp" 44 45 # Expect free/busy periods at the sender. 46 47 list_script "out0f.tmp" "$SENDER" "freebusy" 48 test_freebusy '20141126T150000Z' '20141126T160000Z' "out0f.tmp" 49 50 # Present the request to the recipient. 51 52 person_script "event.tmp" "out1.tmp" 53 54 # Expect no reply because the recipient must handle the request. 55 56 is_absent 'METHOD:REPLY' "out1.tmp" && success || failed "out1.tmp" 57 58 # Expect no free/busy periods for the recipient. 59 60 list_script "out1f.tmp" "$USER" "freebusy" 61 test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out1f.tmp" 62 63 # Expect free/busy periods for the sender at the recipient. 64 65 list_script "out1fo.tmp" "$USER" "freebusy_other" "$SENDER" 66 test_freebusy '20141126T150000Z' '20141126T160000Z' "out1fo.tmp" 67 68 # Counter the invitation. 69 70 cat > "event_counter_cmd.tmp" <<EOF 71 period 0 edit 20141126 17 00 00 Europe/Oslo 20141126 18 00 00 Europe/Oslo 72 finish 73 update event_counter.tmp 74 EOF 75 76 text_client_specific "$USER" "event_counter_cmd.tmp" "$UID1" 77 78 # Expect a counter-proposal from the client. 79 80 showmail "event_counter.tmp" | is_present 'METHOD:COUNTER' \ 81 && success || failed "event_counter.tmp" 82 83 # Note that the invitation has only been prepared, not processed. 84 85 list_script "out2f.tmp" "$USER" "freebusy" 86 test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out2f.tmp" 87 test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out2f.tmp" 88 89 list_script "out2fo.tmp" "$USER" "freebusy_offers" 90 test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out2fo.tmp" 91 92 # Send the counter-proposal. 93 94 outgoing_script "event_counter.tmp" 95 96 # Expect no free/busy periods for the recipient. 97 98 list_script "out2f2.tmp" "$USER" "freebusy" 99 test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out2f2.tmp" 100 test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out2f2.tmp" 101 102 # Expect a free/busy offer period. 103 104 list_script "out2o2.tmp" "$USER" "freebusy_offers" 105 test_freebusy '20141126T160000Z' '20141126T170000Z' "out2o2.tmp" 106 107 # Present the response to the organiser. 108 109 person_script "event_counter.tmp" "out3.tmp" 110 111 # Expect no free/busy periods for the recipient at the sender. 112 113 list_script "out3f.tmp" "$SENDER" "freebusy_other" "$USER" 114 test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out3f.tmp" 115 test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out3f.tmp" 116 117 # Expect the original object at the sender. 118 119 list_script "out3O.tmp" "$SENDER" "object" "$UID1" 120 is_present 'DTSTART;TZID=Europe/Oslo.*:20141126T160000' "out3O.tmp" \ 121 && success || failed "out3O.tmp" 122 123 # Expect the countered object at the sender. 124 125 list_script "out3C.tmp" "$SENDER" "countered_object" "$UID1" "$USER" 126 is_present 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' "out3C.tmp" \ 127 && success || failed "out3C.tmp" 128 129 # Expect a request at the sender. 130 131 list_script "out3R.tmp" "$SENDER" "requests" 132 is_present "$UID1" "out3R.tmp" && success || failed "out3R.tmp" 133 134 # Check the free/busy state of the recipient so far. 135 136 person_script "$TEMPLATES/fb-request-person-all.txt" "out4.tmp" 137 138 is_present 'METHOD:REPLY' "out4.tmp" \ 139 && is_absent '^FREEBUSY' "out4.tmp" \ 140 && success || failed "out4.tmp" 141 142 # Decline the counter-proposal. 143 # NOTE: Support this in the client. 144 145 showmail "event_counter.tmp" \ 146 | sed 's/COUNTER/DECLINECOUNTER/' \ 147 | sed "s/^From: $USERADDRESS/To: $USERADDRESS/" \ 148 | sed "s/^To: $SENDERADDRESS/From: $SENDERADDRESS/" \ 149 > "event_declinecounter.tmp" 150 151 outgoing_script "event_declinecounter.tmp" 152 153 # The countered object should be removed at the sender. 154 155 list_script "out5C.tmp" "$SENDER" "countered_object" "$UID1" "$USER" 156 is_absent "$UID1" "out5C.tmp" && success || failed "out5C.tmp" 157 158 # The request should be removed at the sender. 159 160 list_script "out5R.tmp" "$SENDER" "requests" 161 is_absent "$UID1" "out5R.tmp" && success || failed "out5R.tmp" 162 163 # Present the decline message to the recipient. 164 165 person_script "event_declinecounter.tmp" "out6.tmp" 166 167 # Expect no free/busy periods at the recipient. 168 169 list_script "out6f.tmp" "$USER" "freebusy" 170 test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out6f.tmp" 171 test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out6f.tmp" 172 173 # Expect no free/busy offers at the recipient. 174 175 list_script "out6o.tmp" "$USER" "freebusy_offers" 176 test_freebusy_missing '20141126T150000Z' '20141126T160000Z' "out6o.tmp" 177 test_freebusy_missing '20141126T160000Z' '20141126T170000Z' "out6o.tmp"