# HG changeset patch # User Paul Boddie # Date 1444838404 -7200 # Node ID 49e786eda736e8b623f1ca7319db6af04740f4c3 # Parent 6e83b9a9a6099de43fed51ae7bf95500b6d14d56 Handle new attendees trying to invite themselves without permission. diff -r 6e83b9a9a609 -r 49e786eda736 imiptools/client.py --- a/imiptools/client.py Wed Oct 14 14:56:05 2015 +0200 +++ b/imiptools/client.py Wed Oct 14 18:00:04 2015 +0200 @@ -351,9 +351,11 @@ for attendee, attendee_attr in attendees.items(): - # Update attendance in the loaded object. + # Update attendance in the loaded object for any recognised + # attendees. - attendee_map[attendee] = attendee_attr + if attendee_map.has_key(attendee): + attendee_map[attendee] = attendee_attr # Set the new details and store the object. @@ -813,7 +815,16 @@ "For the current user, record free/busy information from 'attendees'." - for attendee in attendees.keys(): + obj = self.get_stored_object_version() + + if not obj or not self.have_new_object(): + return + + # Filter out unrecognised attendees. + + attendees = set(attendees).intersection(uri_values(obj.get_values("ATTENDEE"))) + + for attendee in attendees: self.update_freebusy_from_participant(attendee, False) def remove_freebusy_from_organiser(self, organiser): diff -r 6e83b9a9a609 -r 49e786eda736 tests/templates/event-request-person-imposter-object.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/templates/event-request-person-imposter-object.txt Wed Oct 14 18:00:04 2015 +0200 @@ -0,0 +1,10 @@ +BEGIN:VEVENT +ORGANIZER:mailto:paul.boddie@example.com +ATTENDEE;ROLE=CHAIR:mailto:paul.boddie@example.com +ATTENDEE;RSVP=TRUE:mailto:oliver.otter@example.com +DTSTAMP:20141125T004600Z +DTSTART;TZID=Europe/Oslo:20141126T160000 +DTEND;TZID=Europe/Oslo:20141126T170000 +SUMMARY:Meeting at 4pm +UID:event6@example.com +END:VEVENT diff -r 6e83b9a9a609 -r 49e786eda736 tests/test_person_non_participation.sh --- a/tests/test_person_non_participation.sh Wed Oct 14 14:56:05 2015 +0200 +++ b/tests/test_person_non_participation.sh Wed Oct 14 18:00:04 2015 +0200 @@ -10,9 +10,11 @@ PREFS=/tmp/prefs ARGS="-S $STORE -P $STATIC -p $PREFS -d" USER="mailto:vincent.vole@example.com" +IMPOSTER="mailto:oliver.otter@example.com" SENDER="mailto:paul.boddie@example.com" FBFILE="$STORE/$USER/freebusy" FBOTHERFILE="$STORE/$USER/freebusy-other/$SENDER" +FBIMPOSTERFILE="$STORE/$SENDER/freebusy-other/$IMPOSTER" TAB=`printf '\t'` OUTGOING_SCRIPT="$THIS_DIR/../imip_person_outgoing.py" @@ -37,6 +39,9 @@ mkdir -p "$PREFS/$USER" echo 'no' > "$PREFS/$USER/participating" +mkdir -p "$PREFS/$SENDER" +echo 'yes' > "$PREFS/$SENDER/participating" + "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/fb-request-person-all.txt" 2>> $ERROR \ | "$SHOWMAIL" \ > out0.tmp @@ -45,6 +50,16 @@ && echo "Success" \ || echo "Failed" +# Show the request to the outgoing handler first. + +"$OUTGOING_SCRIPT" < "$TEMPLATES/event-request-person.txt" $ARGS 2>> $ERROR + + [ -e "$STORE/$SENDER/objects/event6@example.com" ] \ +&& echo "Success" \ +|| echo "Failed" + +# Send a request to the recipient. + "$PERSON_SCRIPT" $ARGS < "$TEMPLATES/event-request-person.txt" 2>> $ERROR \ | "$SHOWMAIL" \ > out2.tmp @@ -61,6 +76,8 @@ && echo "Success" \ || echo "Failed" +# Make sure that the recipient ignored it. + "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$USER" < "$TEMPLATES/event-request-person-object.txt" 2>> $ERROR \ | tee out3.tmp \ | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR @@ -69,3 +86,21 @@ || ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ && echo "Success" \ || echo "Failed" + +# Now see if an imposter can invite themself to the event. + + "$ACCEPT_SCRIPT" $ACCEPT_ARGS "$IMPOSTER" < "$TEMPLATES/event-request-person-imposter-object.txt" 2>> $ERROR \ +| tee out4.tmp \ +| "$PERSON_SCRIPT" $ARGS 2>> $ERROR \ +| "$SHOWMAIL" \ +> out5.tmp + + [ -e "$STORE/$SENDER/objects/event6@example.com" ] \ +&& ! grep -q "otter" "$STORE/$SENDER/objects/event6@example.com" \ +&& echo "Success" \ +|| echo "Failed" + + ( ! [ -e "$FBIMPOSTERFILE" ] \ + || ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBIMPOSTERFILE") \ +&& echo "Success" \ +|| echo "Failed"