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 ! grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \ 75 && echo "Success" \ 76 || echo "Failed" 77 78 grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBOTHERFILE" \ 79 && echo "Success" \ 80 || echo "Failed" 81 82 # Test acceptance and registration in the outgoing handler. 83 84 "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" 2>> $ERROR \ 85 | tee out4.tmp \ 86 | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR 87 88 grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \ 89 && echo "Success" \ 90 || echo "Failed" 91 92 # Test a request from a non-attendee for the event details to be refreshed. 93 94 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-refresh-person-recurring-non-attendee.txt" 2>> $ERROR \ 95 | "$SHOWMAIL" \ 96 > out5.tmp 97 98 ! grep -q 'METHOD:REQUEST' out5.tmp \ 99 && echo "Success" \ 100 || echo "Failed" 101 102 # Test rescheduling in the outgoing handler. 103 104 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring-reschedule-instance.txt" 2>> $ERROR 105 106 grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBSENDERFILE" \ 107 && ! grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBSENDERFILE" \ 108 && echo "Success" \ 109 || echo "Failed" 110 111 # Test another request from an attendee for the event details to be refreshed. 112 113 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-refresh-person-recurring.txt" 2>> $ERROR \ 114 | "$SHOWMAIL" \ 115 > out6.tmp 116 117 grep -q 'METHOD:REQUEST' out6.tmp \ 118 && grep -q 'RECURRENCE-ID' out6.tmp \ 119 && [ `grep 'BEGIN:VEVENT' out6.tmp | wc -l` = '2' ] \ 120 && echo "Success" \ 121 || echo "Failed" 122 123 # Cancel a recurrence. Both the original and rescheduled recurrences should be 124 # absent from the free/busy collection. 125 126 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-person-recurring-rescheduled-instance.txt" 2>> $ERROR 127 128 ! grep -q "^20141010T080000Z${TAB}20141010T090000Z" "$FBSENDERFILE" \ 129 && ! grep -q "^20141011T080000Z${TAB}20141011T090000Z" "$FBSENDERFILE" \ 130 && echo "Success" \ 131 || echo "Failed" 132 133 # Test another request from an attendee for the event details to be refreshed. 134 # The additional recurrence should now be absent. 135 136 "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-refresh-person-recurring.txt" 2>> $ERROR \ 137 | "$SHOWMAIL" \ 138 > out7.tmp 139 140 grep -q 'METHOD:REQUEST' out7.tmp \ 141 && ! grep -q 'RECURRENCE-ID' out7.tmp \ 142 && [ `grep 'BEGIN:VEVENT' out7.tmp | wc -l` = '1' ] \ 143 && echo "Success" \ 144 || echo "Failed"