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