imip-agent

tests/test_person_invitation_counter.sh

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