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