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