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 SENDERADDRESS1="paul.boddie@example.com" 10 SENDERADDRESS2="vincent.vole@example.com" 11 QUOTA=cars 12 13 mkdir -p "$PREFS/$USER1" 14 echo 'Europe/Oslo' > "$PREFS/$USER1/TZID" 15 echo 'share' > "$PREFS/$USER1/freebusy_sharing" 16 cat > "$PREFS/$USER1/scheduling_function" <<EOF 17 schedule_in_freebusy 18 check_quota $QUOTA 19 EOF 20 21 mkdir -p "$PREFS/$USER2" 22 echo 'Europe/Oslo' > "$PREFS/$USER2/TZID" 23 echo 'share' > "$PREFS/$USER2/freebusy_sharing" 24 cat > "$PREFS/$USER2/scheduling_function" <<EOF 25 schedule_in_freebusy 26 check_quota $QUOTA 27 EOF 28 29 "$SET_QUOTA_LIMIT" "$QUOTA" 'mailto:vincent.vole@example.com' 'PT10H' $SET_QUOTA_LIMIT_ARGS 30 "$SET_QUOTA_LIMIT" "$QUOTA" '*' 'PT5H' $SET_QUOTA_LIMIT_ARGS 31 32 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-car-all.txt" 2>> $ERROR \ 33 | "$SHOWMAIL" \ 34 > out0.tmp 35 36 grep -q 'METHOD:REPLY' out0.tmp \ 37 && ! grep -q '^FREEBUSY' out0.tmp \ 38 && echo "Success" \ 39 || echo "Failed" 40 41 # Attempt to schedule an event. 42 43 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-cars-recurring.txt" 2>> $ERROR 44 45 "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \ 46 > out0f.tmp 47 48 grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out0f.tmp" \ 49 && grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out0f.tmp" \ 50 && echo "Success" \ 51 || echo "Failed" 52 53 # Present the request to the resource. 54 55 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-cars-recurring.txt" 2>> $ERROR \ 56 | tee out1r.tmp \ 57 | "$SHOWMAIL" \ 58 > out1.tmp 59 60 grep -q 'METHOD:REPLY' out1.tmp \ 61 && grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out1.tmp \ 62 && echo "Success" \ 63 || echo "Failed" 64 65 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 66 > out1f.tmp 67 68 "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ 69 > out1f2.tmp 70 71 ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out1f.tmp" \ 72 && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out1f.tmp" \ 73 && ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out1f2.tmp" \ 74 && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out1f2.tmp" \ 75 && echo "Success" \ 76 || echo "Failed" 77 78 # Check the quota (event is not confirmed). 79 80 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER1" \ 81 > out1e.tmp 82 83 ! grep -q "event25@example.com" "out1e.tmp" \ 84 && echo "Success" \ 85 || echo "Failed" 86 87 # Modify the event and attempt to schedule it again. 88 89 sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=5/;' "$TEMPLATES/event-request-cars-recurring.txt" \ 90 | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR 91 92 "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \ 93 > out1s.tmp 94 95 grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out1s.tmp" \ 96 && grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out1s.tmp" \ 97 && echo "Success" \ 98 || echo "Failed" 99 100 # Present the request to the resource. 101 102 sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=5/;' "$TEMPLATES/event-request-cars-recurring.txt" \ 103 | "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \ 104 | tee out2r.tmp \ 105 | "$SHOWMAIL" \ 106 > out2.tmp 107 108 # Since the email module used by showmail.py cannot stop after reading a single 109 # message, the second message is obtained. 110 111 grep -n '^From ' out2r.tmp \ 112 | tail -n 1 \ 113 | cut -d ':' -f 1 \ 114 | xargs -I{} tail -n +'{}' out2r.tmp \ 115 | "$SHOWMAIL" \ 116 >> out2.tmp 117 118 grep -q 'METHOD:REPLY' out2.tmp \ 119 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out2.tmp \ 120 && grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out2.tmp \ 121 && echo "Success" \ 122 || echo "Failed" 123 124 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 125 > out2f.tmp 126 127 "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ 128 > out2f2.tmp 129 130 ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f.tmp" \ 131 && ! grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out2f.tmp" \ 132 && grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f2.tmp" \ 133 && grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out2f2.tmp" ) \ 134 || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f2.tmp" \ 135 && ! grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out2f2.tmp" \ 136 && grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f.tmp" \ 137 && grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out2f.tmp" ) \ 138 && echo "Success" \ 139 || echo "Failed" 140 141 # Check the quota (event is confirmed for one resource). 142 143 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER1" \ 144 > out2e.tmp 145 146 grep -q "event25@example.com" "out2e.tmp" \ 147 && echo "Success" \ 148 || echo "Failed" 149 150 # Cancel the event. 151 152 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-cars-recurring.txt" 2>> $ERROR 153 154 "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \ 155 > out2s.tmp 156 157 ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2s.tmp" \ 158 && ! grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out2s.tmp" \ 159 && echo "Success" \ 160 || echo "Failed" 161 162 # Present the request to the resource. 163 164 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-cars-recurring.txt" 2>> $ERROR \ 165 | tee out3r.tmp \ 166 | "$SHOWMAIL" \ 167 > out3.tmp 168 169 ! grep -q 'METHOD:REPLY' out3.tmp \ 170 && echo "Success" \ 171 || echo "Failed" 172 173 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 174 > out3f.tmp 175 176 "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ 177 > out3f2.tmp 178 179 ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out3f.tmp" \ 180 && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out3f.tmp" \ 181 && ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out3f2.tmp" \ 182 && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out3f2.tmp" \ 183 && echo "Success" \ 184 || echo "Failed" 185 186 # Check the quota (event is retracted). 187 188 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER1" \ 189 > out3e.tmp 190 191 ! grep -q "event25@example.com" "out3e.tmp" \ 192 && echo "Success" \ 193 || echo "Failed" 194 195 # Modify the event and attempt to schedule it again. 196 197 sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=5/;' "$TEMPLATES/event-request-cars-recurring.txt" \ 198 | sed "s/$SENDERADDRESS1/$SENDERADDRESS2/;" \ 199 | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR 200 201 "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy" \ 202 > out3s.tmp 203 204 grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out3s.tmp" \ 205 && grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out3s.tmp" \ 206 && echo "Success" \ 207 || echo "Failed" 208 209 # Present the request to the resource. 210 211 sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=5/;' "$TEMPLATES/event-request-cars-recurring.txt" \ 212 | sed "s/$SENDERADDRESS1/$SENDERADDRESS2/;" \ 213 | "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \ 214 | tee out4r.tmp \ 215 | "$SHOWMAIL" \ 216 > out4.tmp 217 218 # Since the email module used by showmail.py cannot stop after reading a single 219 # message, the second message is obtained. 220 221 grep -n '^From ' out4r.tmp \ 222 | tail -n 1 \ 223 | cut -d ':' -f 1 \ 224 | xargs -I{} tail -n +'{}' out4r.tmp \ 225 | "$SHOWMAIL" \ 226 >> out4.tmp 227 228 grep -q 'METHOD:REPLY' out4.tmp \ 229 && [ `grep 'ATTENDEE.*;PARTSTAT=ACCEPTED' out4.tmp | wc -l` = '2' ] \ 230 && echo "Success" \ 231 || echo "Failed" 232 233 "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ 234 > out4f.tmp 235 236 "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ 237 > out4f2.tmp 238 239 grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out4f.tmp" \ 240 && grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out4f.tmp" \ 241 && grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out4f2.tmp" \ 242 && grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out4f2.tmp" \ 243 && echo "Success" \ 244 || echo "Failed" 245 246 # Check the quota (event is confirmed for both resources). 247 248 "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER2" \ 249 > out4e.tmp 250 251 grep -q "event25@example.com" "out4e.tmp" \ 252 && echo "Success" \ 253 || echo "Failed"