imip-agent

tests/test_resource_invitation_constraints_quota_delegation.sh

1261:1aa985ba6e76
2017-09-13 Paul Boddie Moved period removal logic into the data module.
     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 USER1ADDRESS="resource-car-porsche911@example.com"    10 USER2ADDRESS="resource-car-fiat500@example.com"    11 SENDER1ADDRESS="paul.boddie@example.com"    12 SENDER2ADDRESS="vincent.vole@example.com"    13 QUOTA=cars    14 OTHER_QUOTA=rooms    15     16 # Test delegation using the default "available" policy, preferring the recipient    17 # over other available delegates. The schedule_in_freebusy function is also used    18 # to insist that the resources can schedule any reservation.    19     20 # The result should be the reservation of USER1, then an attempt to reserve    21 # USER1 again should be delegated to USER2, with USER2 being available in the    22 # requested period. This delegation should then succeed.    23     24 mkdir -p "$PREFS/$USER1"    25 echo 'Europe/Oslo' > "$PREFS/$USER1/TZID"    26 echo 'share' > "$PREFS/$USER1/freebusy_sharing"    27 cat > "$PREFS/$USER1/scheduling_function" <<EOF    28 schedule_for_delegate $QUOTA    29 schedule_in_freebusy    30 EOF    31     32 mkdir -p "$PREFS/$USER2"    33 echo 'Europe/Oslo' > "$PREFS/$USER2/TZID"    34 echo 'share' > "$PREFS/$USER2/freebusy_sharing"    35 cat > "$PREFS/$USER2/scheduling_function" <<EOF    36 schedule_for_delegate $QUOTA    37 schedule_in_freebusy    38 EOF    39     40 # Have a common group for all organisers when scheduling.    41     42 cat <<EOF | "$SET_QUOTA_GROUPS" "$QUOTA" $SET_QUOTA_GROUPS_ARGS    43 * all    44 EOF    45     46 # Set a common quota.    47     48 cat <<EOF | "$SET_QUOTA_LIMITS" "$QUOTA" $SET_QUOTA_LIMITS_ARGS    49 all *    50 EOF    51     52 # Allow cars to delegate to each other.    53     54 cat <<EOF | "$SET_DELEGATES" "$QUOTA" $SET_DELEGATES_ARGS    55 mailto:resource-car-porsche911@example.com    56 mailto:resource-car-fiat500@example.com    57 EOF    58     59   "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-car.txt" 2>> $ERROR \    60 | "$SHOWMAIL" \    61 > out0.tmp    62     63    grep -q 'METHOD:REPLY' out0.tmp \    64 && ! grep -q '^FREEBUSY' out0.tmp \    65 && echo "Success" \    66 || echo "Failed"    67     68 # Attempt to schedule an event.    69     70 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR    71     72    "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \    73 |  tee out0s.tmp \    74 |  grep -q "^20141126T150000Z${TAB}20141126T160000Z" \    75 && echo "Success" \    76 || echo "Failed"    77     78 # Present the request to the resource.    79     80   "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR \    81 | tee out1r.tmp \    82 | "$SHOWMAIL" \    83 > out1.tmp    84     85    grep -q 'METHOD:REPLY' out1.tmp \    86 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out1.tmp \    87 && echo "Success" \    88 || echo "Failed"    89     90    "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \    91 |  tee out1f.tmp \    92 |  grep -q "^20141126T150000Z${TAB}20141126T160000Z" \    93 && echo "Success" \    94 || echo "Failed"    95     96 # Check the quota (event is confirmed).    97     98    "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "all" \    99 |  tee out1e.tmp \   100 |  grep -q "event21@example.com" \   101 && echo "Success" \   102 || echo "Failed"   103    104 # Attempt to schedule another event.   105    106 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-delegating.txt" 2>> $ERROR   107    108    "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy" \   109 |  tee out1s.tmp \   110 |  grep -q "^20141126T153000Z${TAB}20141126T163000Z" \   111 && echo "Success" \   112 || echo "Failed"   113    114 # Present the request to the resource.   115    116   "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-delegating.txt" 2>> $ERROR \   117 > out2r.tmp   118    119   "$SHOWMAIL" < out2r.tmp \   120 > out2p0.tmp   121    122   "$SHOWMAIL" 1 < out2r.tmp \   123 > out2p1.tmp   124    125 if grep -q "To: $SENDER2ADDRESS" out2p0.tmp ; then   126     ORGFN=out2p0.tmp ; DELFN=out2p1.tmp   127 else   128     ORGFN=out2p1.tmp ; DELFN=out2p0.tmp   129 fi   130    131 # One of the responses will be a request sent to the delegate.   132    133    grep -q "To: $USER2ADDRESS" "$DELFN" \   134 && grep -q 'METHOD:REQUEST' "$DELFN" \   135 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$DELFN" \   136 && grep -q 'ATTENDEE.*:'"$USER2" "$DELFN" \   137 && echo "Success" \   138 || echo "Failed"   139    140 # The other will be a reply to the organiser.   141    142    grep -q "To: $SENDER2ADDRESS" "$ORGFN" \   143 && grep -q 'METHOD:REPLY' "$ORGFN" \   144 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$ORGFN" \   145 && grep -q 'ATTENDEE.*:'"$USER2" "$ORGFN" \   146 && echo "Success" \   147 || echo "Failed"   148    149 # Neither the delegator or the delegate will have changed their schedules.   150    151    "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \   152 >  out2f1.tmp   153    154    ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out2f1.tmp" \   155 && echo "Success" \   156 || echo "Failed"   157    158    "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \   159 >  out2f2.tmp   160    161    ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out2f2.tmp" \   162 && echo "Success" \   163 || echo "Failed"   164    165 # Check the quota (event is not confirmed).   166    167    "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "all" \   168 >  out2e.tmp   169    170    grep -q "event21@example.com" "out2e.tmp" \   171 && ! grep -q "event27@example.com" "out2e.tmp" \   172 && echo "Success" \   173 || echo "Failed"   174    175 # Present the reply to the organiser.   176    177   "$PERSON_SCRIPT" $ARGS < "$ORGFN" 2>> "$ERROR" \   178 | tee out3r.tmp \   179 | "$SHOWMAIL" \   180 > out3.tmp   181    182 # Check the free/busy status of the attendees at the organiser.   183 # Currently, neither are attending.   184    185    "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER1" \   186 >  out3s0.tmp \   187    188    ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out3s0.tmp \   189 && echo "Success" \   190 || echo "Failed"   191    192    "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER2" \   193 >  out3s1.tmp \   194    195    ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out3s1.tmp \   196 && echo "Success" \   197 || echo "Failed"   198    199 # Present the request to the delegate.   200    201   "$RESOURCE_SCRIPT" $ARGS < "$DELFN" 2>> "$ERROR" \   202 > out4r.tmp   203    204   "$SHOWMAIL" < out4r.tmp \   205 > out4p0.tmp   206    207   "$SHOWMAIL" 1 < out4r.tmp \   208 > out4p1.tmp   209    210 if grep -q "To: $SENDER2ADDRESS" out4p0.tmp ; then   211     ORGFN=out4p0.tmp ; DELFN=out4p1.tmp   212 else   213     ORGFN=out4p1.tmp ; DELFN=out4p0.tmp   214 fi   215    216 # One of the responses will be a reply sent to the organiser.   217    218    grep -q "To: $SENDER2ADDRESS" "$ORGFN" \   219 && grep -q 'METHOD:REPLY' "$ORGFN" \   220 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$ORGFN" \   221 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED.*:'"$USER2" "$ORGFN" \   222 && echo "Success" \   223 || echo "Failed"   224    225 # The other will be a reply to the delegator.   226    227    grep -q "To: $USER1ADDRESS" "$DELFN" \   228 && grep -q 'METHOD:REPLY' "$DELFN" \   229 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$DELFN" \   230 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED.*:'"$USER2" "$DELFN" \   231 && echo "Success" \   232 || echo "Failed"   233    234 # The delegate should now have a changed schedule.   235    236    "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \   237 >  out4f0.tmp   238    239    ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out4f0.tmp" \   240 && echo "Success" \   241 || echo "Failed"   242    243    "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \   244 >  out4f1.tmp   245    246    grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out4f1.tmp" \   247 && echo "Success" \   248 || echo "Failed"   249    250 # Present the reply to the organiser.   251    252   "$PERSON_SCRIPT" $ARGS < "$ORGFN" 2>> "$ERROR" \   253 | tee out5r.tmp \   254 | "$SHOWMAIL" \   255 > out5.tmp   256    257 # Check the free/busy status of the attendees at the organiser.   258 # Now, the delegate is attending.   259    260    "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER1" \   261 >  out5s0.tmp \   262    263    ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out5s0.tmp \   264 && echo "Success" \   265 || echo "Failed"   266    267    "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER2" \   268 >  out5s1.tmp \   269    270    grep -q "^20141126T153000Z${TAB}20141126T163000Z" out5s1.tmp \   271 && echo "Success" \   272 || echo "Failed"   273    274 # Present the reply to the delegator.   275    276   "$RESOURCE_SCRIPT" $ARGS < "$DELFN" 2>> "$ERROR" \   277 > out6r.tmp