imip-agent

Annotated tests/test_resource_invitation_constraints_quota_delegation.sh

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