paul@734 | 1 | #!/bin/sh |
paul@734 | 2 | |
paul@734 | 3 | THIS_DIR=`dirname $0` |
paul@734 | 4 | |
paul@734 | 5 | TEMPLATES="$THIS_DIR/templates" |
paul@734 | 6 | PERSON_SCRIPT="$THIS_DIR/../imip_person.py" |
paul@734 | 7 | SHOWMAIL="$THIS_DIR/../tools/showmail.py" |
paul@734 | 8 | STORE=/tmp/store |
paul@734 | 9 | STATIC=/tmp/static |
paul@734 | 10 | PREFS=/tmp/prefs |
paul@734 | 11 | ARGS="-S $STORE -P $STATIC -p $PREFS -d" |
paul@734 | 12 | USER="mailto:vincent.vole@example.com" |
paul@734 | 13 | SENDER="mailto:paul.boddie@example.com" |
paul@734 | 14 | FBFILE="$STORE/$USER/freebusy" |
paul@734 | 15 | FBOTHERFILE="$STORE/$USER/freebusy-other/$SENDER" |
paul@734 | 16 | FBSENDERFILE="$STORE/$SENDER/freebusy" |
paul@734 | 17 | FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER" |
paul@734 | 18 | TAB=`printf '\t'` |
paul@734 | 19 | |
paul@734 | 20 | OUTGOING_SCRIPT="$THIS_DIR/../imip_person_outgoing.py" |
paul@734 | 21 | |
paul@734 | 22 | PYTHONPATH="$THIS_DIR/.." |
paul@734 | 23 | export PYTHONPATH |
paul@734 | 24 | |
paul@734 | 25 | ACCEPT_SCRIPT="$THIS_DIR/test_handle.py" |
paul@734 | 26 | ACCEPT_ARGS="accept $STORE" |
paul@734 | 27 | |
paul@734 | 28 | DECLINE_SCRIPT="$THIS_DIR/test_handle.py" |
paul@734 | 29 | DECLINE_ARGS="decline $STORE" |
paul@734 | 30 | |
paul@734 | 31 | ERROR=err.tmp |
paul@734 | 32 | |
paul@734 | 33 | rm -r $STORE |
paul@734 | 34 | rm -r $STATIC |
paul@734 | 35 | rm -r $PREFS |
paul@734 | 36 | rm $ERROR |
paul@734 | 37 | rm out*.tmp |
paul@734 | 38 | |
paul@734 | 39 | mkdir -p "$PREFS/$USER" |
paul@734 | 40 | echo 'Europe/Oslo' > "$PREFS/$USER/TZID" |
paul@734 | 41 | echo 'share' > "$PREFS/$USER/freebusy_sharing" |
paul@734 | 42 | |
paul@734 | 43 | mkdir -p "$PREFS/$SENDER" |
paul@734 | 44 | echo 'Europe/Oslo' > "$PREFS/$USER/TZID" |
paul@734 | 45 | echo 'always' > "$PREFS/$SENDER/event_refreshing" |
paul@734 | 46 | |
paul@734 | 47 | # Test event request registration in the outgoing handler. |
paul@734 | 48 | |
paul@734 | 49 | "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring.txt" 2>> $ERROR |
paul@734 | 50 | |
paul@734 | 51 | grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBSENDERFILE" \ |
paul@734 | 52 | && echo "Success" \ |
paul@734 | 53 | || echo "Failed" |
paul@734 | 54 | |
paul@734 | 55 | # Present the request to the recipient. |
paul@734 | 56 | |
paul@734 | 57 | "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person-recurring.txt" 2>> $ERROR \ |
paul@734 | 58 | | "$SHOWMAIL" \ |
paul@734 | 59 | > out2.tmp |
paul@734 | 60 | |
paul@734 | 61 | ! grep -q 'METHOD:REPLY' out2.tmp \ |
paul@734 | 62 | && echo "Success" \ |
paul@734 | 63 | || echo "Failed" |
paul@734 | 64 | |
paul@734 | 65 | ! [ -e "$FBFILE" ] \ |
paul@734 | 66 | || ! grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \ |
paul@734 | 67 | && echo "Success" \ |
paul@734 | 68 | || echo "Failed" |
paul@734 | 69 | |
paul@734 | 70 | grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBOTHERFILE" \ |
paul@734 | 71 | && echo "Success" \ |
paul@734 | 72 | || echo "Failed" |
paul@734 | 73 | |
paul@734 | 74 | # Test acceptance and registration in the outgoing handler. |
paul@734 | 75 | |
paul@734 | 76 | "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" 2>> $ERROR \ |
paul@734 | 77 | | tee out3.tmp \ |
paul@734 | 78 | | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR |
paul@734 | 79 | |
paul@734 | 80 | "$SHOWMAIL" < out3.tmp | grep -q 'METHOD:REPLY' \ |
paul@734 | 81 | && echo "Success" \ |
paul@734 | 82 | || echo "Failed" |
paul@734 | 83 | |
paul@734 | 84 | grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \ |
paul@734 | 85 | && echo "Success" \ |
paul@734 | 86 | || echo "Failed" |
paul@734 | 87 | |
paul@734 | 88 | # Present the result to the recipient. |
paul@734 | 89 | |
paul@734 | 90 | "$PERSON_SCRIPT" $ARGS < out3.tmp 2>> $ERROR \ |
paul@734 | 91 | | "$SHOWMAIL" \ |
paul@734 | 92 | > out4.tmp |
paul@734 | 93 | |
paul@734 | 94 | grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBSENDEROTHERFILE" \ |
paul@734 | 95 | && echo "Success" \ |
paul@734 | 96 | || echo "Failed" |
paul@734 | 97 | |
paul@734 | 98 | # Attempt to add an occurrence to the event. |
paul@734 | 99 | |
paul@735 | 100 | "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-add-person-recurring.txt" 2>> $ERROR |
paul@734 | 101 | |
paul@734 | 102 | grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBSENDERFILE" \ |
paul@734 | 103 | && grep -q "^20150109T090000Z${TAB}20150109T100000Z" "$FBSENDERFILE" \ |
paul@734 | 104 | && echo "Success" \ |
paul@734 | 105 | || echo "Failed" |
paul@734 | 106 | |
paul@734 | 107 | # Present the request to the recipient. |
paul@734 | 108 | |
paul@735 | 109 | "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-add-person-recurring.txt" 2>> $ERROR \ |
paul@734 | 110 | | "$SHOWMAIL" \ |
paul@734 | 111 | > out5.tmp |
paul@734 | 112 | |
paul@734 | 113 | grep -q 'METHOD:REFRESH' out5.tmp \ |
paul@734 | 114 | && echo "Success" \ |
paul@734 | 115 | || echo "Failed" |
paul@734 | 116 | |
paul@734 | 117 | grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \ |
paul@734 | 118 | && ! grep -q "^20150109T090000Z${TAB}20150109T100000Z" "$FBFILE" \ |
paul@734 | 119 | && echo "Success" \ |
paul@734 | 120 | || echo "Failed" |
paul@734 | 121 | |
paul@734 | 122 | grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBOTHERFILE" \ |
paul@866 | 123 | && ! grep -q "^20150109T090000Z${TAB}20150109T100000Z" "$FBOTHERFILE" \ |
paul@734 | 124 | && echo "Success" \ |
paul@734 | 125 | || echo "Failed" |
paul@734 | 126 | |
paul@734 | 127 | # Present the refresh message to the organiser. |
paul@734 | 128 | |
paul@734 | 129 | "$PERSON_SCRIPT" $ARGS < out5.tmp 2>> $ERROR \ |
paul@866 | 130 | | tee out6r.tmp \ |
paul@734 | 131 | | "$SHOWMAIL" \ |
paul@734 | 132 | > out6.tmp |
paul@734 | 133 | |
paul@734 | 134 | grep -q 'METHOD:REQUEST' out6.tmp \ |
paul@734 | 135 | && echo "Success" \ |
paul@734 | 136 | || echo "Failed" |
paul@734 | 137 | |
paul@734 | 138 | # Present the request to the recipient. |
paul@734 | 139 | |
paul@866 | 140 | "$PERSON_SCRIPT" $ARGS < out6r.tmp 2>> $ERROR \ |
paul@734 | 141 | | "$SHOWMAIL" \ |
paul@734 | 142 | > out7.tmp |
paul@734 | 143 | |
paul@734 | 144 | ! grep -q 'METHOD:REPLY' out7.tmp \ |
paul@734 | 145 | && echo "Success" \ |
paul@734 | 146 | || echo "Failed" |
paul@734 | 147 | |
paul@734 | 148 | grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \ |
paul@734 | 149 | && ! grep -q "^20150109T090000Z${TAB}20150109T100000Z" "$FBFILE" \ |
paul@734 | 150 | && echo "Success" \ |
paul@734 | 151 | || echo "Failed" |
paul@734 | 152 | |
paul@734 | 153 | grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBOTHERFILE" \ |
paul@734 | 154 | && grep -q "^20150109T090000Z${TAB}20150109T100000Z" "$FBOTHERFILE" \ |
paul@734 | 155 | && echo "Success" \ |
paul@734 | 156 | || echo "Failed" |
paul@734 | 157 | |
paul@734 | 158 | # Test acceptance and registration in the outgoing handler. |
paul@734 | 159 | |
paul@734 | 160 | "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" 2>> $ERROR \ |
paul@734 | 161 | | tee out8.tmp \ |
paul@734 | 162 | | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR |
paul@734 | 163 | |
paul@734 | 164 | "$SHOWMAIL" < out8.tmp | grep -q 'METHOD:REPLY' \ |
paul@734 | 165 | && echo "Success" \ |
paul@734 | 166 | || echo "Failed" |
paul@734 | 167 | |
paul@734 | 168 | "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" "event8@example.com" "20150109T090000Z" 2>> $ERROR \ |
paul@734 | 169 | | tee out9.tmp \ |
paul@734 | 170 | | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR |
paul@734 | 171 | |
paul@734 | 172 | "$SHOWMAIL" < out9.tmp | grep -q 'METHOD:REPLY' \ |
paul@734 | 173 | && echo "Success" \ |
paul@734 | 174 | || echo "Failed" |
paul@734 | 175 | |
paul@734 | 176 | grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \ |
paul@734 | 177 | && grep -q "^20150109T090000Z${TAB}20150109T100000Z" "$FBFILE" \ |
paul@734 | 178 | && echo "Success" \ |
paul@734 | 179 | || echo "Failed" |