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 OUTSIDESENDER="mailto:paul.boddie@example.net" 8 FBFILE="$STORE/$USER/freebusy" 9 FBSENDERFILE="$STORE/$SENDER/freebusy" 10 FBOUTSIDESENDERFILE="$STORE/$OUTSIDESENDER/freebusy" 11 12 mkdir -p "$PREFS/$USER" 13 echo 'Europe/Oslo' > "$PREFS/$USER/TZID" 14 echo 'share' > "$PREFS/$USER/freebusy_sharing" 15 cat > "$PREFS/$USER/scheduling_function" <<EOF 16 schedule_in_freebusy 17 same_domain_only 18 EOF 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-outsider.txt" 2>> $ERROR 34 35 grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOUTSIDESENDERFILE" \ 36 && echo "Success" \ 37 || echo "Failed" 38 39 # Present the request to the resource. 40 41 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-outsider.txt" 2>> $ERROR \ 42 | tee out1r.tmp \ 43 | "$SHOWMAIL" \ 44 > out1.tmp 45 46 grep -q 'METHOD:REPLY' out1.tmp \ 47 && grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out1.tmp \ 48 && echo "Success" \ 49 || echo "Failed" 50 51 ! [ -e "$FBFILE" ] \ 52 || ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBFILE" \ 53 && echo "Success" \ 54 || echo "Failed" 55 56 # Relax the scheduling function. 57 58 cat > "$PREFS/$USER/scheduling_function" <<EOF 59 schedule_in_freebusy 60 EOF 61 62 # Present the request to the resource. 63 64 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-outsider.txt" 2>> $ERROR \ 65 | tee out2r.tmp \ 66 | "$SHOWMAIL" \ 67 > out2.tmp 68 69 grep -q 'METHOD:REPLY' out2.tmp \ 70 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out2.tmp \ 71 && echo "Success" \ 72 || echo "Failed" 73 74 [ -e "$FBFILE" ] \ 75 && grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBFILE" \ 76 && echo "Success" \ 77 || echo "Failed" 78 79 # Check the free/busy state of the resource again. 80 81 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \ 82 | "$SHOWMAIL" \ 83 > out3.tmp 84 85 grep -q 'METHOD:REPLY' out3.tmp \ 86 && grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T150000Z/20141126T154500Z' out3.tmp \ 87 && echo "Success" \ 88 || echo "Failed" 89 90 # Try a different scheduling function. 91 92 ACL="$PWD/acl.tmp" 93 94 cat > "$PREFS/$USER/scheduling_function" <<EOF 95 schedule_in_freebusy 96 access_control_list "$ACL" 97 EOF 98 99 # Try without an ACL. 100 101 cat > "$ACL" <<EOF 102 EOF 103 104 # Attempt to schedule an event. 105 106 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-acl.txt" 2>> $ERROR 107 108 grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBSENDERFILE" \ 109 && echo "Success" \ 110 || echo "Failed" 111 112 # Present the request to the resource. 113 114 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-acl.txt" 2>> $ERROR \ 115 | tee out4r.tmp \ 116 | "$SHOWMAIL" \ 117 > out4.tmp 118 119 grep -q 'METHOD:REPLY' out4.tmp \ 120 && grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out4.tmp \ 121 && echo "Success" \ 122 || echo "Failed" 123 124 ! [ -e "$FBFILE" ] \ 125 || ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBFILE" \ 126 && echo "Success" \ 127 || echo "Failed" 128 129 # Try with an unreasonable ACL. 130 131 cat > "$ACL" <<EOF 132 decline 133 EOF 134 135 # Attempt to schedule an event. 136 137 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-acl.txt" 2>> $ERROR 138 139 grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBSENDERFILE" \ 140 && echo "Success" \ 141 || echo "Failed" 142 143 # Present the request to the resource. 144 145 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-acl.txt" 2>> $ERROR \ 146 | tee out5r.tmp \ 147 | "$SHOWMAIL" \ 148 > out5.tmp 149 150 grep -q 'METHOD:REPLY' out5.tmp \ 151 && grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out5.tmp \ 152 && echo "Success" \ 153 || echo "Failed" 154 155 ! [ -e "$FBFILE" ] \ 156 || ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBFILE" \ 157 && echo "Success" \ 158 || echo "Failed" 159 160 # Try with a reasonable ACL. 161 162 cat > "$ACL" <<EOF 163 accept 164 decline attendee simon.skunk@example.com 165 EOF 166 167 # Attempt to schedule an event. 168 169 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-acl.txt" 2>> $ERROR 170 171 grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBSENDERFILE" \ 172 && echo "Success" \ 173 || echo "Failed" 174 175 # Present the request to the resource. 176 177 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-acl.txt" 2>> $ERROR \ 178 | tee out6r.tmp \ 179 | "$SHOWMAIL" \ 180 > out6.tmp 181 182 grep -q 'METHOD:REPLY' out6.tmp \ 183 && grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out6.tmp \ 184 && echo "Success" \ 185 || echo "Failed" 186 187 ! [ -e "$FBFILE" ] \ 188 || ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBFILE" \ 189 && echo "Success" \ 190 || echo "Failed" 191 192 # Modify the ACL, using the implicit preference setting to hold the list. 193 194 cat > "$PREFS/$USER/scheduling_function" <<EOF 195 schedule_in_freebusy 196 access_control_list 197 EOF 198 199 cat > "$PREFS/$USER/acl" <<EOF 200 accept 201 decline attendee simon.skunk@example.com 202 accept organiser mailto:paul.boddie@example.com 203 EOF 204 205 # Present the request to the resource. 206 207 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-acl.txt" 2>> $ERROR \ 208 | tee out7r.tmp \ 209 | "$SHOWMAIL" \ 210 > out7.tmp 211 212 grep -q 'METHOD:REPLY' out7.tmp \ 213 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out7.tmp \ 214 && echo "Success" \ 215 || echo "Failed" 216 217 ! [ -e "$FBFILE" ] \ 218 || grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBFILE" \ 219 && echo "Success" \ 220 || echo "Failed" 221 222 rm "$ACL"