1 #!/bin/sh 2 3 . "`dirname \"$0\"`/common.sh" 4 5 USER="mailto:resource-room-sauna@example.com" 6 SENDER="mailto:paul.boddie@example.com" 7 RIVALSENDER="mailto:vincent.vole@example.com" 8 FBFILE="$STORE/$USER/freebusy" 9 FBOFFERFILE="$STORE/$USER/freebusy-offers" 10 FBSENDERFILE="$STORE/$SENDER/freebusy" 11 FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER" 12 FBSENDERREQUESTS="$STORE/$SENDER/requests" 13 FBRIVALSENDERFILE="$STORE/$RIVALSENDER/freebusy" 14 15 mkdir -p "$PREFS/$USER" 16 echo 'Europe/Oslo' > "$PREFS/$USER/TZID" 17 echo 'share' > "$PREFS/$USER/freebusy_sharing" 18 echo 'schedule_corrected_in_freebusy' > "$PREFS/$USER/scheduling_function" 19 echo '10,12,14,16,18:0,15,30,45' > "$PREFS/$USER/permitted_times" 20 echo 'PT60S' > "$PREFS/$USER/freebusy_offers" 21 22 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \ 23 | "$SHOWMAIL" \ 24 > out0.tmp 25 26 grep -q 'METHOD:REPLY' out0.tmp \ 27 && ! grep -q '^FREEBUSY' out0.tmp \ 28 && echo "Success" \ 29 || echo "Failed" 30 31 # Attempt to schedule an event. 32 33 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-bad.txt" 2>> $ERROR 34 35 grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ 36 && echo "Success" \ 37 || echo "Failed" 38 39 # Present the request to the resource. 40 41 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-bad.txt" 2>> $ERROR \ 42 | "$SHOWMAIL" \ 43 > out1.tmp 44 45 grep -q 'METHOD:COUNTER' out1.tmp \ 46 && grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161500' out1.tmp \ 47 && echo "Success" \ 48 || echo "Failed" 49 50 ! [ -e "$FBFILE" ] \ 51 || ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBFILE" \ 52 && echo "Success" \ 53 || echo "Failed" 54 55 grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ 56 && echo "Success" \ 57 || echo "Failed" 58 59 # Present the response to the organiser. 60 61 "$PERSON_SCRIPT" $ARGS < out1.tmp 2>> $ERROR \ 62 | tee out2r.tmp \ 63 | "$SHOWMAIL" \ 64 > out2.tmp 65 66 [ ! -e "$FBSENDEROTHERFILE" ] \ 67 || ( ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDEROTHERFILE" \ 68 && ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBSENDEROTHERFILE" ) \ 69 && echo "Success" \ 70 || echo "Failed" 71 72 grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161000' "$STORE/$SENDER/objects/event13@example.com" \ 73 && echo "Success" \ 74 || echo "Failed" 75 76 grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161500' "$STORE/$SENDER/counters/objects/event13@example.com/$USER" \ 77 && echo "Success" \ 78 || echo "Failed" 79 80 grep -q 'event13@example.com' "$FBSENDERREQUESTS" \ 81 && echo "Success" \ 82 || echo "Failed" 83 84 # Decline the counter-proposal. 85 86 sed 's/COUNTER/DECLINECOUNTER/' < out1.tmp \ 87 | sed 's/^From: calendar/To: resource-room-sauna/' \ 88 | sed 's/^To: paul.boddie/From: paul.boddie/' \ 89 > out3.tmp 90 91 "$OUTGOING_SCRIPT" $ARGS < out3.tmp 2>> $ERROR 92 93 "$RESOURCE_SCRIPT" $ARGS < out3.tmp 2>> $ERROR \ 94 | "$SHOWMAIL" \ 95 > out4.tmp 96 97 ! [ -e "$FBFILE" ] \ 98 || ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBFILE" \ 99 && echo "Success" \ 100 || echo "Failed" 101 102 ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ 103 && echo "Success" \ 104 || echo "Failed" 105 106 # Attempt to schedule an event in the proposed period. 107 108 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-rival.txt" 2>> $ERROR 109 110 ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ 111 && grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ 112 && echo "Success" \ 113 || echo "Failed" 114 115 # Present the request to the resource. 116 117 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-rival.txt" 2>> $ERROR \ 118 | "$SHOWMAIL" \ 119 > out5.tmp 120 121 grep -q 'METHOD:REPLY' out5.tmp \ 122 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out5.tmp \ 123 && echo "Success" \ 124 || echo "Failed" 125 126 grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBFILE" \ 127 && echo "Success" \ 128 || echo "Failed" 129 130 ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ 131 && echo "Success" \ 132 || echo "Failed" 133 134 # Present the response to the organiser. 135 136 "$PERSON_SCRIPT" $ARGS < out5.tmp 2>> $ERROR \ 137 | "$SHOWMAIL" \ 138 > out6.tmp 139 140 ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ 141 && ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ 142 && grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ 143 && echo "Success" \ 144 || echo "Failed" 145 146 grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' "$STORE/$RIVALSENDER/objects/event18@example.com" \ 147 && echo "Success" \ 148 || echo "Failed" 149 150 # Check the free/busy state of the resource so far. 151 152 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \ 153 | "$SHOWMAIL" \ 154 > out7.tmp 155 156 grep -q 'METHOD:REPLY' out7.tmp \ 157 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151000Z/20141126T154500Z' out7.tmp \ 158 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151500Z/20141126T154500Z' out7.tmp \ 159 && grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T153000Z/20141126T154500Z' out7.tmp \ 160 && echo "Success" \ 161 || echo "Failed"