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 FBOTHERFILE="$STORE/$USER/freebusy-other/$SENDER" 16 FBSENDERFILE="$STORE/$SENDER/freebusy" 17 TAB=`printf '\t'` 18 19 OUTGOING_SCRIPT="$THIS_DIR/../imip_person_outgoing.py" 20 21 PYTHONPATH="$THIS_DIR/.." 22 export PYTHONPATH 23 24 ACCEPT_SCRIPT="$THIS_DIR/test_handle.py" 25 ACCEPT_ARGS="accept $STORE" 26 27 DECLINE_SCRIPT="$THIS_DIR/test_handle.py" 28 DECLINE_ARGS="decline $STORE" 29 30 ERROR=err.tmp 31 32 rm -r $STORE 33 rm -r $STATIC 34 rm -r $PREFS 35 rm $ERROR 36 rm out*.tmp 37 38 mkdir -p "$PREFS/$USER" 39 echo 'Europe/Oslo' > "$PREFS/$USER/TZID" 40 echo 'share' > "$PREFS/$USER/freebusy_sharing" 41 42 mkdir -p "$PREFS/$SENDER" 43 echo 'Europe/Oslo' > "$PREFS/$USER/TZID" 44 echo 'always' > "$PREFS/$SENDER/event_refreshing" 45 46 # Publish an event, testing registration in the outgoing handler. 47 48 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring.txt" 2>> $ERROR 49 50 grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBSENDERFILE" \ 51 && echo "Success" \ 52 || echo "Failed" 53 54 # Test a request from an attendee for the event details to be refreshed. 55 56 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-refresh-person-recurring.txt" 2>> $ERROR \ 57 | "$SHOWMAIL" \ 58 > out2.tmp 59 60 grep -q 'METHOD:REQUEST' out2.tmp \ 61 && echo "Success" \ 62 || echo "Failed" 63 64 # Present the result to the recipient. 65 66 "$PERSON_SCRIPT" $ARGS < out2.tmp 2>> $ERROR \ 67 | "$SHOWMAIL" \ 68 > out3.tmp 69 70 ! grep -q 'METHOD:REPLY' out3.tmp \ 71 && echo "Success" \ 72 || echo "Failed" 73 74 ! [ -e "$FBFILE" ] \ 75 || ! grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \ 76 && echo "Success" \ 77 || echo "Failed" 78 79 grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBOTHERFILE" \ 80 && echo "Success" \ 81 || echo "Failed" 82 83 # Test acceptance and registration in the outgoing handler. 84 85 "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" 2>> $ERROR \ 86 | tee out4.tmp \ 87 | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR 88 89 grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \ 90 && echo "Success" \ 91 || echo "Failed" 92 93 # Test a request from a non-attendee for the event details to be refreshed. 94 95 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-refresh-person-recurring-non-attendee.txt" 2>> $ERROR \ 96 | "$SHOWMAIL" \ 97 > out5.tmp 98 99 ! grep -q 'METHOD:REQUEST' out5.tmp \ 100 && echo "Success" \ 101 || echo "Failed" 102 103 # Test rescheduling in the outgoing handler. 104 105 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring-reschedule-instance.txt" 2>> $ERROR 106 107 grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBSENDERFILE" \ 108 && ! grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBSENDERFILE" \ 109 && echo "Success" \ 110 || echo "Failed" 111 112 # Test another request from an attendee for the event details to be refreshed. 113 114 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-refresh-person-recurring.txt" 2>> $ERROR \ 115 | "$SHOWMAIL" \ 116 > out6.tmp 117 118 grep -q 'METHOD:REQUEST' out6.tmp \ 119 && grep -q 'RECURRENCE-ID' out6.tmp \ 120 && [ `grep 'BEGIN:VEVENT' out6.tmp | wc -l` = '2' ] \ 121 && echo "Success" \ 122 || echo "Failed" 123 124 # Cancel a recurrence. Both the original and rescheduled recurrences should be 125 # absent from the free/busy collection. 126 127 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring-rescheduled-instance.txt" 2>> $ERROR 128 129 ! grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBSENDERFILE" \ 130 && ! grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBSENDERFILE" \ 131 && echo "Success" \ 132 || echo "Failed" 133 134 # Test another request from an attendee for the event details to be refreshed. 135 # The additional recurrence should now be absent. 136 137 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-refresh-person-recurring.txt" 2>> $ERROR \ 138 | "$SHOWMAIL" \ 139 > out7.tmp 140 141 grep -q 'METHOD:REQUEST' out7.tmp \ 142 && ! grep -q 'RECURRENCE-ID' out7.tmp \ 143 && [ `grep 'BEGIN:VEVENT' out7.tmp | wc -l` = '1' ] \ 144 && echo "Success" \ 145 || echo "Failed"