imip-agent

Annotated tests/test_resource_invitation_constraints_next_free.sh

1045:5a9722130d25
2016-02-08 Paul Boddie Used event-related attributes stored in the handler directly.
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
FBFILE="$STORE/$USER/freebusy"
paul@945 9
FBOTHERFILE="$STORE/$USER/freebusy-other/$SENDER"
paul@942 10
FBOFFERFILE="$STORE/$USER/freebusy-offers"
paul@942 11
FBSENDERFILE="$STORE/$SENDER/freebusy"
paul@942 12
FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER"
paul@942 13
FBSENDERREQUESTS="$STORE/$SENDER/requests"
paul@942 14
FBRIVALSENDERFILE="$STORE/$RIVALSENDER/freebusy"
paul@942 15
paul@942 16
mkdir -p "$PREFS/$USER"
paul@942 17
echo 'Europe/Oslo' > "$PREFS/$USER/TZID"
paul@942 18
echo 'share' > "$PREFS/$USER/freebusy_sharing"
paul@942 19
echo 'schedule_next_available_in_freebusy' > "$PREFS/$USER/scheduling_function"
paul@942 20
echo 'PT60S' > "$PREFS/$USER/freebusy_offers"
paul@942 21
paul@942 22
  "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \
paul@942 23
| "$SHOWMAIL" \
paul@942 24
> out0.tmp
paul@942 25
paul@942 26
   grep -q 'METHOD:REPLY' out0.tmp \
paul@942 27
&& ! grep -q '^FREEBUSY' out0.tmp \
paul@942 28
&& echo "Success" \
paul@942 29
|| echo "Failed"
paul@942 30
paul@942 31
# Let the rival sender book the resource.
paul@942 32
paul@942 33
"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-busy.txt" 2>> $ERROR
paul@942 34
paul@942 35
   [ `grep "event19@example.com" "$FBRIVALSENDERFILE" | wc -l` = '5' ] \
paul@942 36
&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBRIVALSENDERFILE" \
paul@942 37
&& echo "Success" \
paul@942 38
|| echo "Failed"
paul@942 39
paul@942 40
# Present the request to the resource.
paul@942 41
paul@942 42
  "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-busy.txt" 2>> $ERROR \
paul@942 43
| tee out1r.tmp \
paul@942 44
| "$SHOWMAIL" \
paul@942 45
> out1.tmp
paul@942 46
paul@942 47
   grep -q 'METHOD:REPLY' out1.tmp \
paul@942 48
&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T160000' out1.tmp \
paul@942 49
&& echo "Success" \
paul@942 50
|| echo "Failed"
paul@942 51
paul@942 52
   [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \
paul@942 53
&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \
paul@942 54
&& echo "Success" \
paul@942 55
|| echo "Failed"
paul@942 56
paul@942 57
# Present the response to the rival sender.
paul@942 58
paul@942 59
  "$PERSON_SCRIPT" $ARGS < out1r.tmp 2>> $ERROR \
paul@942 60
| tee out2r.tmp \
paul@942 61
| "$SHOWMAIL" \
paul@942 62
> out2.tmp
paul@942 63
paul@945 64
# Publish some conflicting periods as busy.
paul@945 65
paul@945 66
  "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-publish-conflicts.txt" 2>> $ERROR \
paul@945 67
| "$SHOWMAIL" \
paul@945 68
> out3.tmp
paul@945 69
paul@945 70
   grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBOTHERFILE" \
paul@945 71
&& grep -q "^20141126T180000Z${TAB}20141126T190000Z" "$FBOTHERFILE" \
paul@945 72
&& echo "Success" \
paul@945 73
|| echo "Failed"
paul@945 74
paul@942 75
# Attempt to schedule an event with the resource.
paul@942 76
paul@942 77
"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR
paul@942 78
paul@942 79
   grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \
paul@942 80
&& echo "Success" \
paul@942 81
|| echo "Failed"
paul@942 82
paul@942 83
# Present the request to the resource. This should cause the event to be
paul@945 84
# proposed not just after the requested period, but also after the busy periods
paul@945 85
# published to the resource.
paul@942 86
paul@942 87
  "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR \
paul@942 88
| tee out6r.tmp \
paul@942 89
| "$SHOWMAIL" \
paul@942 90
> out6.tmp
paul@942 91
paul@942 92
   grep -q 'METHOD:COUNTER' out6.tmp \
paul@942 93
&& ! grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out6.tmp \
paul@942 94
&& echo "Success" \
paul@942 95
|| echo "Failed"
paul@942 96
paul@942 97
   ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \
paul@945 98
&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \
paul@945 99
&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "$FBOFFERFILE" \
paul@945 100
&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "$FBOFFERFILE" \
paul@945 101
&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "$FBOFFERFILE" \
paul@945 102
&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBOFFERFILE" \
paul@942 103
&& echo "Success" \
paul@942 104
|| echo "Failed"
paul@942 105
paul@942 106
# Present the response to the organiser.
paul@942 107
paul@942 108
  "$PERSON_SCRIPT" $ARGS < out6r.tmp 2>> $ERROR \
paul@942 109
| tee out7r.tmp \
paul@942 110
| "$SHOWMAIL" \
paul@942 111
> out7.tmp
paul@942 112
paul@942 113
   grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \
paul@942 114
&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBSENDERFILE" \
paul@942 115
&& echo "Success" \
paul@942 116
|| echo "Failed"
paul@942 117
paul@942 118
   [ -e "$STORE/$SENDER/counters/objects/event13@example.com/$USER" ] \
paul@942 119
&& echo "Success" \
paul@942 120
|| echo "Failed"
paul@942 121
paul@942 122
   grep -q 'event13@example.com' "$FBSENDERREQUESTS" \
paul@942 123
&& echo "Success" \
paul@942 124
|| echo "Failed"
paul@942 125
paul@942 126
# Reschedule the event by accepting the counter-proposal.
paul@942 127
paul@942 128
  sed 's/COUNTER/REQUEST/' < out6.tmp \
paul@942 129
| sed 's/^From: calendar/To: resource-room-sauna/' \
paul@942 130
| sed 's/^To: paul.boddie/From: paul.boddie/' \
paul@942 131
> out8.tmp
paul@942 132
paul@942 133
"$OUTGOING_SCRIPT" $ARGS < out8.tmp 2>> $ERROR
paul@942 134
paul@942 135
   ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \
paul@945 136
&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBSENDERFILE" \
paul@942 137
&& echo "Success" \
paul@942 138
|| echo "Failed"
paul@942 139
paul@942 140
   ! [ -e "$STORE/$SENDER/counters/objects/event13@example.com/$USER" ] \
paul@942 141
&& echo "Success" \
paul@942 142
|| echo "Failed"
paul@942 143
paul@942 144
   ! grep -q 'event13@example.com' "$FBSENDERREQUESTS" \
paul@942 145
&& echo "Success" \
paul@942 146
|| echo "Failed"
paul@942 147
paul@942 148
  "$RESOURCE_SCRIPT" $ARGS < out8.tmp 2>> $ERROR \
paul@942 149
| "$SHOWMAIL" \
paul@942 150
> out9.tmp
paul@942 151
paul@942 152
   grep -q 'METHOD:REPLY' out9.tmp \
paul@945 153
&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T210000' out9.tmp \
paul@942 154
&& echo "Success" \
paul@942 155
|| echo "Failed"
paul@942 156
paul@942 157
   ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \
paul@942 158
&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \
paul@945 159
&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "$FBOFFERFILE" \
paul@945 160
&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "$FBOFFERFILE" \
paul@945 161
&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "$FBOFFERFILE" \
paul@945 162
&& ! grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBOFFERFILE" \
paul@942 163
&& echo "Success" \
paul@942 164
|| echo "Failed"
paul@942 165
paul@942 166
   [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \
paul@942 167
&& [ `grep "event13@example.com" "$FBFILE" | wc -l` = '1' ] \
paul@945 168
&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBFILE" \
paul@942 169
&& echo "Success" \
paul@942 170
|| echo "Failed"
paul@956 171
paul@956 172
# Test updating the event to see if the resource can handle this.
paul@956 173
paul@956 174
  "$RESOURCE_SCRIPT" $ARGS < out8.tmp 2>> $ERROR \
paul@956 175
| "$SHOWMAIL" \
paul@956 176
> out10.tmp
paul@956 177
paul@956 178
   grep -q 'METHOD:REPLY' out10.tmp \
paul@956 179
&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T210000' out10.tmp \
paul@956 180
&& echo "Success" \
paul@956 181
|| echo "Failed"
paul@956 182
paul@956 183
   ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \
paul@956 184
&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \
paul@956 185
&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "$FBOFFERFILE" \
paul@956 186
&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "$FBOFFERFILE" \
paul@956 187
&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "$FBOFFERFILE" \
paul@956 188
&& ! grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBOFFERFILE" \
paul@956 189
&& echo "Success" \
paul@956 190
|| echo "Failed"
paul@956 191
paul@956 192
   [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \
paul@956 193
&& [ `grep "event13@example.com" "$FBFILE" | wc -l` = '1' ] \
paul@956 194
&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBFILE" \
paul@956 195
&& echo "Success" \
paul@956 196
|| echo "Failed"
paul@957 197
paul@957 198
# Test scheduling again with a different period. This should disregard the
paul@957 199
# existing event periods when computing availability in order to be able to
paul@957 200
# offer them again. Otherwise, an offer would be made for even later periods.
paul@957 201
paul@957 202
  sed 's/20141126T160000/20141126T161500/' < "$TEMPLATES/event-request-sauna-good.txt" \
paul@957 203
| tee out11.tmp \
paul@957 204
| "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \
paul@957 205
| "$SHOWMAIL" \
paul@957 206
> out12.tmp
paul@957 207
paul@957 208
   grep -q 'METHOD:COUNTER' out12.tmp \
paul@957 209
&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T210000' out12.tmp \
paul@957 210
&& echo "Success" \
paul@957 211
|| echo "Failed"
paul@957 212
paul@957 213
# Note that the duration is different now.
paul@957 214
paul@957 215
   ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \
paul@957 216
&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \
paul@957 217
&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "$FBOFFERFILE" \
paul@957 218
&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "$FBOFFERFILE" \
paul@957 219
&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "$FBOFFERFILE" \
paul@957 220
&& grep -q "^20141126T200000Z${TAB}20141126T203000Z" "$FBOFFERFILE" \
paul@957 221
&& echo "Success" \
paul@957 222
|| echo "Failed"
paul@957 223
paul@957 224
   [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \
paul@957 225
&& [ `grep "event13@example.com" "$FBFILE" | wc -l` = '1' ] \
paul@957 226
&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBFILE" \
paul@957 227
&& echo "Success" \
paul@957 228
|| echo "Failed"