imip-agent

tests/test_resource_invitation_constraints.sh

789:c90e7281106d
2015-09-29 Paul Boddie Added missing escaping for text within elements.
     1 #!/bin/sh     2      3 THIS_DIR=`dirname $0`     4      5 TEMPLATES="$THIS_DIR/templates"     6 PERSON_SCRIPT="$THIS_DIR/../imip_person.py"     7 RESOURCE_SCRIPT="$THIS_DIR/../imip_resource.py"     8 SHOWMAIL="$THIS_DIR/../tools/showmail.py"     9 STORE=/tmp/store    10 STATIC=/tmp/static    11 PREFS=/tmp/prefs    12 ARGS="-S $STORE -P $STATIC -p $PREFS -d"    13 USER="mailto:resource-room-sauna@example.com"    14 SENDER="mailto:paul.boddie@example.com"    15 RIVALSENDER="mailto:vincent.vole@example.com"    16 FBFILE="$STORE/$USER/freebusy"    17 FBOFFERFILE="$STORE/$USER/freebusy-offers"    18 FBSENDERFILE="$STORE/$SENDER/freebusy"    19 FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER"    20 FBSENDERREQUESTS="$STORE/$SENDER/requests"    21 FBRIVALSENDERFILE="$STORE/$RIVALSENDER/freebusy"    22 TAB=`printf '\t'`    23     24 OUTGOING_SCRIPT="$THIS_DIR/../imip_person_outgoing.py"    25     26 ERROR=err.tmp    27     28 rm -r $STORE    29 rm -r $STATIC    30 rm -r $PREFS    31 rm $ERROR    32 rm out*.tmp    33     34 mkdir -p "$PREFS/$USER"    35 echo 'Europe/Oslo' > "$PREFS/$USER/TZID"    36 echo 'share' > "$PREFS/$USER/freebusy_sharing"    37 echo '10,12,14,16,18:0,15,30,45' > "$PREFS/$USER/permitted_times"    38 echo 'PT60S' > "$PREFS/$USER/freebusy_offers"    39     40   "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \    41 | "$SHOWMAIL" \    42 > out0.tmp    43     44    grep -q 'METHOD:REPLY' out0.tmp \    45 && ! grep -q '^FREEBUSY' out0.tmp \    46 && echo "Success" \    47 || echo "Failed"    48     49 # Attempt to schedule an event.    50     51 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-bad.txt" 2>> $ERROR    52     53    grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \    54 && echo "Success" \    55 || echo "Failed"    56     57 # Present the request to the resource.    58     59   "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-bad.txt" 2>> $ERROR \    60 | "$SHOWMAIL" \    61 > out1.tmp    62     63    grep -q 'METHOD:COUNTER' out1.tmp \    64 && grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161500' out1.tmp \    65 && echo "Success" \    66 || echo "Failed"    67     68    ! [ -e "$FBFILE" ] \    69 || ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBFILE" \    70 && echo "Success" \    71 || echo "Failed"    72     73    grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBOFFERFILE" \    74 && echo "Success" \    75 || echo "Failed"    76     77 # Present the response to the organiser.    78     79   "$PERSON_SCRIPT" $ARGS < out1.tmp 2>> $ERROR \    80 | tee out2r.tmp \    81 | "$SHOWMAIL" \    82 > out2.tmp    83     84    ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDEROTHERFILE" \    85 && echo "Success" \    86 || echo "Failed"    87     88    grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' "$STORE/$SENDER/objects/event13@example.com" \    89 && grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161000' "$STORE/$SENDER/objects/event13@example.com" \    90 && echo "Success" \    91 || echo "Failed"    92     93    grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161500' "$STORE/$SENDER/counters/objects/event13@example.com/$USER" \    94 && echo "Success" \    95 || echo "Failed"    96     97    grep -q 'event13@example.com' "$FBSENDERREQUESTS" \    98 && echo "Success" \    99 || echo "Failed"   100    101 # Attempt to schedule an event in the proposed period.   102    103 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-rival.txt" 2>> $ERROR   104    105    ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \   106 && grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \   107 && echo "Success" \   108 || echo "Failed"   109    110 # Present the request to the resource.   111    112   "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-rival.txt" 2>> $ERROR \   113 | "$SHOWMAIL" \   114 > out3.tmp   115    116    grep -q 'METHOD:REPLY' out3.tmp \   117 && grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' out3.tmp \   118 && echo "Success" \   119 || echo "Failed"   120    121 # Present the response to the organiser.   122    123   "$PERSON_SCRIPT" $ARGS < out3.tmp 2>> $ERROR \   124 | tee out4r.tmp \   125 | "$SHOWMAIL" \   126 > out4.tmp   127    128    ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \   129 && grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \   130 && echo "Success" \   131 || echo "Failed"   132    133    grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' "$STORE/$RIVALSENDER/objects/event18@example.com" \   134 && echo "Success" \   135 || echo "Failed"   136    137 # Check the free/busy state of the resource so far.   138    139   "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \   140 | "$SHOWMAIL" \   141 > out5.tmp   142    143    grep -q 'METHOD:REPLY' out5.tmp \   144 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151000Z/20141126T154500Z' out5.tmp \   145 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151500Z/20141126T154500Z' out5.tmp \   146 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T153000Z/20141126T154500Z' out5.tmp \   147 && echo "Success" \   148 || echo "Failed"   149    150 # Attempt to schedule again in response to the counter-proposal.   151    152 "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR   153    154    ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \   155 && ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBSENDERFILE" \   156 && ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \   157 && echo "Success" \   158 || echo "Failed"   159    160    [ ! -e "$STORE/$SENDER/counters/objects/event13@example.com/$USER" ] \   161 && echo "Success" \   162 || echo "Failed"   163    164    ! grep -q 'event13@example.com' "$FBSENDERREQUESTS" \   165 && echo "Success" \   166 || echo "Failed"   167    168 # Present the request to the resource.   169    170   "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR \   171 | "$SHOWMAIL" \   172 > out6.tmp   173    174    grep -q 'METHOD:REPLY' out6.tmp \   175 && grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out6.tmp \   176 && echo "Success" \   177 || echo "Failed"   178    179    grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBFILE" \   180 && echo "Success" \   181 || echo "Failed"   182    183    ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \   184 && ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBOFFERFILE" \   185 && ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \   186 && echo "Success" \   187 || echo "Failed"   188    189 # Present the response to the organiser.   190    191   "$PERSON_SCRIPT" $ARGS < out6.tmp 2>> $ERROR \   192 | tee out7r.tmp \   193 | "$SHOWMAIL" \   194 > out7.tmp   195    196    grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \   197 && ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \   198 && ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBSENDERFILE" \   199 && ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \   200 && echo "Success" \   201 || echo "Failed"   202    203    [ ! -e "$STORE/$SENDER/counters/objects/event13@example.com/$USER" ] \   204 && echo "Success" \   205 || echo "Failed"   206    207    ! grep -q 'event13@example.com' "$FBSENDERREQUESTS" \   208 && echo "Success" \   209 || echo "Failed"   210    211 # Check the free/busy state of the resource again.   212    213   "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \   214 | "$SHOWMAIL" \   215 > out6.tmp   216    217    grep -q 'METHOD:REPLY' out6.tmp \   218 && grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T150000Z/20141126T154500Z' out6.tmp \   219 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151000Z/20141126T154500Z' out6.tmp \   220 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T151500Z/20141126T154500Z' out6.tmp \   221 && ! grep -q 'FREEBUSY;FBTYPE=BUSY:20141126T153000Z/20141126T154500Z' out6.tmp \   222 && echo "Success" \   223 || echo "Failed"