imip-agent

Annotated tests/test_person_invitation_recurring.sh

871:b38466ae1e51
2015-10-18 Paul Boddie Handle rule-based occurrences as exceptions when removed by attendees for counter-proposals.
paul@594 1
#!/bin/sh
paul@594 2
paul@594 3
THIS_DIR=`dirname $0`
paul@594 4
paul@594 5
TEMPLATES="$THIS_DIR/templates"
paul@594 6
PERSON_SCRIPT="$THIS_DIR/../imip_person.py"
paul@594 7
SHOWMAIL="$THIS_DIR/../tools/showmail.py"
paul@594 8
STORE=/tmp/store
paul@594 9
STATIC=/tmp/static
paul@640 10
PREFS=/tmp/prefs
paul@640 11
ARGS="-S $STORE -P $STATIC -p $PREFS -d"
paul@594 12
USER="mailto:vincent.vole@example.com"
paul@594 13
SENDER="mailto:paul.boddie@example.com"
paul@594 14
FBFILE="$STORE/$USER/freebusy"
paul@594 15
FBOTHERFILE="$STORE/$USER/freebusy-other/$SENDER"
paul@685 16
FBSENDERFILE="$STORE/$SENDER/freebusy"
paul@594 17
TAB=`printf '\t'`
paul@594 18
paul@594 19
OUTGOING_SCRIPT="$THIS_DIR/../imip_person_outgoing.py"
paul@594 20
paul@594 21
PYTHONPATH="$THIS_DIR/.."
paul@594 22
export PYTHONPATH
paul@594 23
paul@594 24
ACCEPT_SCRIPT="$THIS_DIR/test_handle.py"
paul@594 25
ACCEPT_ARGS="accept $STORE"
paul@594 26
paul@594 27
DECLINE_SCRIPT="$THIS_DIR/test_handle.py"
paul@594 28
DECLINE_ARGS="decline $STORE"
paul@594 29
paul@602 30
ERROR=err.tmp
paul@602 31
paul@594 32
rm -r $STORE
paul@594 33
rm -r $STATIC
paul@640 34
rm -r $PREFS
paul@602 35
rm $ERROR
paul@602 36
rm out*.tmp
paul@594 37
paul@640 38
mkdir -p "$PREFS/$USER"
paul@640 39
echo 'Europe/Oslo' > "$PREFS/$USER/TZID"
paul@640 40
echo 'share' > "$PREFS/$USER/freebusy_sharing"
paul@640 41
paul@685 42
mkdir -p "$PREFS/$SENDER"
paul@685 43
echo 'Europe/Oslo' > "$PREFS/$USER/TZID"
paul@685 44
paul@685 45
# Test free/busy responses.
paul@685 46
paul@602 47
  "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \
paul@594 48
| "$SHOWMAIL" \
paul@594 49
> out0.tmp
paul@594 50
paul@594 51
   grep -q 'METHOD:REPLY' out0.tmp \
paul@594 52
&& ! grep -q '^FREEBUSY' out0.tmp \
paul@594 53
&& echo "Success" \
paul@594 54
|| echo "Failed"
paul@594 55
paul@602 56
  "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person.txt" 2>> $ERROR \
paul@594 57
| "$SHOWMAIL" \
paul@594 58
> out1.tmp
paul@594 59
paul@594 60
   grep -q 'METHOD:REPLY' out1.tmp \
paul@594 61
&& ! grep -q '^FREEBUSY' out1.tmp \
paul@594 62
&& echo "Success" \
paul@594 63
|| echo "Failed"
paul@594 64
paul@685 65
# Publish an event, testing registration in the outgoing handler.
paul@685 66
paul@685 67
"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring.txt" 2>> $ERROR
paul@685 68
paul@685 69
   grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBSENDERFILE" \
paul@685 70
&& echo "Success" \
paul@685 71
|| echo "Failed"
paul@685 72
paul@685 73
# Test registration in the incoming handler for the recipient.
paul@685 74
paul@602 75
  "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring.txt" 2>> $ERROR \
paul@594 76
| "$SHOWMAIL" \
paul@594 77
> out2.tmp
paul@594 78
paul@594 79
   ! grep -q 'METHOD:REPLY' out2.tmp \
paul@594 80
&& echo "Success" \
paul@594 81
|| echo "Failed"
paul@594 82
paul@708 83
   ! [ -e "$FBFILE" ] \
paul@708 84
|| ! grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \
paul@594 85
&& echo "Success" \
paul@594 86
|| echo "Failed"
paul@594 87
paul@594 88
   grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBOTHERFILE" \
paul@594 89
&& echo "Success" \
paul@594 90
|| echo "Failed"
paul@594 91
paul@685 92
# Test acceptance and registration in the outgoing handler.
paul@685 93
paul@673 94
  "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" 2>> $ERROR \
paul@594 95
| tee out3.tmp \
paul@673 96
| "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR
paul@594 97
paul@594 98
   grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \
paul@594 99
&& echo "Success" \
paul@594 100
|| echo "Failed"
paul@594 101
paul@685 102
# Test recurrence cancellation in the outgoing handler.
paul@685 103
paul@685 104
"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring-instance.txt" 2>> $ERROR
paul@685 105
paul@685 106
   [ `grep "event8@example.com" "$FBSENDERFILE" | wc -l` = '2' ] \
paul@685 107
&& ! grep -q "^20141114T090000Z${TAB}20141114T100000Z" "$FBSENDERFILE" \
paul@685 108
&& echo "Success" \
paul@685 109
|| echo "Failed"
paul@685 110
paul@685 111
# Test cancellation in the incoming handler.
paul@685 112
paul@602 113
  "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring-instance.txt" 2>> $ERROR \
paul@594 114
| "$SHOWMAIL" \
paul@594 115
> out4.tmp
paul@594 116
paul@594 117
   ! grep -q 'METHOD:REPLY' out4.tmp \
paul@594 118
&& echo "Success" \
paul@594 119
|| echo "Failed"
paul@594 120
paul@594 121
   [ `grep "event8@example.com" "$FBFILE" | wc -l` = '2' ] \
paul@594 122
&& ! grep -q "^20141114T090000Z${TAB}20141114T100000Z" "$FBFILE" \
paul@594 123
&& echo "Success" \
paul@594 124
|| echo "Failed"
paul@594 125
paul@594 126
   [ `grep "event8@example.com" "$FBOTHERFILE" | wc -l` = '2' ] \
paul@594 127
&& ! grep -q "^20141114T090000Z${TAB}20141114T100000Z" "$FBOTHERFILE" \
paul@594 128
&& echo "Success" \
paul@594 129
|| echo "Failed"
paul@594 130
paul@685 131
# Test rescheduling in the outgoing handler.
paul@685 132
paul@685 133
"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring-reschedule-instance.txt" 2>> $ERROR
paul@685 134
paul@685 135
   grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBSENDERFILE" \
paul@685 136
&& ! grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBSENDERFILE" \
paul@685 137
&& echo "Success" \
paul@685 138
|| echo "Failed"
paul@685 139
paul@685 140
# Test rescheduling in the incoming handler.
paul@685 141
paul@602 142
  "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring-reschedule-instance.txt" 2>> $ERROR \
paul@594 143
| "$SHOWMAIL" \
paul@594 144
> out5.tmp
paul@594 145
paul@594 146
   ! grep -q 'METHOD:REPLY' out5.tmp \
paul@594 147
&& echo "Success" \
paul@594 148
|| echo "Failed"
paul@594 149
paul@594 150
   ! grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBFILE" \
paul@594 151
&& grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBFILE" \
paul@594 152
&& echo "Success" \
paul@594 153
|| echo "Failed"
paul@594 154
paul@594 155
   grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBOTHERFILE" \
paul@594 156
&& ! grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBOTHERFILE" \
paul@594 157
&& echo "Success" \
paul@594 158
|| echo "Failed"
paul@594 159
paul@685 160
# Test rescheduling acceptance in the outgoing handler.
paul@685 161
paul@673 162
  "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" "20141010T080000Z" 2>> $ERROR \
paul@594 163
| tee out6.tmp \
paul@673 164
| "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR
paul@594 165
paul@594 166
   grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBFILE" \
paul@594 167
&& ! grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBFILE" \
paul@594 168
&& echo "Success" \
paul@594 169
|| echo "Failed"
paul@594 170
paul@685 171
# Test complete cancellation in the outgoing handler.
paul@685 172
paul@685 173
"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring.txt" 2>> $ERROR
paul@685 174
paul@685 175
   ! grep -q "event8@example.com" "$FBSENDERFILE" \
paul@685 176
&& echo "Success" \
paul@685 177
|| echo "Failed"
paul@685 178
paul@685 179
# Test complete cancellation in the incoming handler.
paul@685 180
paul@602 181
  "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring.txt" 2>> $ERROR \
paul@594 182
| "$SHOWMAIL" \
paul@594 183
> out6.tmp
paul@594 184
paul@594 185
   ! grep -q 'METHOD:REPLY' out6.tmp \
paul@594 186
&& echo "Success" \
paul@594 187
|| echo "Failed"
paul@594 188
paul@594 189
   ! grep -q "event8@example.com" "$FBFILE" \
paul@594 190
&& echo "Success" \
paul@594 191
|| echo "Failed"
paul@594 192
paul@594 193
   ! grep -q "event8@example.com" "$FBOTHERFILE" \
paul@594 194
&& echo "Success" \
paul@594 195
|| echo "Failed"
paul@644 196
paul@644 197
# Switch time zones.
paul@644 198
paul@644 199
echo 'Europe/Mariehamn' > "$PREFS/$USER/TZID"
paul@644 200
paul@685 201
"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring.txt" 2>> $ERROR
paul@685 202
paul@685 203
   grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBSENDERFILE" \
paul@685 204
&& echo "Success" \
paul@685 205
|| echo "Failed"
paul@685 206
paul@644 207
  "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring.txt" 2>> $ERROR \
paul@644 208
| "$SHOWMAIL" \
paul@644 209
> out7.tmp
paul@644 210
paul@644 211
   ! grep -q 'METHOD:REPLY' out7.tmp \
paul@644 212
&& echo "Success" \
paul@644 213
|| echo "Failed"
paul@644 214
paul@644 215
   ! grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \
paul@644 216
&& echo "Success" \
paul@644 217
|| echo "Failed"
paul@644 218
paul@644 219
   grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBOTHERFILE" \
paul@644 220
&& echo "Success" \
paul@644 221
|| echo "Failed"
paul@644 222
paul@673 223
  "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" 2>> $ERROR \
paul@644 224
| tee out8.tmp \
paul@673 225
| "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR
paul@644 226
paul@644 227
   grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \
paul@644 228
&& echo "Success" \
paul@644 229
|| echo "Failed"
paul@644 230
paul@685 231
"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring.txt" 2>> $ERROR
paul@685 232
paul@685 233
   ! grep -q "event8@example.com" "$FBSENDERFILE" \
paul@685 234
&& echo "Success" \
paul@685 235
|| echo "Failed"
paul@685 236
paul@644 237
  "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring.txt" 2>> $ERROR \
paul@644 238
| "$SHOWMAIL" \
paul@644 239
> out9.tmp
paul@644 240
paul@644 241
   ! grep -q 'METHOD:REPLY' out9.tmp \
paul@644 242
&& echo "Success" \
paul@644 243
|| echo "Failed"
paul@644 244
paul@644 245
   ! grep -q "event8@example.com" "$FBFILE" \
paul@644 246
&& echo "Success" \
paul@644 247
|| echo "Failed"
paul@644 248
paul@644 249
   ! grep -q "event8@example.com" "$FBOTHERFILE" \
paul@644 250
&& echo "Success" \
paul@644 251
|| echo "Failed"
paul@644 252
paul@685 253
# Test floating dates. Here, the outgoing interpretation is different because
paul@685 254
# the sender is in a different time zone.
paul@685 255
paul@685 256
"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring-day-floating.txt" 2>> $ERROR
paul@685 257
paul@685 258
   grep -q "^20141211T230000Z${TAB}20141212T230000Z" "$FBSENDERFILE" \
paul@685 259
&& echo "Success" \
paul@685 260
|| echo "Failed"
paul@685 261
paul@644 262
  "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring-day-floating.txt" 2>> $ERROR \
paul@644 263
| "$SHOWMAIL" \
paul@644 264
> out10.tmp
paul@644 265
paul@644 266
   ! grep -q 'METHOD:REPLY' out10.tmp \
paul@644 267
&& echo "Success" \
paul@644 268
|| echo "Failed"
paul@644 269
paul@644 270
   ! grep -q "^20141211T220000Z${TAB}20141212T220000Z" "$FBFILE" \
paul@644 271
&& echo "Success" \
paul@644 272
|| echo "Failed"
paul@644 273
paul@697 274
# (The organiser is not attending.)
paul@697 275
paul@697 276
   ! grep -q "^20141211T220000Z${TAB}20141212T220000Z" "$FBOTHERFILE" \
paul@644 277
&& echo "Success" \
paul@644 278
|| echo "Failed"
paul@644 279
paul@673 280
  "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event12@example.com" 2>> $ERROR \
paul@644 281
| tee out11.tmp \
paul@673 282
| "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR
paul@644 283
paul@644 284
   grep -q "^20141211T220000Z${TAB}20141212T220000Z" "$FBFILE" \
paul@644 285
&& echo "Success" \
paul@644 286
|| echo "Failed"