diff options
| author | Charles E. Rolke <chug@apache.org> | 2012-08-24 15:24:07 +0000 |
|---|---|---|
| committer | Charles E. Rolke <chug@apache.org> | 2012-08-24 15:24:07 +0000 |
| commit | 3196cc6e0e4f6c537ab7f3694d7b2e454cd97fbc (patch) | |
| tree | 560947ad9908a5dc0731ff1b43f00f32d29eaf8c /qpid/cpp/src/tests | |
| parent | f529f73bc691aa622ab6af34cbbda84301baa6a1 (diff) | |
| download | qpid-python-3196cc6e0e4f6c537ab7f3694d7b2e454cd97fbc.tar.gz | |
QPID-2393 Limit number of queues per user.
Merge work from branches/qpid-2393
This scheme works for old HA as long as cluster members run with the same --max-queues-per-user setting.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1376961 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests')
| -rwxr-xr-x | qpid/cpp/src/tests/acl.py | 59 | ||||
| -rwxr-xr-x | qpid/cpp/src/tests/run_acl_tests | 16 |
2 files changed, 71 insertions, 4 deletions
diff --git a/qpid/cpp/src/tests/acl.py b/qpid/cpp/src/tests/acl.py index 102796cba6..180f848104 100755 --- a/qpid/cpp/src/tests/acl.py +++ b/qpid/cpp/src/tests/acl.py @@ -53,6 +53,9 @@ class ACLTests(TestBase010): def port_u(self): return int(self.defines["port-u"]) + def port_q(self): + return int(self.defines["port-q"]) + def get_session_by_port(self, user, passwd, byPort): socket = connect(self.broker.host, byPort) connection = Connection (sock=socket, username=user, password=passwd, @@ -2243,6 +2246,62 @@ class ACLTests(TestBase010): self.LookupPublish("joe@QPID", "QPID-work", "QPID", "allow") self.LookupPublish("joe@QPID", "QPID-work2", "QPID", "allow") + #===================================== + # Queue per-user quota + #===================================== + + def test_queue_per_user_quota(self): + """ + Test ACL queue counting limits. + port_q has a limit of 2 + """ + # bob should be able to create two queues + session = self.get_session_by_port('bob','bob', self.port_q()) + + try: + session.queue_declare(queue="queue1") + session.queue_declare(queue="queue2") + except qpid.session.SessionException, e: + self.fail("Error during queue create request"); + + # third queue should fail + try: + session.queue_declare(queue="queue3") + self.fail("Should not be able to create third queue") + except Exception, e: + result = None + session = self.get_session_by_port('bob','bob', self.port_q()) + + # alice should be able to create two queues + session2 = self.get_session_by_port('alice','alice', self.port_q()) + + try: + session2.queue_declare(queue="queuea1") + session2.queue_declare(queue="queuea2") + except qpid.session.SessionException, e: + self.fail("Error during queue create request"); + + # third queue should fail + try: + session2.queue_declare(queue="queuea3") + self.fail("Should not be able to create third queue") + except Exception, e: + result = None + session2 = self.get_session_by_port('alice','alice', self.port_q()) + + # bob should be able to delete a queue and create another + try: + session.queue_delete(queue="queue1") + session.queue_declare(queue="queue3") + except qpid.session.SessionException, e: + self.fail("Error during queue create request"); + + # alice should be able to delete a queue and create another + try: + session2.queue_delete(queue="queuea1") + session2.queue_declare(queue="queuea3") + except qpid.session.SessionException, e: + self.fail("Error during queue create request"); class BrokerAdmin: def __init__(self, broker, username=None, password=None): diff --git a/qpid/cpp/src/tests/run_acl_tests b/qpid/cpp/src/tests/run_acl_tests index 25241ad75e..d4d0d74e00 100755 --- a/qpid/cpp/src/tests/run_acl_tests +++ b/qpid/cpp/src/tests/run_acl_tests @@ -24,22 +24,26 @@ source ./test_env.sh DATA_DIR=`pwd`/data_dir DATA_DIRI=`pwd`/data_diri DATA_DIRU=`pwd`/data_diru +DATA_DIRQ=`pwd`/data_dirq trap stop_brokers INT TERM QUIT start_brokers() { - ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIR --load-module $ACL_LIB --acl-file policy.acl --auth no --log-to-file local.log > qpidd.port + ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIR --load-module $ACL_LIB --acl-file policy.acl --auth no --log-to-file local.log > qpidd.port LOCAL_PORT=`cat qpidd.port` - ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIRI --load-module $ACL_LIB --acl-file policy.acl --auth no --max-connections-per-ip 2 --log-to-file locali.log > qpiddi.port + ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIRI --load-module $ACL_LIB --acl-file policy.acl --auth no --max-connections-per-ip 2 --log-to-file locali.log > qpiddi.port LOCAL_PORTI=`cat qpiddi.port` ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIRU --load-module $ACL_LIB --acl-file policy.acl --auth no --max-connections-per-user 2 --log-to-file localu.log > qpiddu.port LOCAL_PORTU=`cat qpiddu.port` + ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIRQ --load-module $ACL_LIB --acl-file policy.acl --auth no --max-queues-per-user 2 --log-to-file localq.log > qpiddq.port + LOCAL_PORTQ=`cat qpiddq.port` } stop_brokers() { $QPIDD_EXEC --no-module-dir -q --port $LOCAL_PORT $QPIDD_EXEC --no-module-dir -q --port $LOCAL_PORTI $QPIDD_EXEC --no-module-dir -q --port $LOCAL_PORTU + $QPIDD_EXEC --no-module-dir -q --port $LOCAL_PORTQ } test_loading_acl_from_absolute_path(){ @@ -59,20 +63,24 @@ if test -d ${PYTHON_DIR} ; then rm -rf $DATA_DIR rm -rf $DATA_DIRI rm -rf $DATA_DIRU + rm -rf $DATA_DIRQ mkdir -p $DATA_DIR mkdir -p $DATA_DIRI mkdir -p $DATA_DIRU + mkdir -p $DATA_DIRQ cp $srcdir/policy.acl $DATA_DIR cp $srcdir/policy.acl $DATA_DIRI cp $srcdir/policy.acl $DATA_DIRU + cp $srcdir/policy.acl $DATA_DIRQ start_brokers - echo "Running acl tests using brokers on ports $LOCAL_PORT, $LOCAL_PORTI, and $LOCAL_PORTU" - $QPID_PYTHON_TEST -b localhost:$LOCAL_PORT -m acl -Dport-i=$LOCAL_PORTI -Dport-u=$LOCAL_PORTU || EXITCODE=1 + echo "Running acl tests using brokers on ports $LOCAL_PORT, $LOCAL_PORTI, $LOCAL_PORTU, and $LOCAL_PORTQ" + $QPID_PYTHON_TEST -b localhost:$LOCAL_PORT -m acl -Dport-i=$LOCAL_PORTI -Dport-u=$LOCAL_PORTU -Dport-q=$LOCAL_PORTQ || EXITCODE=1 stop_brokers || EXITCODE=1 test_loading_acl_from_absolute_path || EXITCODE=1 rm -rf $DATA_DIR rm -rf $DATA_DIRI rm -rf $DATA_DIRU + rm -rf $DATA_DIRQ exit $EXITCODE fi |
