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