imip-agent

tests/test_resource_invitation_constraints_quota_recurring_limits.sh

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