imip-agent

Annotated tests/test_person_invitation_counter.sh

838:40f53e26c74e
2015-10-15 Paul Boddie Added support for adding suggested attendees from counter-proposals.
paul@800 1
#!/bin/sh
paul@800 2
paul@800 3
THIS_DIR=`dirname $0`
paul@800 4
paul@800 5
TEMPLATES="$THIS_DIR/templates"
paul@800 6
PERSON_SCRIPT="$THIS_DIR/../imip_person.py"
paul@800 7
SHOWMAIL="$THIS_DIR/../tools/showmail.py"
paul@800 8
STORE=/tmp/store
paul@800 9
STATIC=/tmp/static
paul@800 10
PREFS=/tmp/prefs
paul@800 11
ARGS="-S $STORE -P $STATIC -p $PREFS -d"
paul@800 12
USER="mailto:vincent.vole@example.com"
paul@800 13
SENDER="mailto:paul.boddie@example.com"
paul@800 14
FBFILE="$STORE/$USER/freebusy"
paul@800 15
FBOFFERFILE="$STORE/$USER/freebusy-offers"
paul@800 16
FBSENDERFILE="$STORE/$SENDER/freebusy"
paul@800 17
FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER"
paul@800 18
FBSENDERREQUESTS="$STORE/$SENDER/requests"
paul@800 19
TAB=`printf '\t'`
paul@800 20
paul@800 21
OUTGOING_SCRIPT="$THIS_DIR/../imip_person_outgoing.py"
paul@800 22
paul@800 23
PYTHONPATH="$THIS_DIR/.."
paul@800 24
export PYTHONPATH
paul@800 25
paul@800 26
ACCEPT_SCRIPT="$THIS_DIR/test_handle.py"
paul@800 27
ACCEPT_ARGS="accept $STORE"
paul@800 28
paul@800 29
COUNTER_SCRIPT="$THIS_DIR/test_handle.py"
paul@800 30
COUNTER_ARGS="counter $STORE"
paul@800 31
paul@800 32
DECLINE_SCRIPT="$THIS_DIR/test_handle.py"
paul@800 33
DECLINE_ARGS="decline $STORE"
paul@800 34
paul@800 35
ERROR=err.tmp
paul@800 36
paul@800 37
rm -r $STORE
paul@800 38
rm -r $STATIC
paul@800 39
rm -r $PREFS
paul@800 40
rm $ERROR
paul@800 41
rm out*.tmp
paul@800 42
paul@800 43
mkdir -p "$PREFS/$USER"
paul@800 44
echo 'Europe/Oslo' > "$PREFS/$USER/TZID"
paul@800 45
echo 'share' > "$PREFS/$USER/freebusy_sharing"
paul@800 46
echo 'PT60S' > "$PREFS/$USER/freebusy_offers"
paul@800 47
paul@800 48
  "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \
paul@800 49
| "$SHOWMAIL" \
paul@800 50
> out0.tmp
paul@800 51
paul@800 52
   grep -q 'METHOD:REPLY' out0.tmp \
paul@800 53
&& ! grep -q '^FREEBUSY' out0.tmp \
paul@800 54
&& echo "Success" \
paul@800 55
|| echo "Failed"
paul@800 56
paul@800 57
# Attempt to schedule an event.
paul@800 58
paul@800 59
"$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person.txt" 2>> $ERROR
paul@800 60
paul@800 61
   grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE" \
paul@800 62
&& echo "Success" \
paul@800 63
|| echo "Failed"
paul@800 64
paul@800 65
# Present the request to the recipient.
paul@800 66
paul@800 67
  "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person.txt" 2>> $ERROR \
paul@800 68
| "$SHOWMAIL" \
paul@800 69
> out1.tmp
paul@800 70
paul@800 71
   ! grep -q 'METHOD:REPLY' out1.tmp \
paul@800 72
&& echo "Success" \
paul@800 73
|| echo "Failed"
paul@800 74
paul@800 75
   ! [ -e "$FBFILE" ] \
paul@800 76
|| ! grep -q "event6@example.com" "$FBFILE" \
paul@800 77
&& echo "Success" \
paul@800 78
|| echo "Failed"
paul@800 79
paul@800 80
   ! [ -e "$FBOTHERFILE" ] \
paul@800 81
|| ! grep -q "event6@example.com" "$FBOTHERFILE" \
paul@800 82
&& echo "Success" \
paul@800 83
|| echo "Failed"
paul@800 84
paul@800 85
# Counter the invitation.
paul@800 86
paul@800 87
  "$COUNTER_SCRIPT" $COUNTER_ARGS "$USER" 20141126T170000 20141126T180000 "event6@example.com" 2>> $ERROR \
paul@800 88
| tee out2r.tmp \
paul@800 89
| "$SHOWMAIL" \
paul@800 90
> out2.tmp
paul@800 91
paul@800 92
# Note that the invitation has only been prepared, not processed.
paul@800 93
paul@800 94
   ! [ -e "$FBFILE" ] \
paul@800 95
|| ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \
paul@800 96
  && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBFILE" ) \
paul@800 97
&& echo "Success" \
paul@800 98
|| echo "Failed"
paul@800 99
paul@800 100
   grep -q 'METHOD:COUNTER' out2.tmp \
paul@800 101
&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' out2.tmp \
paul@800 102
&& echo "Success" \
paul@800 103
|| echo "Failed"
paul@800 104
paul@800 105
   ! [ -e "$FBOFFERFILE" ] \
paul@800 106
|| ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBOFFERFILE" \
paul@800 107
&& echo "Success" \
paul@800 108
|| echo "Failed"
paul@800 109
paul@800 110
# Send the counter-proposal.
paul@800 111
paul@800 112
"$OUTGOING_SCRIPT" $ARGS < out2r.tmp 2>> $ERROR
paul@800 113
paul@800 114
   ! [ -e "$FBFILE" ] \
paul@800 115
|| ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \
paul@800 116
  && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBFILE" ) \
paul@800 117
&& echo "Success" \
paul@800 118
|| echo "Failed"
paul@800 119
paul@800 120
   grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBOFFERFILE" \
paul@800 121
&& echo "Success" \
paul@800 122
|| echo "Failed"
paul@804 123
paul@804 124
# Present the response to the organiser.
paul@804 125
paul@804 126
  "$PERSON_SCRIPT" $ARGS < out2r.tmp 2>> $ERROR \
paul@804 127
| tee out3r.tmp \
paul@804 128
| "$SHOWMAIL" \
paul@804 129
> out3.tmp
paul@804 130
paul@804 131
   ! [ -e "$FBSENDEROTHERFILE" ] \
paul@804 132
|| ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDEROTHERFILE" \
paul@804 133
  && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBSENDEROTHERFILE" ) \
paul@804 134
&& echo "Success" \
paul@804 135
|| echo "Failed"
paul@804 136
paul@804 137
   grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' "$STORE/$SENDER/objects/event6@example.com" \
paul@804 138
&& grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T160000' "$STORE/$SENDER/objects/event6@example.com" \
paul@804 139
&& echo "Success" \
paul@804 140
|| echo "Failed"
paul@804 141
paul@804 142
   grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T170000' "$STORE/$SENDER/counters/objects/event6@example.com/$USER" \
paul@804 143
&& echo "Success" \
paul@804 144
|| echo "Failed"
paul@804 145
paul@804 146
   grep -q 'event6@example.com' "$FBSENDERREQUESTS" \
paul@804 147
&& echo "Success" \
paul@804 148
|| echo "Failed"
paul@804 149
paul@804 150
# Check the free/busy state of the recipient so far.
paul@804 151
paul@804 152
  "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \
paul@804 153
| "$SHOWMAIL" \
paul@804 154
> out4.tmp
paul@804 155
paul@804 156
   grep -q 'METHOD:REPLY' out4.tmp \
paul@804 157
&& ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T150000Z/20141126T160000Z' out4.tmp \
paul@804 158
&& ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T160000Z/20141126T170000Z' out4.tmp \
paul@804 159
&& echo "Success" \
paul@804 160
|| echo "Failed"
paul@804 161
paul@804 162
# Decline the counter-proposal.
paul@804 163
paul@804 164
  sed 's/COUNTER/DECLINECOUNTER/' < out2.tmp \
paul@804 165
| sed 's/^From: calendar/To: vincent.vole/' \
paul@804 166
| sed 's/^To: paul.boddie/From: paul.boddie/' \
paul@804 167
> out5.tmp
paul@804 168
paul@804 169
"$OUTGOING_SCRIPT" $ARGS < out5.tmp 2>> $ERROR
paul@804 170
paul@804 171
   ! [ -e "$STORE/$SENDER/counters/objects/event6@example.com/$USER" ] \
paul@804 172
&& echo "Success" \
paul@804 173
|| echo "Failed"
paul@804 174
paul@804 175
   ! grep -q 'event6@example.com' "$FBSENDERREQUESTS" \
paul@804 176
&& echo "Success" \
paul@804 177
|| echo "Failed"
paul@804 178
paul@804 179
  "$PERSON_SCRIPT" $ARGS < out5.tmp 2>> $ERROR \
paul@804 180
| "$SHOWMAIL" \
paul@804 181
> out6.tmp
paul@804 182
paul@804 183
   ! [ -e "$FBFILE" ] \
paul@804 184
|| ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \
paul@804 185
  && ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBFILE" ) \
paul@804 186
&& echo "Success" \
paul@804 187
|| echo "Failed"
paul@804 188
paul@804 189
   ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBOFFERFILE" \
paul@804 190
&& ! grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBOFFERFILE" \
paul@804 191
&& echo "Success" \
paul@804 192
|| echo "Failed"