# HG changeset patch # User Paul Boddie # Date 1457656425 -3600 # Node ID 54e1af14f1a2d78ed020a0339dc22b479f309c2f # Parent 31d839d508f6cb303db441fc661b05798fc2f4ed Added support for store/journal-level locking to the PostgreSQL store. Fixed various journal and free/busy provider tables in the database schema. Fixed inappropriate slicing of free/busy providers when retrieving them from the store. Fixed some unparameterised database store queries. Added a store method for setting quota limits along with a tool used by the tests to configure them. Changed the tools to be more aware of different store types and updated the installation script. Added documentation about store types. Converted the remaining tests to work with the database store. Made a minimal common test configuration script so that the resource_request.sh script can use the common configuration without deleting state information. diff -r 31d839d508f6 -r 54e1af14f1a2 conf/postgresql/schema.sql --- a/conf/postgresql/schema.sql Thu Mar 10 01:43:31 2016 +0100 +++ b/conf/postgresql/schema.sql Fri Mar 11 01:33:45 2016 +0100 @@ -81,7 +81,7 @@ create table freebusy_provider_datetimes ( store_user varchar not null, - "start" varchar not null + "start" varchar ); -- Object store request details. @@ -128,12 +128,14 @@ -- Journal user groups and limits. create table quota_limits ( + quota varchar not null, user_group varchar not null, quota_limit varchar not null, primary key(user_group) ); create table user_groups ( + quota varchar not null, store_user varchar not null, user_group varchar not null, primary key(store_user, user_group) diff -r 31d839d508f6 -r 54e1af14f1a2 docs/wiki/DatabaseStore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/wiki/DatabaseStore Fri Mar 11 01:33:45 2016 +0100 @@ -0,0 +1,15 @@ += Database Store = + +The database data store offers a mechanism for storing calendar objects and free/busy +details in a database system, currently focusing on relational database systems, with +specific support for PostgreSQL. + +Benefits of the database store include convenient and standardised interfaces for +querying and inspecting the data, together with various guarantees around the durability +of the stored data. However, more administrative knowledge is usually required to operate +database installations satisfactorily, and activities such as archiving require extra +planning and expertise. + +The [[../FileStore|file store]] offers a more convenient method of managing calendar +data, albeit offering arguably less scalability and less convenience when data volumes +become significantly large. diff -r 31d839d508f6 -r 54e1af14f1a2 docs/wiki/FileStore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/wiki/FileStore Fri Mar 11 01:33:45 2016 +0100 @@ -0,0 +1,15 @@ += File Store = + +The file data store is the default mechanism for storing calendar objects and +free/busy details, making use of various directories as described in the +[[../FilesystemUsage|filesystem usage guide]]. + +Benefits of the file store include transparency and ease of administration: +all data is stored in text files, direct modification of certain files can be +performed to change the system's behaviour, archiving is possible using +traditional filesystem tools. However, the simple representation may make +certain operations costly, such as the modification of tabular data, and +querying of data may not always be particularly convenient. + +Thus, the [[../DatabaseStore|database store]] exists as an alternative, offering +different characteristics to those of the file store. diff -r 31d839d508f6 -r 54e1af14f1a2 docs/wiki/FilesystemUsage --- a/docs/wiki/FilesystemUsage Thu Mar 10 01:43:31 2016 +0100 +++ b/docs/wiki/FilesystemUsage Fri Mar 11 01:33:45 2016 +0100 @@ -26,6 +26,11 @@ Note that the free/busy resources are located in `/var/www` as opposed to `/var/lib` since they are intended to be published on the Web. +Meanwhile, the journal and store resources are only present in the filesystem +if the [[../FileStore|file store]] is in use. Where a +[[../DatabaseStore|database store]] is being used instead, such resources are +located in a database system. + == Journal Structure == Within the journal directory are a collection of subdirectories, each of which diff -r 31d839d508f6 -r 54e1af14f1a2 docs/wiki/GettingStarted --- a/docs/wiki/GettingStarted Thu Mar 10 01:43:31 2016 +0100 +++ b/docs/wiki/GettingStarted Fri Mar 11 01:33:45 2016 +0100 @@ -97,6 +97,10 @@ || Postfix routing and transport configuration || [[../MailIntegration|E-Mail Integration]] and .. [[../MailboxIntegration|Mailbox Integration]] +== +`postgresql` +|| PostgreSQL configuration +|| [[../DatabaseStore|Database Store]] }}} == Configuring the Software == diff -r 31d839d508f6 -r 54e1af14f1a2 imiptools/stores/common.py --- a/imiptools/stores/common.py Thu Mar 10 01:43:31 2016 +0100 +++ b/imiptools/stores/common.py Fri Mar 11 01:33:45 2016 +0100 @@ -19,18 +19,12 @@ this program. If not, see . """ -from imiptools.dates import format_datetime +from imiptools.dates import format_datetime, get_datetime class StoreBase: "The core operations of a data store." - def acquire_lock(self, user, timeout=None): - pass - - def release_lock(self, user): - pass - # User discovery. def get_users(self): @@ -240,7 +234,7 @@ # Otherwise, return the providers. - return t[1:] + return t def _set_freebusy_providers(self, user, dt_string, t): @@ -567,6 +561,15 @@ pass + def set_limit(self, quota, group, limit): + + """ + For the given 'quota', set for a user 'group' the given 'limit' on + resource usage. + """ + + pass + # Free/busy period access for users within quota groups. def get_freebusy(self, quota, user, mutable=False): diff -r 31d839d508f6 -r 54e1af14f1a2 imiptools/stores/database/common.py --- a/imiptools/stores/database/common.py Thu Mar 10 01:43:31 2016 +0100 +++ b/imiptools/stores/database/common.py Fri Mar 11 01:33:45 2016 +0100 @@ -809,7 +809,7 @@ "select store_user, user_group from user_groups :condition", columns, values) - self.cursor.execute(query) + self.cursor.execute(query, values) return dict(self.cursor.fetchall()) def get_limits(self, quota): @@ -826,9 +826,40 @@ "select user_group, quota_limit from quota_limits :condition", columns, values) - self.cursor.execute(query) + self.cursor.execute(query, values) return dict(self.cursor.fetchall()) + def set_limit(self, quota, group, limit): + + """ + For the given 'quota', set for a user 'group' the given 'limit' on + resource usage. + """ + + columns = ["quota", "user_group"] + values = [quota, group] + setcolumns = ["quota_limit"] + setvalues = [limit] + + query, values = self.get_query( + "update quota_limits :set :condition", + columns, values, setcolumns, setvalues) + + self.cursor.execute(query, values) + + if self.cursor.rowcount > 0: + return True + + columns = ["quota", "user_group", "quota_limit"] + values = [quota, group, limit] + + query, values = self.get_query( + "insert into quota_limits (:columns) values (:values)", + columns, values) + + self.cursor.execute(query, values) + return True + # Free/busy period access for users within quota groups. def get_freebusy(self, quota, user, mutable=False): diff -r 31d839d508f6 -r 54e1af14f1a2 imiptools/stores/database/postgresql.py --- a/imiptools/stores/database/postgresql.py Thu Mar 10 01:43:31 2016 +0100 +++ b/imiptools/stores/database/postgresql.py Fri Mar 11 01:33:45 2016 +0100 @@ -34,6 +34,14 @@ connection.autocommit = True DatabaseStore.__init__(self, connection, psycopg2.paramstyle) + def acquire_lock(self, user, timeout=None): + query = "select pg_advisory_lock(20160311)" + self.cursor.execute(query) + + def release_lock(self, user): + query = "select pg_advisory_unlock(20160311)" + self.cursor.execute(query) + class Journal(DatabaseJournal): "A PostgreSQL journal system supporting quotas." @@ -46,4 +54,12 @@ connection.autocommit = True DatabaseJournal.__init__(self, connection, psycopg2.paramstyle) + def acquire_lock(self, user, timeout=None): + query = "select pg_advisory_lock(20160312)" + self.cursor.execute(query) + + def release_lock(self, user): + query = "select pg_advisory_unlock(20160312)" + self.cursor.execute(query) + # vim: tabstop=4 expandtab shiftwidth=4 diff -r 31d839d508f6 -r 54e1af14f1a2 imiptools/stores/file.py --- a/imiptools/stores/file.py Thu Mar 10 01:43:31 2016 +0100 +++ b/imiptools/stores/file.py Fri Mar 11 01:33:45 2016 +0100 @@ -810,6 +810,23 @@ return dict(self._get_table_atomic(quota, filename, tab_separated=False)) + def set_limit(self, quota, group, limit): + + """ + For the given 'quota', set for a user 'group' the given 'limit' on + resource usage. + """ + + filename = self.get_object_in_store(quota, "limits") + if not filename: + return None + + limits = self.get_limits(quota) or {} + limits[group] = limit + + self._set_table_atomic(quota, filename, limits.items()) + return True + # Free/busy period access for users within quota groups. def get_freebusy(self, quota, user, mutable=False): diff -r 31d839d508f6 -r 54e1af14f1a2 tests/common.sh --- a/tests/common.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tests/common.sh Fri Mar 11 01:33:45 2016 +0100 @@ -1,23 +1,6 @@ #!/bin/sh -THIS_DIR=`dirname "$0"` -BASE_DIR="$THIS_DIR/.." - -STORETYPE=file - -if [ "$STORETYPE" = "file" ]; then - STORE=/tmp/store - JOURNAL=/tmp/journal -elif [ "$STORETYPE" = "postgresql" ]; then - DBNAME='test' - STORE="dbname=$DBNAME" - JOURNAL="$STORE" -fi - -STATIC=/tmp/static -PREFS=/tmp/prefs - -ARGS="-T $STORETYPE -S $STORE -P $STATIC -p $PREFS -j $JOURNAL -d" +. "`dirname \"$0\"`/common_minimal.sh" ACCEPT_SCRIPT="$THIS_DIR/test_handle.py" ACCEPT_ARGS="accept $STORETYPE $STORE $JOURNAL $PREFS" @@ -38,16 +21,11 @@ PERSON_SCRIPT="$BASE_DIR/imip_person.py" -RESOURCE_SCRIPT="$BASE_DIR/imip_resource.py" - -SHOWMAIL="$BASE_DIR/tools/showmail.py" +SET_QUOTA_LIMIT="$BASE_DIR/tools/set_quota_limit.py" +SET_QUOTA_LIMIT_ARGS="-T $STORETYPE -j $JOURNAL" TAB=`printf '\t'` -TEMPLATES="$THIS_DIR/templates" - -ERROR=err.tmp - PYTHONPATH="$BASE_DIR" export PYTHONPATH diff -r 31d839d508f6 -r 54e1af14f1a2 tests/common_minimal.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/common_minimal.sh Fri Mar 11 01:33:45 2016 +0100 @@ -0,0 +1,28 @@ +#!/bin/sh + +THIS_DIR=`dirname "$0"` +BASE_DIR="$THIS_DIR/.." + +STORETYPE=file + +if [ "$STORETYPE" = "file" ]; then + STORE=/tmp/store + JOURNAL=/tmp/journal +elif [ "$STORETYPE" = "postgresql" ]; then + DBNAME='test' + STORE="dbname=$DBNAME" + JOURNAL="$STORE" +fi + +STATIC=/tmp/static +PREFS=/tmp/prefs + +ARGS="-T $STORETYPE -S $STORE -P $STATIC -p $PREFS -j $JOURNAL -d" + +RESOURCE_SCRIPT="$BASE_DIR/imip_resource.py" + +SHOWMAIL="$BASE_DIR/tools/showmail.py" + +TEMPLATES="$THIS_DIR/templates" + +ERROR=err.tmp diff -r 31d839d508f6 -r 54e1af14f1a2 tests/list_table.py --- a/tests/list_table.py Thu Mar 10 01:43:31 2016 +0100 +++ b/tests/list_table.py Fri Mar 11 01:33:45 2016 +0100 @@ -56,7 +56,8 @@ # Periods. if table == "entries": - data = journal.get_entries(user) + group = args[0] + data = journal.get_entries(user, group) show_periods(data) elif table == "freebusy": @@ -78,6 +79,10 @@ data = store.get_requests(user) show_tuples(data) + elif table == "freebusy_providers": + data = store.get_freebusy_providers(user) + show_tuples(data) + # Objects. elif table == "countered_object": diff -r 31d839d508f6 -r 54e1af14f1a2 tests/resource_request.sh --- a/tests/resource_request.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tests/resource_request.sh Fri Mar 11 01:33:45 2016 +0100 @@ -1,17 +1,6 @@ #!/bin/sh -THIS_DIR=`dirname $0` - -TEMPLATES="$THIS_DIR/templates" -RESOURCE_SCRIPT="$THIS_DIR/../imip_resource.py" -SHOWMAIL="$THIS_DIR/../tools/showmail.py" -STORE=/tmp/store -STATIC=/tmp/static -PREFS=/tmp/prefs -JOURNAL=/tmp/journal -ARGS="-S $STORE -P $STATIC -p $PREFS -j $JOURNAL -d" - -ERROR=err.tmp +. "`dirname \"$0\"`/common_minimal.sh" export N=$1 export START=20141126T090000 diff -r 31d839d508f6 -r 54e1af14f1a2 tests/test_resource_invitation_add.sh --- a/tests/test_resource_invitation_add.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tests/test_resource_invitation_add.sh Fri Mar 11 01:33:45 2016 +0100 @@ -4,9 +4,6 @@ USER="mailto:resource-room-confroom@example.com" SENDER="mailto:paul.boddie@example.com" -FBFILE="$STORE/$USER/freebusy" -FBSENDERFILE="$STORE/$SENDER/freebusy" -FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER" mkdir -p "$PREFS/$USER" echo 'Europe/Oslo' > "$PREFS/$USER/TZID" @@ -20,7 +17,9 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-recurring.txt" 2>> $ERROR - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +| tee out0f.tmp \ +| grep -q "^20141212T090000Z${TAB}20141212T100000Z" \ && echo "Success" \ || echo "Failed" @@ -34,7 +33,9 @@ && echo "Success" \ || echo "Failed" - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +| tee out1f.tmp \ +| grep -q "^20141212T090000Z${TAB}20141212T100000Z" \ && echo "Success" \ || echo "Failed" @@ -44,7 +45,9 @@ | "$SHOWMAIL" \ > out2.tmp - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBSENDEROTHERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy_other" "$USER" \ +| tee out2o.tmp \ +| grep -q "^20141212T090000Z${TAB}20141212T100000Z" \ && echo "Success" \ || echo "Failed" @@ -52,8 +55,11 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-add-recurring.txt" 2>> $ERROR - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBSENDERFILE" \ -&& grep -q "^20150109T090000Z${TAB}20150109T100000Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +> out2f.tmp + + grep -q "^20141212T090000Z${TAB}20141212T100000Z" "out2f.tmp" \ +&& grep -q "^20150109T090000Z${TAB}20150109T100000Z" "out2f.tmp" \ && echo "Success" \ || echo "Failed" @@ -67,8 +73,11 @@ && echo "Success" \ || echo "Failed" - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \ -&& ! grep -q "^20150109T090000Z${TAB}20150109T100000Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out3f.tmp + + grep -q "^20141212T090000Z${TAB}20141212T100000Z" "out3f.tmp" \ +&& ! grep -q "^20150109T090000Z${TAB}20150109T100000Z" "out3f.tmp" \ && echo "Success" \ || echo "Failed" @@ -94,8 +103,11 @@ && echo "Success" \ || echo "Failed" - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBFILE" \ -&& grep -q "^20150109T090000Z${TAB}20150109T100000Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out5f.tmp + + grep -q "^20141212T090000Z${TAB}20141212T100000Z" "out5f.tmp" \ +&& grep -q "^20150109T090000Z${TAB}20150109T100000Z" "out5f.tmp" \ && echo "Success" \ || echo "Failed" @@ -105,7 +117,10 @@ | "$SHOWMAIL" \ > out6.tmp - grep -q "^20141212T090000Z${TAB}20141212T100000Z" "$FBSENDEROTHERFILE" \ -&& grep -q "^20150109T090000Z${TAB}20150109T100000Z" "$FBSENDEROTHERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy_other" "$USER" \ +> out6o.tmp + + grep -q "^20141212T090000Z${TAB}20141212T100000Z" "out6o.tmp" \ +&& grep -q "^20150109T090000Z${TAB}20150109T100000Z" "out6o.tmp" \ && echo "Success" \ || echo "Failed" diff -r 31d839d508f6 -r 54e1af14f1a2 tests/test_resource_invitation_constraints.sh --- a/tests/test_resource_invitation_constraints.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tests/test_resource_invitation_constraints.sh Fri Mar 11 01:33:45 2016 +0100 @@ -5,12 +5,6 @@ USER="mailto:resource-room-sauna@example.com" SENDER="mailto:paul.boddie@example.com" RIVALSENDER="mailto:vincent.vole@example.com" -FBFILE="$STORE/$USER/freebusy" -FBOFFERFILE="$STORE/$USER/freebusy-offers" -FBSENDERFILE="$STORE/$SENDER/freebusy" -FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER" -FBSENDERREQUESTS="$STORE/$SENDER/requests" -FBRIVALSENDERFILE="$STORE/$RIVALSENDER/freebusy" mkdir -p "$PREFS/$USER" echo 'Europe/Oslo' > "$PREFS/$USER/TZID" @@ -32,7 +26,9 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-bad.txt" 2>> $ERROR - grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +| tee out0f.tmp \ +| grep -q "^20141126T151000Z${TAB}20141126T154500Z" \ && echo "Success" \ || echo "Failed" @@ -48,12 +44,16 @@ && echo "Success" \ || echo "Failed" - ! [ -e "$FBFILE" ] \ -|| ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out1f.tmp + + ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "out1f.tmp" \ && echo "Success" \ || echo "Failed" - grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \ +| tee out1o.tmp \ +| grep -q "^20141126T151500Z${TAB}20141126T154500Z" \ && echo "Success" \ || echo "Failed" @@ -64,20 +64,28 @@ | "$SHOWMAIL" \ > out2.tmp - ( ! [ -e "$FBSENDEROTHERFILE" ] \ - || ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDEROTHERFILE") \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy_other" "$USER" \ +> out2f.tmp + + ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "out2f.tmp" \ && echo "Success" \ || echo "Failed" - grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161000' "$STORE/$SENDER/objects/event13@example.com" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "object" "event13@example.com" \ +| tee out2O.tmp \ +| grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161000' \ && echo "Success" \ || echo "Failed" - grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161500' "$STORE/$SENDER/counters/objects/event13@example.com/$USER" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "countered_object" "event13@example.com" "$USER" \ +| tee out2C.tmp \ +| grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161500' \ && echo "Success" \ || echo "Failed" - grep -q 'event13@example.com' "$FBSENDERREQUESTS" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "requests" \ +| tee out2r.tmp \ +| grep -q 'event13@example.com' \ && echo "Success" \ || echo "Failed" @@ -85,8 +93,11 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-rival.txt" 2>> $ERROR - ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ -&& grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$RIVALSENDER" "freebusy" \ +> out2R.tmp + + ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "out2R.tmp" \ +&& grep -q "^20141126T153000Z${TAB}20141126T154500Z" "out2R.tmp" \ && echo "Success" \ || echo "Failed" @@ -108,12 +119,17 @@ | "$SHOWMAIL" \ > out4.tmp - ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ -&& grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$RIVALSENDER" "freebusy" \ +> out4R.tmp + + ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "out4R.tmp" \ +&& grep -q "^20141126T153000Z${TAB}20141126T154500Z" "out4R.tmp" \ && echo "Success" \ || echo "Failed" - grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' "$STORE/$RIVALSENDER/objects/event18@example.com" \ + "$LIST_SCRIPT" $LIST_ARGS "$RIVALSENDER" "object" "event18@example.com" \ +| tee out4O.tmp \ +| grep -q 'ATTENDEE.*;PARTSTAT=DECLINED' \ && echo "Success" \ || echo "Failed" @@ -134,9 +150,12 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR - ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ -&& ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ -&& ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +> out5f.tmp + + ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "out5f.tmp" \ +&& ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "out5f.tmp" \ +&& ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "out5f.tmp" \ && echo "Success" \ || echo "Failed" @@ -144,7 +163,10 @@ && echo "Success" \ || echo "Failed" - ! grep -q 'event13@example.com' "$FBSENDERREQUESTS" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "requests" \ +> out5r.tmp + + ! grep -q 'event13@example.com' "out5r.tmp" \ && echo "Success" \ || echo "Failed" @@ -159,13 +181,18 @@ && echo "Success" \ || echo "Failed" - grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +| tee out6f.tmp \ +| grep -q "^20141126T150000Z${TAB}20141126T154500Z" \ && echo "Success" \ || echo "Failed" - ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \ +> out6o.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "out6o.tmp" \ +&& ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "out6o.tmp" \ +&& ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "out6o.tmp" \ && echo "Success" \ || echo "Failed" @@ -176,10 +203,13 @@ | "$SHOWMAIL" \ > out7.tmp - grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ -&& ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ -&& ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ -&& ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +> out7f.tmp + + grep -q "^20141126T150000Z${TAB}20141126T154500Z" "out7f.tmp" \ +&& ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "out7f.tmp" \ +&& ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "out7f.tmp" \ +&& ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "out7f.tmp" \ && echo "Success" \ || echo "Failed" @@ -187,7 +217,10 @@ && echo "Success" \ || echo "Failed" - ! grep -q 'event13@example.com' "$FBSENDERREQUESTS" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "requests" \ +> out7r.tmp + + ! grep -q 'event13@example.com' "out7r.tmp" \ && echo "Success" \ || echo "Failed" diff -r 31d839d508f6 -r 54e1af14f1a2 tests/test_resource_invitation_constraints_alternative.sh --- a/tests/test_resource_invitation_constraints_alternative.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tests/test_resource_invitation_constraints_alternative.sh Fri Mar 11 01:33:45 2016 +0100 @@ -5,12 +5,6 @@ USER="mailto:resource-room-sauna@example.com" SENDER="mailto:paul.boddie@example.com" RIVALSENDER="mailto:vincent.vole@example.com" -FBFILE="$STORE/$USER/freebusy" -FBOFFERFILE="$STORE/$USER/freebusy-offers" -FBSENDERFILE="$STORE/$SENDER/freebusy" -FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER" -FBSENDERREQUESTS="$STORE/$SENDER/requests" -FBRIVALSENDERFILE="$STORE/$RIVALSENDER/freebusy" mkdir -p "$PREFS/$USER" echo 'Europe/Oslo' > "$PREFS/$USER/TZID" @@ -32,7 +26,9 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-bad.txt" 2>> $ERROR - grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +| tee out0f.tmp \ +| grep -q "^20141126T151000Z${TAB}20141126T154500Z" \ && echo "Success" \ || echo "Failed" @@ -47,12 +43,16 @@ && echo "Success" \ || echo "Failed" - ! [ -e "$FBFILE" ] \ -|| ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out1f.tmp + + ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "out1f.tmp" \ && echo "Success" \ || echo "Failed" - grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \ +| tee out1o.tmp \ +| grep -q "^20141126T151500Z${TAB}20141126T154500Z" \ && echo "Success" \ || echo "Failed" @@ -63,21 +63,29 @@ | "$SHOWMAIL" \ > out2.tmp - [ ! -e "$FBSENDEROTHERFILE" ] \ -|| ( ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBSENDEROTHERFILE" \ - && ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBSENDEROTHERFILE" ) \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy_other" "$USER" \ +> out2f.tmp + + ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "out2f.tmp" \ +&& ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "out2f.tmp" \ && echo "Success" \ || echo "Failed" - grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161000' "$STORE/$SENDER/objects/event13@example.com" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "object" "event13@example.com" \ +| tee out2O.tmp \ +| grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161000' \ && echo "Success" \ || echo "Failed" - grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161500' "$STORE/$SENDER/counters/objects/event13@example.com/$USER" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "countered_object" "event13@example.com" "$USER" \ +| tee out2C.tmp \ +| grep -q 'DTSTART;TZID=Europe/Oslo.*:20141126T161500' \ && echo "Success" \ || echo "Failed" - grep -q 'event13@example.com' "$FBSENDERREQUESTS" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "requests" \ +| tee out2R.tmp \ +| grep -q 'event13@example.com' \ && echo "Success" \ || echo "Failed" @@ -94,12 +102,17 @@ | "$SHOWMAIL" \ > out4.tmp - ! [ -e "$FBFILE" ] \ -|| ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out4f.tmp + + ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "out4f.tmp" \ && echo "Success" \ || echo "Failed" - ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \ +> out4o.tmp + + ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "out4o.tmp" \ && echo "Success" \ || echo "Failed" @@ -107,8 +120,11 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-rival.txt" 2>> $ERROR - ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ -&& grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$RIVALSENDER" "freebusy" \ +> out4r.tmp + + ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "out4r.tmp" \ +&& grep -q "^20141126T153000Z${TAB}20141126T154500Z" "out4r.tmp" \ && echo "Success" \ || echo "Failed" @@ -123,11 +139,16 @@ && echo "Success" \ || echo "Failed" - grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +| tee out5f.tmp \ +| grep -q "^20141126T153000Z${TAB}20141126T154500Z" \ && echo "Success" \ || echo "Failed" - ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \ +> out5o.tmp + + ! grep -q "^20141126T153000Z${TAB}20141126T154500Z" "out5o.tmp" \ && echo "Success" \ || echo "Failed" @@ -137,13 +158,18 @@ | "$SHOWMAIL" \ > out6.tmp - ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ -&& ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ -&& grep -q "^20141126T153000Z${TAB}20141126T154500Z" "$FBRIVALSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$RIVALSENDER" "freebusy" \ +> out6r.tmp + + ! grep -q "^20141126T151000Z${TAB}20141126T154500Z" "out6r.tmp" \ +&& ! grep -q "^20141126T151500Z${TAB}20141126T154500Z" "out6r.tmp" \ +&& grep -q "^20141126T153000Z${TAB}20141126T154500Z" "out6r.tmp" \ && echo "Success" \ || echo "Failed" - grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' "$STORE/$RIVALSENDER/objects/event18@example.com" \ + "$LIST_SCRIPT" $LIST_ARGS "$RIVALSENDER" "object" "event18@example.com" \ +| tee out6O.tmp \ +| grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' \ && echo "Success" \ || echo "Failed" diff -r 31d839d508f6 -r 54e1af14f1a2 tests/test_resource_invitation_constraints_multiple.sh --- a/tests/test_resource_invitation_constraints_multiple.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tests/test_resource_invitation_constraints_multiple.sh Fri Mar 11 01:33:45 2016 +0100 @@ -5,9 +5,6 @@ USER="mailto:resource-room-sauna@example.com" SENDER="mailto:paul.boddie@example.com" OUTSIDESENDER="mailto:paul.boddie@example.net" -FBFILE="$STORE/$USER/freebusy" -FBSENDERFILE="$STORE/$SENDER/freebusy" -FBOUTSIDESENDERFILE="$STORE/$OUTSIDESENDER/freebusy" mkdir -p "$PREFS/$USER" echo 'Europe/Oslo' > "$PREFS/$USER/TZID" @@ -32,7 +29,9 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-outsider.txt" 2>> $ERROR - grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOUTSIDESENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$OUTSIDESENDER" "freebusy" \ +| tee out0f.tmp \ +| grep -q "^20141126T150000Z${TAB}20141126T154500Z" \ && echo "Success" \ || echo "Failed" @@ -48,8 +47,10 @@ && echo "Success" \ || echo "Failed" - ! [ -e "$FBFILE" ] \ -|| ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out1f.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "out1f.tmp" \ && echo "Success" \ || echo "Failed" @@ -71,8 +72,9 @@ && echo "Success" \ || echo "Failed" - [ -e "$FBFILE" ] \ -&& grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +| tee out2f.tmp \ +| grep -q "^20141126T150000Z${TAB}20141126T154500Z" \ && echo "Success" \ || echo "Failed" @@ -105,7 +107,9 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-acl.txt" 2>> $ERROR - grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +| tee out3f.tmp \ +| grep -q "^20141126T160000Z${TAB}20141126T164500Z" \ && echo "Success" \ || echo "Failed" @@ -121,8 +125,10 @@ && echo "Success" \ || echo "Failed" - ! [ -e "$FBFILE" ] \ -|| ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out4f.tmp + + ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "out4f.tmp" \ && echo "Success" \ || echo "Failed" @@ -136,7 +142,9 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-acl.txt" 2>> $ERROR - grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +| tee out4s.tmp \ +| grep -q "^20141126T160000Z${TAB}20141126T164500Z" \ && echo "Success" \ || echo "Failed" @@ -152,8 +160,10 @@ && echo "Success" \ || echo "Failed" - ! [ -e "$FBFILE" ] \ -|| ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out5f.tmp + + ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "out5f.tmp" \ && echo "Success" \ || echo "Failed" @@ -168,7 +178,9 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-acl.txt" 2>> $ERROR - grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +| tee out5s.tmp \ +| grep -q "^20141126T160000Z${TAB}20141126T164500Z" \ && echo "Success" \ || echo "Failed" @@ -184,8 +196,10 @@ && echo "Success" \ || echo "Failed" - ! [ -e "$FBFILE" ] \ -|| ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out6f.tmp + + ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "out6f.tmp" \ && echo "Success" \ || echo "Failed" @@ -214,8 +228,9 @@ && echo "Success" \ || echo "Failed" - ! [ -e "$FBFILE" ] \ -|| grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +| tee out7f.tmp \ +| grep -q "^20141126T160000Z${TAB}20141126T164500Z" \ && echo "Success" \ || echo "Failed" diff -r 31d839d508f6 -r 54e1af14f1a2 tests/test_resource_invitation_constraints_next_free.sh --- a/tests/test_resource_invitation_constraints_next_free.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tests/test_resource_invitation_constraints_next_free.sh Fri Mar 11 01:33:45 2016 +0100 @@ -5,13 +5,6 @@ USER="mailto:resource-room-sauna@example.com" SENDER="mailto:paul.boddie@example.com" RIVALSENDER="mailto:vincent.vole@example.com" -FBFILE="$STORE/$USER/freebusy" -FBOTHERFILE="$STORE/$USER/freebusy-other/$SENDER" -FBOFFERFILE="$STORE/$USER/freebusy-offers" -FBSENDERFILE="$STORE/$SENDER/freebusy" -FBSENDEROTHERFILE="$STORE/$SENDER/freebusy-other/$USER" -FBSENDERREQUESTS="$STORE/$SENDER/requests" -FBRIVALSENDERFILE="$STORE/$RIVALSENDER/freebusy" mkdir -p "$PREFS/$USER" echo 'Europe/Oslo' > "$PREFS/$USER/TZID" @@ -32,8 +25,11 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-busy.txt" 2>> $ERROR - [ `grep "event19@example.com" "$FBRIVALSENDERFILE" | wc -l` = '5' ] \ -&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBRIVALSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$RIVALSENDER" "freebusy" \ +> out0s.tmp + + [ `grep "event19@example.com" "out0s.tmp" | wc -l` = '5' ] \ +&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out0s.tmp" \ && echo "Success" \ || echo "Failed" @@ -49,8 +45,11 @@ && echo "Success" \ || echo "Failed" - [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \ -&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out1f.tmp + + [ `grep "event19@example.com" "out1f.tmp" | wc -l` = '5' ] \ +&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out1f.tmp" \ && echo "Success" \ || echo "Failed" @@ -67,8 +66,11 @@ | "$SHOWMAIL" \ > out3.tmp - grep -q "^20141126T160000Z${TAB}20141126T170000Z" "$FBOTHERFILE" \ -&& grep -q "^20141126T180000Z${TAB}20141126T190000Z" "$FBOTHERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_other" "$SENDER" \ +> out3f.tmp + + grep -q "^20141126T160000Z${TAB}20141126T170000Z" "out3f.tmp" \ +&& grep -q "^20141126T180000Z${TAB}20141126T190000Z" "out3f.tmp" \ && echo "Success" \ || echo "Failed" @@ -76,7 +78,9 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-sauna-good.txt" 2>> $ERROR - grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +| tee out3s.tmp \ +| grep -q "^20141126T150000Z${TAB}20141126T154500Z" \ && echo "Success" \ || echo "Failed" @@ -94,12 +98,15 @@ && echo "Success" \ || echo "Failed" - ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "$FBOFFERFILE" \ -&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBOFFERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \ +> out6o.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "out6o.tmp" \ +&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "out6o.tmp" \ +&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "out6o.tmp" \ +&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "out6o.tmp" \ +&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "out6o.tmp" \ +&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "out6o.tmp" \ && echo "Success" \ || echo "Failed" @@ -110,16 +117,23 @@ | "$SHOWMAIL" \ > out7.tmp - grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ -&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +> out7s.tmp + + grep -q "^20141126T150000Z${TAB}20141126T154500Z" "out7s.tmp" \ +&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "out7s.tmp" \ && echo "Success" \ || echo "Failed" - [ -e "$STORE/$SENDER/counters/objects/event13@example.com/$USER" ] \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "countered_object" "event13@example.com" "$USER" \ +| tee out7C.tmp \ +| grep -q "event13@example.com" \ && echo "Success" \ || echo "Failed" - grep -q 'event13@example.com' "$FBSENDERREQUESTS" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "requests" \ +| tee out7R.tmp \ +| grep -q 'event13@example.com' \ && echo "Success" \ || echo "Failed" @@ -132,16 +146,25 @@ "$OUTGOING_SCRIPT" $ARGS < out8.tmp 2>> $ERROR - ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBSENDERFILE" \ -&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +> out8s.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "out8s.tmp" \ +&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "out8s.tmp" \ && echo "Success" \ || echo "Failed" - ! [ -e "$STORE/$SENDER/counters/objects/event13@example.com/$USER" ] \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "countered_object" "event13@example.com" "$USER" \ +> out8C.tmp + + ! grep -q "event13@example.com" "out8C.tmp" \ && echo "Success" \ || echo "Failed" - ! grep -q 'event13@example.com' "$FBSENDERREQUESTS" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "requests" \ +> out8R.tmp + + ! grep -q 'event13@example.com' "out8R.tmp" \ && echo "Success" \ || echo "Failed" @@ -154,18 +177,24 @@ && echo "Success" \ || echo "Failed" - ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBOFFERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \ +> out9o.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "out9o.tmp" \ +&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "out9o.tmp" \ +&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "out9o.tmp" \ +&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "out9o.tmp" \ +&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "out9o.tmp" \ +&& ! grep -q "^20141126T200000Z${TAB}20141126T204500Z" "out9o.tmp" \ && echo "Success" \ || echo "Failed" - [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \ -&& [ `grep "event13@example.com" "$FBFILE" | wc -l` = '1' ] \ -&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out9f.tmp + + [ `grep "event19@example.com" "out9f.tmp" | wc -l` = '5' ] \ +&& [ `grep "event13@example.com" "out9f.tmp" | wc -l` = '1' ] \ +&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "out9f.tmp" \ && echo "Success" \ || echo "Failed" @@ -180,18 +209,24 @@ && echo "Success" \ || echo "Failed" - ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBOFFERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \ +> out10o.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "out10o.tmp" \ +&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "out10o.tmp" \ +&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "out10o.tmp" \ +&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "out10o.tmp" \ +&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "out10o.tmp" \ +&& ! grep -q "^20141126T200000Z${TAB}20141126T204500Z" "out10o.tmp" \ && echo "Success" \ || echo "Failed" - [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \ -&& [ `grep "event13@example.com" "$FBFILE" | wc -l` = '1' ] \ -&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out10f.tmp + + [ `grep "event19@example.com" "out10f.tmp" | wc -l` = '5' ] \ +&& [ `grep "event13@example.com" "out10f.tmp" | wc -l` = '1' ] \ +&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "out10f.tmp" \ && echo "Success" \ || echo "Failed" @@ -212,17 +247,23 @@ # Note that the duration is different now. - ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "$FBOFFERFILE" \ -&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "$FBOFFERFILE" \ -&& grep -q "^20141126T200000Z${TAB}20141126T203000Z" "$FBOFFERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_offers" \ +> out12o.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T154500Z" "out12o.tmp" \ +&& ! grep -q "^20141126T160000Z${TAB}20141126T164500Z" "out12o.tmp" \ +&& ! grep -q "^20141126T170000Z${TAB}20141126T174500Z" "out12o.tmp" \ +&& ! grep -q "^20141126T180000Z${TAB}20141126T184500Z" "out12o.tmp" \ +&& ! grep -q "^20141126T190000Z${TAB}20141126T194500Z" "out12o.tmp" \ +&& grep -q "^20141126T200000Z${TAB}20141126T203000Z" "out12o.tmp" \ && echo "Success" \ || echo "Failed" - [ `grep "event19@example.com" "$FBFILE" | wc -l` = '5' ] \ -&& [ `grep "event13@example.com" "$FBFILE" | wc -l` = '1' ] \ -&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out12f.tmp + + [ `grep "event19@example.com" "out12f.tmp" | wc -l` = '5' ] \ +&& [ `grep "event13@example.com" "out12f.tmp" | wc -l` = '1' ] \ +&& grep -q "^20141126T200000Z${TAB}20141126T204500Z" "out12f.tmp" \ && echo "Success" \ || echo "Failed" diff -r 31d839d508f6 -r 54e1af14f1a2 tests/test_resource_invitation_constraints_quota.sh --- a/tests/test_resource_invitation_constraints_quota.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tests/test_resource_invitation_constraints_quota.sh Fri Mar 11 01:33:45 2016 +0100 @@ -5,11 +5,7 @@ USER1="mailto:resource-car-porsche911@example.com" USER2="mailto:resource-car-fiat500@example.com" SENDER="mailto:paul.boddie@example.com" -FBFILE1="$STORE/$USER1/freebusy" -FBFILE2="$STORE/$USER2/freebusy" -FBSENDERFILE="$STORE/$SENDER/freebusy" QUOTA=cars -JOURNALFILE="$JOURNAL/$QUOTA/journal/$SENDER" mkdir -p "$PREFS/$USER1" echo 'Europe/Oslo' > "$PREFS/$USER1/TZID" @@ -27,8 +23,7 @@ check_quota $QUOTA EOF -mkdir -p "$JOURNAL/$QUOTA" -echo '* PT1H' > "$JOURNAL/$QUOTA/limits" +"$SET_QUOTA_LIMIT" "$QUOTA" '*' 'PT1H' $SET_QUOTA_LIMIT_ARGS "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-car.txt" 2>> $ERROR \ | "$SHOWMAIL" \ @@ -43,7 +38,9 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR - grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +| tee out0s.tmp \ +| grep -q "^20141126T150000Z${TAB}20141126T160000Z" \ && echo "Success" \ || echo "Failed" @@ -59,15 +56,17 @@ && echo "Success" \ || echo "Failed" - [ -e "$FBFILE1" ] \ -&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE1" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ +| tee out1f.tmp \ +| grep -q "^20141126T150000Z${TAB}20141126T160000Z" \ && echo "Success" \ || echo "Failed" # Check the quota (event is confirmed). - [ -e "$JOURNALFILE" ] \ -&& grep -q "event21@example.com" "$JOURNALFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ +| tee out1e.tmp \ +| grep -q "event21@example.com" \ && echo "Success" \ || echo "Failed" @@ -75,7 +74,9 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-conflict.txt" 2>> $ERROR - grep -q "^20141126T153000Z${TAB}20141126T163000Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +| tee out1s.tmp \ +| grep -q "^20141126T153000Z${TAB}20141126T163000Z" \ && echo "Success" \ || echo "Failed" @@ -91,28 +92,34 @@ && echo "Success" \ || echo "Failed" - ! [ -e "$FBFILE2" ] \ -|| ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "$FBFILE2" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ +> out2f.tmp + + ! grep -q "^20141126T153000Z${TAB}20141126T163000Z" "out2f.tmp" \ && echo "Success" \ || echo "Failed" # Check the quota (event is not confirmed). - [ -e "$JOURNALFILE" ] \ -&& grep -q "event21@example.com" "$JOURNALFILE" \ -&& ! grep -q "event22@example.com" "$JOURNALFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ +> out2e.tmp + + grep -q "event21@example.com" "out2e.tmp" \ +&& ! grep -q "event22@example.com" "out2e.tmp" \ && echo "Success" \ || echo "Failed" # Increase the quota. -echo '* PT2H' > "$JOURNAL/$QUOTA/limits" +"$SET_QUOTA_LIMIT" "$QUOTA" '*' 'PT2H' $SET_QUOTA_LIMIT_ARGS # Attempt to schedule the event again. "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-conflict.txt" 2>> $ERROR - grep -q "^20141126T153000Z${TAB}20141126T163000Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +| tee out2s.tmp \ +| grep -q "^20141126T153000Z${TAB}20141126T163000Z" \ && echo "Success" \ || echo "Failed" @@ -128,16 +135,19 @@ && echo "Success" \ || echo "Failed" - [ -e "$FBFILE2" ] \ -&& grep -q "^20141126T153000Z${TAB}20141126T163000Z" "$FBFILE2" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ +| tee out3f.tmp \ +| grep -q "^20141126T153000Z${TAB}20141126T163000Z" \ && echo "Success" \ || echo "Failed" # Check the quota (event is confirmed). - [ -e "$JOURNALFILE" ] \ -&& grep -q "event21@example.com" "$JOURNALFILE" \ -&& grep -q "event22@example.com" "$JOURNALFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ +> out3e.tmp + + grep -q "event21@example.com" "out3e.tmp" \ +&& grep -q "event22@example.com" "out3e.tmp" \ && echo "Success" \ || echo "Failed" @@ -145,7 +155,10 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-car.txt" 2>> $ERROR - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +> out3s.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out3s.tmp" \ && echo "Success" \ || echo "Failed" @@ -160,15 +173,20 @@ && echo "Success" \ || echo "Failed" - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE1" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ +> out4f.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out4f.tmp" \ && echo "Success" \ || echo "Failed" # Check the quota (event is retracted). - [ -e "$JOURNALFILE" ] \ -&& ! grep -q "event21@example.com" "$JOURNALFILE" \ -&& grep -q "event22@example.com" "$JOURNALFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ +> out4e.tmp + + ! grep -q "event21@example.com" "out4e.tmp" \ +&& grep -q "event22@example.com" "out4e.tmp" \ && echo "Success" \ || echo "Failed" @@ -198,16 +216,19 @@ && echo "Success" \ || echo "Failed" - [ -e "$FBFILE2" ] \ -&& grep -q "^20141126T153000Z${TAB}20141126T163000Z" "$FBFILE2" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ +| tee out5f.tmp \ +| grep -q "^20141126T153000Z${TAB}20141126T163000Z" \ && echo "Success" \ || echo "Failed" # Check the quota (event is still confirmed). - [ -e "$JOURNALFILE" ] \ -&& ! grep -q "event21@example.com" "$JOURNALFILE" \ -&& grep -q "event22@example.com" "$JOURNALFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ +> out5e.tmp + + ! grep -q "event21@example.com" "out5e.tmp" \ +&& grep -q "event22@example.com" "out5e.tmp" \ && echo "Success" \ || echo "Failed" @@ -215,7 +236,9 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car.txt" 2>> $ERROR - grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +| tee out5s.tmp \ +| grep -q "^20141126T150000Z${TAB}20141126T160000Z" \ && echo "Success" \ || echo "Failed" @@ -231,15 +254,20 @@ && echo "Success" \ || echo "Failed" - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE1" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ +> out6f.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out6f.tmp" \ && echo "Success" \ || echo "Failed" # Check the quota (event is still retracted and not newly confirmed). - [ -e "$JOURNALFILE" ] \ -&& ! grep -q "event21@example.com" "$JOURNALFILE" \ -&& grep -q "event22@example.com" "$JOURNALFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ +> out6e.tmp + + ! grep -q "event21@example.com" "out6e.tmp" \ +&& grep -q "event22@example.com" "out6e.tmp" \ && echo "Success" \ || echo "Failed" @@ -247,8 +275,11 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-moved.txt" 2>> $ERROR - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE" \ -&& grep -q "^20141126T143000Z${TAB}20141126T153000Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +> out6s.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out6s.tmp" \ +&& grep -q "^20141126T143000Z${TAB}20141126T153000Z" "out6s.tmp" \ && echo "Success" \ || echo "Failed" @@ -264,27 +295,33 @@ && echo "Success" \ || echo "Failed" - grep -q "^20141126T143000Z${TAB}20141126T153000Z" "$FBFILE1" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ +| tee out7f.tmp \ +| grep -q "^20141126T143000Z${TAB}20141126T153000Z" \ && echo "Success" \ || echo "Failed" # Check the quota (event is newly confirmed). - [ -e "$JOURNALFILE" ] \ -&& grep -q "event21@example.com" "$JOURNALFILE" \ -&& grep -q "event22@example.com" "$JOURNALFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ +> out7e.tmp + + grep -q "event21@example.com" "out7e.tmp" \ +&& grep -q "event22@example.com" "out7e.tmp" \ && echo "Success" \ || echo "Failed" # Increase the quota. -echo '* PT3H' > "$JOURNAL/$QUOTA/limits" +"$SET_QUOTA_LIMIT" "$QUOTA" '*' 'PT3H' $SET_QUOTA_LIMIT_ARGS # Attempt to schedule an event involving both resources. "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-cars.txt" 2>> $ERROR - grep -q "^20141127T150000Z${TAB}20141127T160000Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +| tee out7s.tmp \ +| grep -q "^20141127T150000Z${TAB}20141127T160000Z" \ && echo "Success" \ || echo "Failed" @@ -311,16 +348,23 @@ && echo "Success" \ || echo "Failed" - ( grep -q "^20141127T150000Z${TAB}20141127T160000Z" "$FBFILE1" \ - && ! grep -q "^20141127T150000Z${TAB}20141127T160000Z" "$FBFILE2" ) \ -|| ( ! grep -q "^20141127T150000Z${TAB}20141127T160000Z" "$FBFILE1" \ - && grep -q "^20141127T150000Z${TAB}20141127T160000Z" "$FBFILE2" ) \ + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ +> out8f.tmp + + "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ +> out8f2.tmp + + ( grep -q "^20141127T150000Z${TAB}20141127T160000Z" "out8f.tmp" \ + && ! grep -q "^20141127T150000Z${TAB}20141127T160000Z" "out8f2.tmp" ) \ +|| ( ! grep -q "^20141127T150000Z${TAB}20141127T160000Z" "out8f.tmp" \ + && grep -q "^20141127T150000Z${TAB}20141127T160000Z" "out8f2.tmp" ) \ && echo "Success" \ || echo "Failed" # Check the quota (event is confirmed, but only for one resource). - [ -e "$JOURNALFILE" ] \ -&& grep -q "event23@example.com" "$JOURNALFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ +| tee out8e.tmp \ +| grep -q "event23@example.com" \ && echo "Success" \ || echo "Failed" diff -r 31d839d508f6 -r 54e1af14f1a2 tests/test_resource_invitation_constraints_quota_recurring.sh --- a/tests/test_resource_invitation_constraints_quota_recurring.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tests/test_resource_invitation_constraints_quota_recurring.sh Fri Mar 11 01:33:45 2016 +0100 @@ -4,10 +4,7 @@ USER="mailto:resource-car-porsche911@example.com" SENDER="mailto:paul.boddie@example.com" -FBFILE="$STORE/$USER/freebusy" -FBSENDERFILE="$STORE/$SENDER/freebusy" QUOTA="$USER" -JOURNALFILE="$JOURNAL/$QUOTA/journal/$SENDER" mkdir -p "$PREFS/$USER" echo 'Europe/Oslo' > "$PREFS/$USER/TZID" @@ -19,8 +16,7 @@ # Employ a user-specific quota (no argument with the functions above). -mkdir -p "$JOURNAL/$QUOTA" -echo '* PT10H' > "$JOURNAL/$QUOTA/limits" +"$SET_QUOTA_LIMIT" "$QUOTA" '*' 'PT10H' $SET_QUOTA_LIMIT_ARGS "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-car-all.txt" 2>> $ERROR \ | "$SHOWMAIL" \ @@ -35,8 +31,11 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-car-recurring.txt" 2>> $ERROR - grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE" \ -&& grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +> out0f.tmp + + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out0f.tmp" \ +&& grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out0f.tmp" \ && echo "Success" \ || echo "Failed" @@ -52,16 +51,20 @@ && echo "Success" \ || echo "Failed" - ! [ -e "$FBFILE" ] \ -|| ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ - && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBFILE" ) \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out1f.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out1f.tmp" \ +&& ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out1f.tmp" \ && echo "Success" \ || echo "Failed" # Check the quota (event is not confirmed). - ! [ -e "$JOURNALFILE" ] \ -|| ! grep -q "event24@example.com" "$JOURNALFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ +> out1e.tmp + + ! grep -q "event24@example.com" "out1e.tmp" \ && echo "Success" \ || echo "Failed" @@ -70,9 +73,12 @@ sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=11/;' "$TEMPLATES/event-request-car-recurring.txt" \ | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR - grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE" \ -&& grep -q "^20141205T150000Z${TAB}20141205T160000Z" "$FBSENDERFILE" \ -&& grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +> out1s.tmp + + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out1s.tmp" \ +&& grep -q "^20141205T150000Z${TAB}20141205T160000Z" "out1s.tmp" \ +&& grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out1s.tmp" \ && echo "Success" \ || echo "Failed" @@ -89,17 +95,21 @@ && echo "Success" \ || echo "Failed" - ! [ -e "$FBFILE" ] \ -|| ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ - && ! grep -q "^20141205T150000Z${TAB}20141205T160000Z" "$FBFILE" \ - && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBFILE" ) \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out2f.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f.tmp" \ +&& ! grep -q "^20141205T150000Z${TAB}20141205T160000Z" "out2f.tmp" \ +&& ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out2f.tmp" \ && echo "Success" \ || echo "Failed" # Check the quota (event is confirmed). - ! [ -e "$JOURNALFILE" ] \ -|| ! grep -q "event24@example.com" "$JOURNALFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ +> out2e.tmp + + ! grep -q "event24@example.com" "out2e.tmp" \ && echo "Success" \ || echo "Failed" @@ -108,9 +118,12 @@ sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=10/;' "$TEMPLATES/event-request-car-recurring.txt" \ | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR - grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE" \ -&& grep -q "^20141205T150000Z${TAB}20141205T160000Z" "$FBSENDERFILE" \ -&& ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBSENDERFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER" "freebusy" \ +> out2s.tmp + + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2s.tmp" \ +&& grep -q "^20141205T150000Z${TAB}20141205T160000Z" "out2s.tmp" \ +&& ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out2s.tmp" \ && echo "Success" \ || echo "Failed" @@ -118,25 +131,29 @@ sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=10/;' "$TEMPLATES/event-request-car-recurring.txt" \ | "$RESOURCE_SCRIPT" $ARGS 2>> $ERROR \ -| tee out2r.tmp \ +| tee out3r.tmp \ | "$SHOWMAIL" \ -> out2.tmp +> out3.tmp - grep -q 'METHOD:REPLY' out2.tmp \ -&& grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out2.tmp \ + grep -q 'METHOD:REPLY' out3.tmp \ +&& grep -q 'ATTENDEE.*;PARTSTAT=ACCEPTED' out3.tmp \ && echo "Success" \ || echo "Failed" - [ -e "$FBFILE" ] \ -&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE" \ -&& grep -q "^20141205T150000Z${TAB}20141205T160000Z" "$FBFILE" \ -&& ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy" \ +> out3f.tmp + + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out3f.tmp" \ +&& grep -q "^20141205T150000Z${TAB}20141205T160000Z" "out3f.tmp" \ +&& ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out3f.tmp" \ && echo "Success" \ || echo "Failed" # Check the quota (event is confirmed). - [ -e "$JOURNALFILE" ] \ -&& grep -q "event24@example.com" "$JOURNALFILE" \ + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER" \ +> out3e.tmp + + grep -q "event24@example.com" "out3e.tmp" \ && echo "Success" \ || echo "Failed" diff -r 31d839d508f6 -r 54e1af14f1a2 tests/test_resource_invitation_constraints_quota_recurring_limits.sh --- a/tests/test_resource_invitation_constraints_quota_recurring_limits.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tests/test_resource_invitation_constraints_quota_recurring_limits.sh Fri Mar 11 01:33:45 2016 +0100 @@ -8,13 +8,7 @@ SENDER2="mailto:vincent.vole@example.com" SENDERADDRESS1="paul.boddie@example.com" SENDERADDRESS2="vincent.vole@example.com" -FBFILE1="$STORE/$USER1/freebusy" -FBFILE2="$STORE/$USER2/freebusy" -FBSENDERFILE1="$STORE/$SENDER1/freebusy" -FBSENDERFILE2="$STORE/$SENDER2/freebusy" QUOTA=cars -JOURNALFILE1="$JOURNAL/$QUOTA/journal/$SENDER1" -JOURNALFILE2="$JOURNAL/$QUOTA/journal/$SENDER2" mkdir -p "$PREFS/$USER1" echo 'Europe/Oslo' > "$PREFS/$USER1/TZID" @@ -32,11 +26,8 @@ check_quota $QUOTA EOF -mkdir -p "$JOURNAL/$QUOTA" -cat > "$JOURNAL/$QUOTA/limits" <> $ERROR \ | "$SHOWMAIL" \ @@ -51,8 +42,11 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-request-cars-recurring.txt" 2>> $ERROR - grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE1" \ -&& grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBSENDERFILE1" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \ +> out0f.tmp + + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out0f.tmp" \ +&& grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out0f.tmp" \ && echo "Success" \ || echo "Failed" @@ -68,19 +62,25 @@ && echo "Success" \ || echo "Failed" - ( ! [ -e "$FBFILE1" ] \ - || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE1" \ - && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBFILE1" )) \ -&& ( ! [ -e "$FBFILE2" ] \ - || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE2" \ - && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBFILE2" )) \ + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ +> out1f.tmp + + "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ +> out1f2.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out1f.tmp" \ +&& ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out1f.tmp" \ +&& ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out1f2.tmp" \ +&& ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out1f2.tmp" \ && echo "Success" \ || echo "Failed" # Check the quota (event is not confirmed). - ! [ -e "$JOURNALFILE1" ] \ -|| ! grep -q "event25@example.com" "$JOURNALFILE1" \ + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER1" \ +> out1e.tmp + + ! grep -q "event25@example.com" "out1e.tmp" \ && echo "Success" \ || echo "Failed" @@ -89,8 +89,11 @@ sed 's/FREQ=DAILY/FREQ=DAILY;COUNT=5/;' "$TEMPLATES/event-request-cars-recurring.txt" \ | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR - grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE1" \ -&& grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBSENDERFILE1" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \ +> out1s.tmp + + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out1s.tmp" \ +&& grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out1s.tmp" \ && echo "Success" \ || echo "Failed" @@ -118,25 +121,29 @@ && echo "Success" \ || echo "Failed" - (( ! [ -e "$FBFILE1" ] \ - || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE1" \ - && ! grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBFILE1" )) \ - && [ -e "$FBFILE2" ] \ - && grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE2" \ - && grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBFILE2" ) \ -|| (( ! [ -e "$FBFILE2" ] \ - || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE2" \ - && ! grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBFILE2" )) \ - && [ -e "$FBFILE1" ] \ - && grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE1" \ - && grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBFILE1" ) \ + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ +> out2f.tmp + + "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ +> out2f2.tmp + + ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f.tmp" \ + && ! grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out2f.tmp" \ + && grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f2.tmp" \ + && grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out2f2.tmp" ) \ +|| ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f2.tmp" \ + && ! grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out2f2.tmp" \ + && grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2f.tmp" \ + && grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out2f.tmp" ) \ && echo "Success" \ || echo "Failed" # Check the quota (event is confirmed for one resource). - ! [ -e "$JOURNALFILE1" ] \ -|| grep -q "event25@example.com" "$JOURNALFILE1" \ + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER1" \ +> out2e.tmp + + grep -q "event25@example.com" "out2e.tmp" \ && echo "Success" \ || echo "Failed" @@ -144,8 +151,11 @@ "$OUTGOING_SCRIPT" $ARGS < "$TEMPLATES/event-cancel-cars-recurring.txt" 2>> $ERROR - ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE1" \ -&& ! grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBSENDERFILE1" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER1" "freebusy" \ +> out2s.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out2s.tmp" \ +&& ! grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out2s.tmp" \ && echo "Success" \ || echo "Failed" @@ -160,19 +170,25 @@ && echo "Success" \ || echo "Failed" - ( ! [ -e "$FBFILE1" ] \ - || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE1" \ - && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBFILE1" )) \ -&& ( ! [ -e "$FBFILE2" ] \ - || ( ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE2" \ - && ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "$FBFILE2" )) \ + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ +> out3f.tmp + + "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ +> out3f2.tmp + + ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out3f.tmp" \ +&& ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out3f.tmp" \ +&& ! grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out3f2.tmp" \ +&& ! grep -q "^20141206T150000Z${TAB}20141206T160000Z" "out3f2.tmp" \ && echo "Success" \ || echo "Failed" # Check the quota (event is retracted). - ! [ -e "$JOURNALFILE1" ] \ -|| ! grep -q "event25@example.com" "$JOURNALFILE1" \ + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER1" \ +> out3e.tmp + + ! grep -q "event25@example.com" "out3e.tmp" \ && echo "Success" \ || echo "Failed" @@ -182,8 +198,11 @@ | sed "s/$SENDERADDRESS1/$SENDERADDRESS2/;" \ | "$OUTGOING_SCRIPT" $ARGS 2>> $ERROR - grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBSENDERFILE2" \ -&& grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBSENDERFILE2" \ + "$LIST_SCRIPT" $LIST_ARGS "$SENDER2" "freebusy" \ +> out3s.tmp + + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out3s.tmp" \ +&& grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out3s.tmp" \ && echo "Success" \ || echo "Failed" @@ -211,18 +230,24 @@ && echo "Success" \ || echo "Failed" - [ -e "$FBFILE1" ] \ -&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE1" \ -&& grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBFILE1" \ -&& [ -e "$FBFILE2" ] \ -&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "$FBFILE2" \ -&& grep -q "^20141130T150000Z${TAB}20141130T160000Z" "$FBFILE2" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER1" "freebusy" \ +> out4f.tmp + + "$LIST_SCRIPT" $LIST_ARGS "$USER2" "freebusy" \ +> out4f2.tmp + + grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out4f.tmp" \ +&& grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out4f.tmp" \ +&& grep -q "^20141126T150000Z${TAB}20141126T160000Z" "out4f2.tmp" \ +&& grep -q "^20141130T150000Z${TAB}20141130T160000Z" "out4f2.tmp" \ && echo "Success" \ || echo "Failed" # Check the quota (event is confirmed for both resources). - [ -e "$JOURNALFILE2" ] \ -&& grep -q "event25@example.com" "$JOURNALFILE2" \ + "$LIST_SCRIPT" $LIST_ARGS "$QUOTA" "entries" "$SENDER2" \ +> out4e.tmp + + grep -q "event25@example.com" "out4e.tmp" \ && echo "Success" \ || echo "Failed" diff -r 31d839d508f6 -r 54e1af14f1a2 tests/test_resource_invitation_recurring_indefinitely.sh --- a/tests/test_resource_invitation_recurring_indefinitely.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tests/test_resource_invitation_recurring_indefinitely.sh Fri Mar 11 01:33:45 2016 +0100 @@ -39,7 +39,9 @@ "$FREEBUSY_SCRIPT" "$USER" $FREEBUSY_ARGS $ARGS 2>> $ERROR - grep -q 'event14@example.com' "$STORE/$USER/freebusy-providers" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_providers" \ +| tee out3p.tmp \ +| grep -q 'event14@example.com' \ && echo "Success" \ || echo "Failed" @@ -57,7 +59,10 @@ && echo "Success" \ || echo "Failed" - ! grep -q 'event14@example.com' "$STORE/$USER/freebusy-providers" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_providers" \ +> out4p.tmp + + ! grep -q 'event14@example.com' "out4p.tmp" \ && echo "Success" \ || echo "Failed" @@ -83,6 +88,8 @@ && echo "Success" \ || echo "Failed" - grep -q 'event14@example.com' "$STORE/$USER/freebusy-providers" \ + "$LIST_SCRIPT" $LIST_ARGS "$USER" "freebusy_providers" \ +| tee out6p.tmp \ +| grep -q 'event14@example.com' \ && echo "Success" \ || echo "Failed" diff -r 31d839d508f6 -r 54e1af14f1a2 tools/config.sh --- a/tools/config.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tools/config.sh Fri Mar 11 01:33:45 2016 +0100 @@ -1,5 +1,6 @@ #!/bin/sh +STORE_TYPE=file IMIP_AGENT_USER=imip-agent IMIP_AGENT_GROUP=lmtp INSTALL_DIR=/var/lib/imip-agent diff -r 31d839d508f6 -r 54e1af14f1a2 tools/fix.sh --- a/tools/fix.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tools/fix.sh Fri Mar 11 01:33:45 2016 +0100 @@ -3,9 +3,11 @@ DIRNAME=`dirname $0` if [ -e "$DIRNAME/config.sh" ]; then - . "$DIRNAME/config.sh" + CONFIG="$DIRNAME/config.sh" + . "$CONFIG" else - . /etc/imip-agent/config.sh + CONFIG=/etc/imip-agent/config.sh + . "$CONFIG" fi PROGNAME=`basename $0` @@ -32,9 +34,16 @@ chown -R "$USER" "$INSTALL_DIR" chgrp -R "$GROUP" "$INSTALL_DIR" -for DIR in "$INSTALL_DIR"/store "$INSTALL_DIR"/preferences "$WEB_INSTALL_DIR"/static \ - "$INSTALL_DIR"/journal ; do +for DIR in "$INSTALL_DIR"/preferences "$WEB_INSTALL_DIR"/static ; do chown -R "$USER" "$DIR" chgrp -R "$GROUP" "$DIR" chmod -R g+w "$DIR" done + +if [ "$STORE_TYPE" = "file" ]; then + for DIR in "$INSTALL_DIR"/store "$INSTALL_DIR"/journal ; do + chown -R "$USER" "$DIR" + chgrp -R "$GROUP" "$DIR" + chmod -R g+w "$DIR" + done +fi diff -r 31d839d508f6 -r 54e1af14f1a2 tools/init.sh --- a/tools/init.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tools/init.sh Fri Mar 11 01:33:45 2016 +0100 @@ -3,9 +3,11 @@ DIRNAME=`dirname $0` if [ -e "$DIRNAME/config.sh" ]; then - . "$DIRNAME/config.sh" + CONFIG="$DIRNAME/config.sh" + . "$CONFIG" else - . /etc/imip-agent/config.sh + CONFIG=/etc/imip-agent/config.sh + . "$CONFIG" fi PROGNAME=`basename $0` @@ -23,14 +25,16 @@ Within the stored data directory (using $INSTALL_DIR as an example), the following directories are created: - * $INSTALL_DIR/journal + * $INSTALL_DIR/journal (if STORE_TYPE is "file") * $INSTALL_DIR/preferences - * $INSTALL_DIR/store + * $INSTALL_DIR/store (if STORE_TYPE is "file") Within the published data directory (using $WEB_INSTALL_DIR as an example), the following directory is created: * $WEB_INSTALL_DIR/static + +See $CONFIG for the STORE_TYPE setting. EOF exit 1 fi @@ -40,10 +44,18 @@ USER=${3:-$IMIP_AGENT_USER} GROUP=${4:-$IMIP_AGENT_GROUP} -for DIR in "$INSTALL_DIR"/store "$INSTALL_DIR"/preferences "$WEB_INSTALL_DIR"/static \ - "$INSTALL_DIR"/journal ; do +for DIR in "$INSTALL_DIR"/preferences "$WEB_INSTALL_DIR"/static ; do mkdir -p "$DIR" chown "$USER" "$DIR" chgrp "$GROUP" "$DIR" chmod g+ws "$DIR" done + +if [ "$STORE_TYPE" = "file" ]; then + for DIR in "$INSTALL_DIR"/store "$INSTALL_DIR"/journal ; do + mkdir -p "$DIR" + chown "$USER" "$DIR" + chgrp "$GROUP" "$DIR" + chmod g+ws "$DIR" + done +fi diff -r 31d839d508f6 -r 54e1af14f1a2 tools/init_user.sh --- a/tools/init_user.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tools/init_user.sh Fri Mar 11 01:33:45 2016 +0100 @@ -3,9 +3,11 @@ DIRNAME=`dirname $0` if [ -e "$DIRNAME/config.sh" ]; then - . "$DIRNAME/config.sh" + CONFIG="$DIRNAME/config.sh" + . "$CONFIG" else - . /etc/imip-agent/config.sh + CONFIG=/etc/imip-agent/config.sh + . "$CONFIG" fi PROGNAME=`basename $0` @@ -29,10 +31,18 @@ WEB_INSTALL_DIR=${3:-$WEB_INSTALL_DIR} USER=${4:-$IMIP_AGENT_USER} -for DIR in "$INSTALL_DIR"/store "$INSTALL_DIR"/preferences "$WEB_INSTALL_DIR"/static \ - "$INSTALL_DIR"/journal ; do +for DIR in "$INSTALL_DIR"/preferences "$WEB_INSTALL_DIR"/static ; do mkdir -p "$DIR/$CALENDAR_USER" chown "$USER" "$DIR/$CALENDAR_USER" chmod g+ws "$DIR/$CALENDAR_USER" # Group privileges should already be set. done + +if [ "$STORE_TYPE" = "file" ]; then + for DIR in "$INSTALL_DIR"/store "$INSTALL_DIR"/journal ; do + mkdir -p "$DIR/$CALENDAR_USER" + chown "$USER" "$DIR/$CALENDAR_USER" + chmod g+ws "$DIR/$CALENDAR_USER" + # Group privileges should already be set. + done +fi diff -r 31d839d508f6 -r 54e1af14f1a2 tools/install.sh --- a/tools/install.sh Thu Mar 10 01:43:31 2016 +0100 +++ b/tools/install.sh Fri Mar 11 01:33:45 2016 +0100 @@ -89,7 +89,7 @@ # Tools -TOOLS="fix.sh init.sh init_user.sh make_freebusy.py update_quotas.py update_scheduling_modules.py" +TOOLS="fix.sh init.sh init_user.sh make_freebusy.py set_quota_limit.py update_quotas.py update_scheduling_modules.py" if [ ! -e "$INSTALL_DIR/tools" ]; then mkdir -p "$INSTALL_DIR/tools" diff -r 31d839d508f6 -r 54e1af14f1a2 tools/set_quota_limit.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/set_quota_limit.py Fri Mar 11 01:33:45 2016 +0100 @@ -0,0 +1,85 @@ +#!/usr/bin/env python + +""" +Set a quota limit for a user group. + +Copyright (C) 2016 Paul Boddie + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +""" + +from os.path import split +import sys + +# Find the modules. + +try: + import imiptools +except ImportError: + parent = split(split(__file__)[0])[0] + if split(parent)[1] == "imip-agent": + sys.path.append(parent) + +from imiptools import config +from imiptools.stores import get_journal + +# Main program. + +if __name__ == "__main__": + + # Interpret the command line arguments. + + args = [] + store_type = [] + journal_dir = [] + + # Collect quota details first, switching to other arguments when encountering + # switches. + + l = args + + for arg in sys.argv[1:]: + if arg == "-T": + l = store_type + elif arg == "-j": + l = journal_dir + else: + l.append(arg) + + try: + quota, group, limit = args + except ValueError: + print >>sys.stderr, """\ +Usage: %s [ ] + +General options: + +-j Indicates the journal directory location +-T Indicates the store type (the configured value if omitted) +""" % split(sys.argv[0])[1] + sys.exit(1) + + # Override defaults if indicated. + + getvalue = lambda value, default=None: value and value[0] or default + + store_type = getvalue(store_type, config.STORE_TYPE) + journal_dir = getvalue(journal_dir) + + # Obtain store-related objects. + + journal = get_journal(store_type, journal_dir) + journal.set_limit(quota, group, limit) + +# vim: tabstop=4 expandtab shiftwidth=4