1 #!/bin/sh 2 3 . "`dirname \"$0\"`/common.sh" 4 5 USER1="mailto:resource-car-porsche911@example.com" 6 USER2="mailto:resource-car-fiat500@example.com" 7 SENDER1="mailto:paul.boddie@example.com" 8 SENDER2="mailto:vincent.vole@example.com" 9 USER1ADDRESS="resource-car-porsche911@example.com" 10 USER2ADDRESS="resource-car-fiat500@example.com" 11 SENDER1ADDRESS="paul.boddie@example.com" 12 SENDER2ADDRESS="vincent.vole@example.com" 13 QUOTA=cars 14 OTHER_QUOTA=rooms 15 16 mkdir -p "$PREFS/$USER1" 17 echo 'Europe/Oslo' > "$PREFS/$USER1/TZID" 18 echo 'share' > "$PREFS/$USER1/freebusy_sharing" 19 cat > "$PREFS/$USER1/scheduling_function" <<EOF 20 schedule_for_delegate $QUOTA 21 schedule_in_freebusy 22 EOF 23 24 mkdir -p "$PREFS/$USER2" 25 echo 'Europe/Oslo' > "$PREFS/$USER2/TZID" 26 echo 'share' > "$PREFS/$USER2/freebusy_sharing" 27 cat > "$PREFS/$USER2/scheduling_function" <<EOF 28 schedule_for_delegate $QUOTA 29 schedule_in_freebusy 30 EOF 31 32 # Have a common group for all organisers when scheduling. 33 34 cat <<EOF | "$SET_QUOTA_GROUPS" "$QUOTA" $SET_QUOTA_GROUPS_ARGS 35 * all 36 EOF 37 38 # Allow cars to delegate to each other. 39 40 cat <<EOF | "$SET_DELEGATES" "$QUOTA" $SET_DELEGATES_ARGS 41 mailto:resource-car-porsche911@example.com 42 mailto:resource-car-fiat500@example.com 43 EOF 44 45 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-car.txt" 2>> $ERROR \ 46 | "$SHOWMAIL" \ 47 > out0.tmp 48 49 grep -q 'METHOD:REPLY' out0.tmp \ 50 && ! grep -q '^FREEBUSY' out0.tmp \ 51 && echo "Success" \ 52 || echo "Failed" 53 54 # Attempt to schedule an event. 55 56 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR 57 58 "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \ 59 | tee out0s.tmp \ 60 | grep -q "^20141126T150000Z${TAB}20141126T160000Z" \ 61 && echo "Success" \ 62 || echo "Failed" 63 64 # Present the request to the resource. 65 66 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR \ 67 | tee out1r.tmp \ 68 | "$SHOWMAIL" \ 69 > out1.tmp 70 71 grep -q 'METHOD:REPLY' out1.tmp \ 72 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out1.tmp \ 73 && echo "Success" \ 74 || echo "Failed" 75 76 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 77 | tee out1f.tmp \ 78 | grep -q "^20141126T150000Z${TAB}20141126T160000Z" \ 79 && echo "Success" \ 80 || echo "Failed" 81 82 # Check the quota (event is confirmed). 83 84 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "all" \ 85 | tee out1e.tmp \ 86 | grep -q "event21@example.com" \ 87 && echo "Success" \ 88 || echo "Failed" 89 90 # Attempt to schedule another event. 91 92 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-delegating.txt" 2>> $ERROR 93 94 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy" \ 95 | tee out1s.tmp \ 96 | grep -q "^20141126T153000Z${TAB}20141126T163000Z" \ 97 && echo "Success" \ 98 || echo "Failed" 99 100 # Present the request to the resource. 101 102 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-delegating.txt" 2>> $ERROR \ 103 > out2r.tmp 104 105 "$SHOWMAIL" < out2r.tmp \ 106 > out2p0.tmp 107 108 "$SHOWMAIL" 1 < out2r.tmp \ 109 > out2p1.tmp 110 111 if grep -q "To: $SENDER2ADDRESS" out2p0.tmp ; then 112 ORGFN=out2p0.tmp ; DELFN=out2p1.tmp 113 else 114 ORGFN=out2p1.tmp ; DELFN=out2p0.tmp 115 fi 116 117 # One of the responses will be a request sent to the delegate. 118 119 grep -q "To: $USER2ADDRESS" "$DELFN" \ 120 && grep -q 'METHOD:REQUEST' "$DELFN" \ 121 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$DELFN" \ 122 && grep -q 'ATTENDEE.*:'"$USER2" "$DELFN" \ 123 && echo "Success" \ 124 || echo "Failed" 125 126 # The other will be a reply to the organiser. 127 128 grep -q "To: $SENDER2ADDRESS" "$ORGFN" \ 129 && grep -q 'METHOD:REPLY' "$ORGFN" \ 130 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$ORGFN" \ 131 && grep -q 'ATTENDEE.*:'"$USER2" "$ORGFN" \ 132 && echo "Success" \ 133 || echo "Failed" 134 135 # Neither the delegator or the delegate will have changed their schedules. 136 137 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 138 > out2f1.tmp 139 140 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out2f1.tmp" \ 141 && echo "Success" \ 142 || echo "Failed" 143 144 "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ 145 > out2f2.tmp 146 147 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out2f2.tmp" \ 148 && echo "Success" \ 149 || echo "Failed" 150 151 # Check the quota (event is not confirmed). 152 153 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "all" \ 154 > out2e.tmp 155 156 grep -q "event21@example.com" "out2e.tmp" \ 157 && ! grep -q "event27@example.com" "out2e.tmp" \ 158 && echo "Success" \ 159 || echo "Failed" 160 161 # Present the reply to the organiser. 162 163 "$PERSON_SCRIPT" $ARGS < "$ORGFN" 2>> "$ERROR" \ 164 | tee out3r.tmp \ 165 | "$SHOWMAIL" \ 166 > out3.tmp 167 168 # Check the free/busy status of the attendees at the organiser. 169 # Currently, neither are attending. 170 171 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER1" \ 172 > out3s0.tmp \ 173 174 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out3s0.tmp \ 175 && echo "Success" \ 176 || echo "Failed" 177 178 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER2" \ 179 > out3s1.tmp \ 180 181 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out3s1.tmp \ 182 && echo "Success" \ 183 || echo "Failed" 184 185 # Present the request to the delegate. 186 187 "$RESOURCE_SCRIPT" $ARGS < "$DELFN" 2>> "$ERROR" \ 188 > out4r.tmp 189 190 "$SHOWMAIL" < out4r.tmp \ 191 > out4p0.tmp 192 193 "$SHOWMAIL" 1 < out4r.tmp \ 194 > out4p1.tmp 195 196 if grep -q "To: $SENDER2ADDRESS" out4p0.tmp ; then 197 ORGFN=out4p0.tmp ; DELFN=out4p1.tmp 198 else 199 ORGFN=out4p1.tmp ; DELFN=out4p0.tmp 200 fi 201 202 # One of the responses will be a reply sent to the organiser. 203 204 grep -q "To: $SENDER2ADDRESS" "$ORGFN" \ 205 && grep -q 'METHOD:REPLY' "$ORGFN" \ 206 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$ORGFN" \ 207 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED.*:'"$USER2" "$ORGFN" \ 208 && echo "Success" \ 209 || echo "Failed" 210 211 # The other will be a reply to the delegator. 212 213 grep -q "To: $USER1ADDRESS" "$DELFN" \ 214 && grep -q 'METHOD:REPLY' "$DELFN" \ 215 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$DELFN" \ 216 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED.*:'"$USER2" "$DELFN" \ 217 && echo "Success" \ 218 || echo "Failed" 219 220 # The delegate should now have a changed schedule. 221 222 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 223 > out4f1.tmp 224 225 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out4f1.tmp" \ 226 && echo "Success" \ 227 || echo "Failed" 228 229 "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ 230 > out4f2.tmp 231 232 grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out4f2.tmp" \ 233 && echo "Success" \ 234 || echo "Failed" 235 236 # Present the reply to the organiser. 237 238 "$PERSON_SCRIPT" $ARGS < "$ORGFN" 2>> "$ERROR" \ 239 | tee out5r.tmp \ 240 | "$SHOWMAIL" \ 241 > out5.tmp 242 243 # Check the free/busy status of the attendees at the organiser. 244 # Now, the delegate is attending. 245 246 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER1" \ 247 > out5s0.tmp \ 248 249 ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out5s0.tmp \ 250 && echo "Success" \ 251 || echo "Failed" 252 253 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER2" \ 254 > out5s1.tmp \ 255 256 grep -q "^20141126T153000Z${TAB}20141126T163000Z" out5s1.tmp \ 257 && echo "Success" \ 258 || echo "Failed" 259 260 # Present the reply to the delegator. 261 262 "$RESOURCE_SCRIPT" $ARGS < "$DELFN" 2>> "$ERROR" \ 263 > out6r.tmp