imip-agent

Annotated tests/test_resource_invitation_constraints_next_free.sh

1343:f184dc45aadf
2017-10-18 Paul Boddie Attempt to prevent erroneous store type configuration overriding.
paul@942 1
#!/bin/sh
paul@942 2
paul@1024 3
. "`dirname \"$0\"`/common.sh"
paul@942 4
paul@942 5
USER="mailto:resource-room-sauna@example.com"
paul@942 6
SENDER="mailto:paul.boddie@example.com"
paul@942 7
RIVALSENDER="mailto:vincent.vole@example.com"
paul@942 8
paul@942 9
mkdir -p "$PREFS/$USER"
paul@942 10
echo 'Europe/Oslo' > "$PREFS/$USER/TZID"
paul@942 11
echo 'share' > "$PREFS/$USER/freebusy_sharing"
paul@942 12
echo 'schedule_next_available_in_freebusy' > "$PREFS/$USER/scheduling_function"
paul@942 13
echo 'PT60S' > "$PREFS/$USER/freebusy_offers"
paul@942 14
paul@942 15
  "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \
paul@942 16
| "$SHOWMAIL" \
paul@942 17
> out0.tmp
paul@942 18
paul@942 19
   grep -q 'METHOD:REPLY' out0.tmp \
paul@942 20
&& ! grep -q '^FREEBUSY' out0.tmp \
paul@942 21
&& echo "Success" \
paul@942 22
|| echo "Failed"
paul@942 23
paul@942 24
# Let the rival sender book the resource.
paul@942 25
paul@942 26
"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-busy.txt" 2>> $ERROR
paul@942 27
paul@1089 28
   "$LIST_SCRIPT" $LIST_ARGS "$RIVALSENDER" "freebusy" \
paul@1089 29
>  out0s.tmp
paul@1089 30
paul@1089 31
   [ `grep "event19@example.com" "out0s.tmp" | wc -l` = '5' ] \
paul@1089 32
&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out0s.tmp" \
paul@942 33
&& echo "Success" \
paul@942 34
|| echo "Failed"
paul@942 35
paul@942 36
# Present the request to the resource.
paul@942 37
paul@942 38
  "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-busy.txt" 2>> $ERROR \
paul@942 39
| tee out1r.tmp \
paul@942 40
| "$SHOWMAIL" \
paul@942 41
> out1.tmp
paul@942 42
paul@942 43
   grep -q 'METHOD:REPLY' out1.tmp \
paul@942 44
&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T160000' out1.tmp \
paul@942 45
&& echo "Success" \
paul@942 46
|| echo "Failed"
paul@942 47
paul@1089 48
   "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \
paul@1089 49
>  out1f.tmp
paul@1089 50
paul@1089 51
   [ `grep "event19@example.com" "out1f.tmp" | wc -l` = '5' ] \
paul@1089 52
&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out1f.tmp" \
paul@942 53
&& echo "Success" \
paul@942 54
|| echo "Failed"
paul@942 55
paul@942 56
# Present the response to the rival sender.
paul@942 57
paul@942 58
  "$PERSON_SCRIPT" $ARGS < out1r.tmp 2>> $ERROR \
paul@942 59
| tee out2r.tmp \
paul@942 60
| "$SHOWMAIL" \
paul@942 61
> out2.tmp
paul@942 62
paul@945 63
# Publish some conflicting periods as busy.
paul@945 64
paul@945 65
  "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-publish-conflicts.txt" 2>> $ERROR \
paul@945 66
| "$SHOWMAIL" \
paul@945 67
> out3.tmp
paul@945 68
paul@1089 69
   "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_other" "$SENDER" \
paul@1089 70
>  out3f.tmp
paul@1089 71
paul@1089 72
   grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out3f.tmp" \
paul@1089 73
&& grep -q "^20141126T180000Z${TAB}20141126T190000Z" "out3f.tmp" \
paul@945 74
&& echo "Success" \
paul@945 75
|| echo "Failed"
paul@945 76
paul@942 77
# Attempt to schedule an event with the resource.
paul@942 78
paul@942 79
"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR
paul@942 80
paul@1089 81
   "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \
paul@1089 82
|  tee out3s.tmp \
paul@1089 83
|  grep -q "^20141126T150000Z${TAB}20141126T154500Z" \
paul@942 84
&& echo "Success" \
paul@942 85
|| echo "Failed"
paul@942 86
paul@942 87
# Present the request to the resource. This should cause the event to be
paul@945 88
# proposed not just after the requested period, but also after the busy periods
paul@945 89
# published to the resource.
paul@942 90
paul@942 91
  "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR \
paul@942 92
| tee out6r.tmp \
paul@942 93
| "$SHOWMAIL" \
paul@942 94
> out6.tmp
paul@942 95
paul@942 96
   grep -q 'METHOD:COUNTER' out6.tmp \
paul@942 97
&& ! grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out6.tmp \
paul@942 98
&& echo "Success" \
paul@942 99
|| echo "Failed"
paul@942 100
paul@1089 101
   "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \
paul@1089 102
>  out6o.tmp
paul@1089 103
paul@1089 104
   ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "out6o.tmp" \
paul@1089 105
&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "out6o.tmp" \
paul@1089 106
&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "out6o.tmp" \
paul@1089 107
&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "out6o.tmp" \
paul@1089 108
&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "out6o.tmp" \
paul@1089 109
&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "out6o.tmp" \
paul@942 110
&& echo "Success" \
paul@942 111
|| echo "Failed"
paul@942 112
paul@942 113
# Present the response to the organiser.
paul@942 114
paul@942 115
  "$PERSON_SCRIPT" $ARGS < out6r.tmp 2>> $ERROR \
paul@942 116
| tee out7r.tmp \
paul@942 117
| "$SHOWMAIL" \
paul@942 118
> out7.tmp
paul@942 119
paul@1089 120
   "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \
paul@1089 121
>  out7s.tmp
paul@1089 122
paul@1089 123
   grep -q "^20141126T150000Z${TAB}20141126T154500Z" "out7s.tmp" \
paul@1089 124
&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "out7s.tmp" \
paul@942 125
&& echo "Success" \
paul@942 126
|| echo "Failed"
paul@942 127
paul@1089 128
   "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "countered_object" "event13@example.com" "$USER" \
paul@1089 129
|  tee out7C.tmp \
paul@1089 130
|  grep -q "event13@example.com" \
paul@942 131
&& echo "Success" \
paul@942 132
|| echo "Failed"
paul@942 133
paul@1089 134
   "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "requests" \
paul@1089 135
|  tee out7R.tmp \
paul@1089 136
|  grep -q 'event13@example.com' \
paul@942 137
&& echo "Success" \
paul@942 138
|| echo "Failed"
paul@942 139
paul@942 140
# Reschedule the event by accepting the counter-proposal.
paul@942 141
paul@942 142
  sed 's/COUNTER/REQUEST/' < out6.tmp \
paul@942 143
| sed 's/^From: calendar/To: resource-room-sauna/' \
paul@942 144
| sed 's/^To: paul.boddie/From: paul.boddie/' \
paul@942 145
> out8.tmp
paul@942 146
paul@942 147
"$OUTGOING_SCRIPT" $ARGS < out8.tmp 2>> $ERROR
paul@942 148
paul@1089 149
   "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \
paul@1089 150
>  out8s.tmp
paul@1089 151
paul@1089 152
   ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "out8s.tmp" \
paul@1089 153
&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "out8s.tmp" \
paul@942 154
&& echo "Success" \
paul@942 155
|| echo "Failed"
paul@942 156
paul@1089 157
   "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "countered_object" "event13@example.com" "$USER" \
paul@1089 158
>  out8C.tmp
paul@1089 159
paul@1089 160
   ! grep -q "event13@example.com" "out8C.tmp" \
paul@942 161
&& echo "Success" \
paul@942 162
|| echo "Failed"
paul@942 163
paul@1089 164
   "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "requests" \
paul@1089 165
>  out8R.tmp
paul@1089 166
paul@1089 167
   ! grep -q 'event13@example.com' "out8R.tmp" \
paul@942 168
&& echo "Success" \
paul@942 169
|| echo "Failed"
paul@942 170
paul@942 171
  "$RESOURCE_SCRIPT" $ARGS < out8.tmp 2>> $ERROR \
paul@942 172
| "$SHOWMAIL" \
paul@942 173
> out9.tmp
paul@942 174
paul@942 175
   grep -q 'METHOD:REPLY' out9.tmp \
paul@945 176
&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T210000' out9.tmp \
paul@942 177
&& echo "Success" \
paul@942 178
|| echo "Failed"
paul@942 179
paul@1089 180
   "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \
paul@1089 181
>  out9o.tmp
paul@1089 182
paul@1089 183
   ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "out9o.tmp" \
paul@1089 184
&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "out9o.tmp" \
paul@1089 185
&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "out9o.tmp" \
paul@1089 186
&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "out9o.tmp" \
paul@1089 187
&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "out9o.tmp" \
paul@1089 188
&& ! grep -q "^20141126T200000Z${TAB}20141126T204500Z" "out9o.tmp" \
paul@942 189
&& echo "Success" \
paul@942 190
|| echo "Failed"
paul@942 191
paul@1089 192
   "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \
paul@1089 193
>  out9f.tmp
paul@1089 194
paul@1089 195
   [ `grep "event19@example.com" "out9f.tmp" | wc -l` = '5' ] \
paul@1089 196
&& [ `grep "event13@example.com" "out9f.tmp" | wc -l` = '1' ] \
paul@1089 197
&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "out9f.tmp" \
paul@942 198
&& echo "Success" \
paul@942 199
|| echo "Failed"
paul@956 200
paul@956 201
# Test updating the event to see if the resource can handle this.
paul@956 202
paul@956 203
  "$RESOURCE_SCRIPT" $ARGS < out8.tmp 2>> $ERROR \
paul@956 204
| "$SHOWMAIL" \
paul@956 205
> out10.tmp
paul@956 206
paul@956 207
   grep -q 'METHOD:REPLY' out10.tmp \
paul@956 208
&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T210000' out10.tmp \
paul@956 209
&& echo "Success" \
paul@956 210
|| echo "Failed"
paul@956 211
paul@1089 212
   "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \
paul@1089 213
>  out10o.tmp
paul@1089 214
paul@1089 215
   ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "out10o.tmp" \
paul@1089 216
&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "out10o.tmp" \
paul@1089 217
&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "out10o.tmp" \
paul@1089 218
&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "out10o.tmp" \
paul@1089 219
&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "out10o.tmp" \
paul@1089 220
&& ! grep -q "^20141126T200000Z${TAB}20141126T204500Z" "out10o.tmp" \
paul@956 221
&& echo "Success" \
paul@956 222
|| echo "Failed"
paul@956 223
paul@1089 224
   "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \
paul@1089 225
>  out10f.tmp
paul@1089 226
paul@1089 227
   [ `grep "event19@example.com" "out10f.tmp" | wc -l` = '5' ] \
paul@1089 228
&& [ `grep "event13@example.com" "out10f.tmp" | wc -l` = '1' ] \
paul@1089 229
&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "out10f.tmp" \
paul@956 230
&& echo "Success" \
paul@956 231
|| echo "Failed"
paul@957 232
paul@957 233
# Test scheduling again with a different period. This should disregard the
paul@957 234
# existing event periods when computing availability in order to be able to
paul@957 235
# offer them again. Otherwise, an offer would be made for even later periods.
paul@957 236
paul@957 237
  sed 's/20141126T160000/20141126T161500/' < "$TEMPLATES/event-request-sauna-good.txt" \
paul@957 238
| tee out11.tmp \
paul@957 239
| "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \
paul@957 240
| "$SHOWMAIL" \
paul@957 241
> out12.tmp
paul@957 242
paul@957 243
   grep -q 'METHOD:COUNTER' out12.tmp \
paul@957 244
&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T210000' out12.tmp \
paul@957 245
&& echo "Success" \
paul@957 246
|| echo "Failed"
paul@957 247
paul@957 248
# Note that the duration is different now.
paul@957 249
paul@1089 250
   "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \
paul@1089 251
>  out12o.tmp
paul@1089 252
paul@1089 253
   ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "out12o.tmp" \
paul@1089 254
&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "out12o.tmp" \
paul@1089 255
&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "out12o.tmp" \
paul@1089 256
&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "out12o.tmp" \
paul@1089 257
&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "out12o.tmp" \
paul@1089 258
&& grep -q "^20141126T200000Z${TAB}20141126T203000Z" "out12o.tmp" \
paul@957 259
&& echo "Success" \
paul@957 260
|| echo "Failed"
paul@957 261
paul@1089 262
   "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \
paul@1089 263
>  out12f.tmp
paul@1089 264
paul@1089 265
   [ `grep "event19@example.com" "out12f.tmp" | wc -l` = '5' ] \
paul@1089 266
&& [ `grep "event13@example.com" "out12f.tmp" | wc -l` = '1' ] \
paul@1089 267
&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "out12f.tmp" \
paul@957 268
&& echo "Success" \
paul@957 269
|| echo "Failed"