imip-agent

tests/test_resource_invitation_constraints_quota_delegation_policy.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 "most-available" policy and without using the    17 # explicit schedule_in_freebusy function since multiple concurrent reservations    18 # are to occur without any limits.    19     20 # The result should be the reservation of USER1, then the reservation of both    21 # USER1 and USER2, followed by an attempt to reserve USER1 that results in the    22 # delegation to USER2 because USER2 is less committed (more available) during    23 # the period concerned.    24     25 mkdir -p "$PREFS/$USER1"    26 echo 'Europe/Oslo' > "$PREFS/$USER1/TZID"    27 echo 'share' > "$PREFS/$USER1/freebusy_sharing"    28 cat > "$PREFS/$USER1/scheduling_function" <<EOF    29 schedule_for_delegate $QUOTA most-available    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 most-available    37 EOF    38     39 # Have a common group for all organisers when scheduling.    40     41 cat <<EOF | "$SET_QUOTA_GROUPS" "$QUOTA" $SET_QUOTA_GROUPS_ARGS    42 * all    43 EOF    44     45 # Set a common quota.    46     47 cat <<EOF | "$SET_QUOTA_LIMITS" "$QUOTA" $SET_QUOTA_LIMITS_ARGS    48 all *    49 EOF    50     51 # Allow cars to delegate to each other.    52     53 cat <<EOF | "$SET_DELEGATES" "$QUOTA" $SET_DELEGATES_ARGS    54 mailto:resource-car-porsche911@example.com    55 mailto:resource-car-fiat500@example.com    56 EOF    57     58   "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-car.txt" 2>> $ERROR \    59 | "$SHOWMAIL" \    60 > out0.tmp    61     62    grep -q 'METHOD:REPLY' out0.tmp \    63 && ! grep -q '^FREEBUSY' out0.tmp \    64 && echo "Success" \    65 || echo "Failed"    66     67 # Attempt to schedule an event.    68     69 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR    70     71    "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \    72 |  tee out0s.tmp \    73 |  grep -q "^20141126T150000Z${TAB}20141126T160000Z" \    74 && echo "Success" \    75 || echo "Failed"    76     77 # Present the request to the resource.    78     79   "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR \    80 | tee out1r.tmp \    81 | "$SHOWMAIL" \    82 > out1.tmp    83     84    grep -q 'METHOD:REPLY' out1.tmp \    85 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out1.tmp \    86 && echo "Success" \    87 || echo "Failed"    88     89    "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \    90 |  tee out1f.tmp \    91 |  grep -q "^20141126T150000Z${TAB}20141126T160000Z" \    92 && echo "Success" \    93 || echo "Failed"    94     95 # Check the quota (event is confirmed).    96     97    "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "all" \    98 |  tee out1e.tmp \    99 |  grep -q "event21@example.com" \   100 && echo "Success" \   101 || echo "Failed"   102    103 # Attempt to schedule another event.   104    105   sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=5/;' "$TEMPLATES/event-request-cars-recurring.txt" \   106 | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR   107    108    "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \   109 >  out2s.tmp   110    111    grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2s.tmp" \   112 && grep -q "event21@example.com" "out2s.tmp" \   113 && grep -q "event25@example.com" "out2s.tmp" \   114 && echo "Success" \   115 || echo "Failed"   116    117 # Present the request to the recipients.   118    119   sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=5/;' "$TEMPLATES/event-request-cars-recurring.txt" \   120 | "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \   121 > out2r.tmp   122    123   "$SHOWMAIL" < "out2r.tmp" \   124 > out2p0.tmp   125    126   "$SHOWMAIL" 1 < "out2r.tmp" \   127 > out2p1.tmp   128    129    grep -q 'METHOD:REPLY' out2p0.tmp \   130 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out2p0.tmp \   131 && echo "Success" \   132 || echo "Failed"   133    134    grep -q 'METHOD:REPLY' out2p1.tmp \   135 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out2p1.tmp \   136 && echo "Success" \   137 || echo "Failed"   138    139    "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \   140 >  out2f0.tmp   141    142    grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f0.tmp" \   143 && grep -q "event21@example.com" "out2f0.tmp" \   144 && grep -q "event25@example.com" "out2f0.tmp" \   145 && echo "Success" \   146 || echo "Failed"   147    148    "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \   149 >  out2f1.tmp   150    151    grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f1.tmp" \   152 && grep -q "event25@example.com" "out2f1.tmp" \   153 && echo "Success" \   154 || echo "Failed"   155    156 # Check the quota (event is confirmed).   157    158    "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "all" \   159 |  tee out2e.tmp \   160 |  grep -q "event25@example.com" \   161 && echo "Success" \   162 || echo "Failed"   163    164 # Attempt to schedule another event.   165    166 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-delegating.txt" 2>> $ERROR   167    168    "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy" \   169 |  tee out3s.tmp \   170 |  grep -q "^20141126T153000Z${TAB}20141126T163000Z" \   171 && echo "Success" \   172 || echo "Failed"   173    174 # Present the request to the resource.   175    176   "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-delegating.txt" 2>> $ERROR \   177 > out3r.tmp   178    179   "$SHOWMAIL" < out3r.tmp \   180 > out3p0.tmp   181    182   "$SHOWMAIL" 1 < out3r.tmp \   183 > out3p1.tmp   184    185 if grep -q "To: $SENDER2ADDRESS" out3p0.tmp ; then   186     ORGFN=out3p0.tmp ; DELFN=out3p1.tmp   187 else   188     ORGFN=out3p1.tmp ; DELFN=out3p0.tmp   189 fi   190    191 # One of the responses will be a request sent to the delegate.   192    193    grep -q "To: $USER2ADDRESS" "$DELFN" \   194 && grep -q 'METHOD:REQUEST' "$DELFN" \   195 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$DELFN" \   196 && grep -q 'ATTENDEE.*:'"$USER2" "$DELFN" \   197 && echo "Success" \   198 || echo "Failed"   199    200 # The other will be a reply to the organiser.   201    202    grep -q "To: $SENDER2ADDRESS" "$ORGFN" \   203 && grep -q 'METHOD:REPLY' "$ORGFN" \   204 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$ORGFN" \   205 && grep -q 'ATTENDEE.*:'"$USER2" "$ORGFN" \   206 && echo "Success" \   207 || echo "Failed"   208    209 # Neither the delegator or the delegate will have changed their schedules.   210    211    "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \   212 >  out4f1.tmp   213    214    ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out4f1.tmp" \   215 && echo "Success" \   216 || echo "Failed"   217    218    "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \   219 >  out4f2.tmp   220    221    ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out4f2.tmp" \   222 && echo "Success" \   223 || echo "Failed"   224    225 # Check the quota (event is not confirmed).   226    227    "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "all" \   228 >  out4e.tmp   229    230    grep -q "event21@example.com" "out4e.tmp" \   231 && grep -q "event25@example.com" "out4e.tmp" \   232 && ! grep -q "event27@example.com" "out4e.tmp" \   233 && echo "Success" \   234 || echo "Failed"   235    236 # Present the reply to the organiser.   237    238   "$PERSON_SCRIPT" $ARGS < "$ORGFN" 2>> "$ERROR" \   239 | tee out5r.tmp \   240 | "$SHOWMAIL" \   241 > out5.tmp   242    243 # Check the free/busy status of the attendees at the organiser.   244 # Currently, neither are attending.   245    246    "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER1" \   247 >  out5s0.tmp \   248    249    ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out5s0.tmp \   250 && echo "Success" \   251 || echo "Failed"   252    253    "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER2" \   254 >  out5s1.tmp \   255    256    ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out5s1.tmp \   257 && echo "Success" \   258 || echo "Failed"   259    260 # Present the request to the delegate.   261    262   "$RESOURCE_SCRIPT" $ARGS < "$DELFN" 2>> "$ERROR" \   263 > out6r.tmp   264    265   "$SHOWMAIL" < out6r.tmp \   266 > out6p0.tmp   267    268   "$SHOWMAIL" 1 < out6r.tmp \   269 > out6p1.tmp   270    271 if grep -q "To: $SENDER2ADDRESS" out6p0.tmp ; then   272     ORGFN=out6p0.tmp ; DELFN=out6p1.tmp   273 else   274     ORGFN=out6p1.tmp ; DELFN=out6p0.tmp   275 fi   276    277 # One of the responses will be a reply sent to the organiser.   278    279    grep -q "To: $SENDER2ADDRESS" "$ORGFN" \   280 && grep -q 'METHOD:REPLY' "$ORGFN" \   281 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$ORGFN" \   282 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED.*:'"$USER2" "$ORGFN" \   283 && echo "Success" \   284 || echo "Failed"   285    286 # The other will be a reply to the delegator.   287    288    grep -q "To: $USER1ADDRESS" "$DELFN" \   289 && grep -q 'METHOD:REPLY' "$DELFN" \   290 && grep -q 'ATTENDEE.*;PARTSTAT=DELEGATED.*:'"$USER1" "$DELFN" \   291 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED.*:'"$USER2" "$DELFN" \   292 && echo "Success" \   293 || echo "Failed"   294    295 # The delegate should now have a changed schedule.   296    297    "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \   298 >  out7f0.tmp   299    300    ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out7f0.tmp" \   301 && echo "Success" \   302 || echo "Failed"   303    304    "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \   305 >  out7f1.tmp   306    307    grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out7f1.tmp" \   308 && grep -q "event27@example.com" "out7f1.tmp" \   309 && echo "Success" \   310 || echo "Failed"   311    312 # Present the reply to the organiser.   313    314   "$PERSON_SCRIPT" $ARGS < "$ORGFN" 2>> "$ERROR" \   315 | tee out8r.tmp \   316 | "$SHOWMAIL" \   317 > out8.tmp   318    319 # Check the free/busy status of the attendees at the organiser.   320 # Now, the delegate is attending.   321    322    "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER1" \   323 >  out8s0.tmp \   324    325    ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" out8s0.tmp \   326 && ! grep -q "event27@example.com" out8s0.tmp \   327 && echo "Success" \   328 || echo "Failed"   329    330    "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy_other" "$USER2" \   331 >  out8s1.tmp \   332    333    grep -q "^20141126T153000Z${TAB}20141126T163000Z" out8s1.tmp \   334 && grep -q "event27@example.com" out8s1.tmp \   335 && echo "Success" \   336 || echo "Failed"   337    338 # Present the reply to the delegator.   339    340   "$RESOURCE_SCRIPT" $ARGS < "$DELFN" 2>> "$ERROR" \   341 > out9r.tmp