diff options
author | Kim van der Riet <kpvdr@apache.org> | 2009-10-29 13:20:07 +0000 |
---|---|---|
committer | Kim van der Riet <kpvdr@apache.org> | 2009-10-29 13:20:07 +0000 |
commit | 93e2dbae88c8960b82f46e499b5d91c20547702f (patch) | |
tree | af30241c5d49bfb1dcab3e7c1cbc1ed1700faa3f | |
parent | b59dc7fe0a39f24b00f7378e1edc2b707c74ddf8 (diff) | |
download | qpid-python-93e2dbae88c8960b82f46e499b5d91c20547702f.tar.gz |
Fix for QPID-2171 "No checks made for reserved exchange names "amq.*" and "qpid.*". This checkin adds the qpid check, r.830751 added the amq check. Python tests also inlcuded which checks for these prefixes.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@830930 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | cpp/src/qpid/broker/SessionAdapter.cpp | 4 | ||||
-rw-r--r-- | python/tests_0-10/exchange.py | 39 |
2 files changed, 31 insertions, 12 deletions
diff --git a/cpp/src/qpid/broker/SessionAdapter.cpp b/cpp/src/qpid/broker/SessionAdapter.cpp index 1a802cb2bd..5e5d79343a 100644 --- a/cpp/src/qpid/broker/SessionAdapter.cpp +++ b/cpp/src/qpid/broker/SessionAdapter.cpp @@ -85,8 +85,8 @@ void SessionAdapter::ExchangeHandlerImpl::declare(const string& exchange, const checkType(actual, type); checkAlternate(actual, alternate); }else{ - if(exchange.find("amq.") == 0) { - throw framing::NotAllowedException(QPID_MSG("Exchange names beginning with \"amq.\" are reserved. (exchange=\"" << exchange << "\")")); + if(exchange.find("amq.") == 0 || exchange.find("qpid.") == 0) { + throw framing::NotAllowedException(QPID_MSG("Exchange names beginning with \"amq.\" or \"qpid.\" are reserved. (exchange=\"" << exchange << "\")")); } try{ std::pair<Exchange::shared_ptr, bool> response = getBroker().getExchanges().declare(exchange, type, durable, args); diff --git a/python/tests_0-10/exchange.py b/python/tests_0-10/exchange.py index e2c84848f7..8d9713076d 100644 --- a/python/tests_0-10/exchange.py +++ b/python/tests_0-10/exchange.py @@ -269,30 +269,49 @@ class DeclareMethodExchangeFieldReservedRuleTests(TestHelper): standardised exchanges. The client MUST NOT attempt to create an exchange starting with "amq.". - + Similarly, exchanges starting with "qpid." are reserved for Qpid + implementation-specific system exchanges (such as the management exchange). + The client must not attempt to create an exchange starting with the string + "qpid.". """ - def test(self): + def template(self, reservedString, exchangeType): try: - self.session.exchange_declare(exchange="amq.", type="direct") - self.fail("Expected not allowed error (530) for exchanges starting with \"amq.\".") + self.session.exchange_declare(exchange=reservedString, type=exchangeType) + self.fail("Expected not allowed error (530) for exchanges starting with \"" + reservedString + "\".") except SessionException, e: self.assertEquals(e.args[0].error_code, 530) # connection closed, reopen it self.tearDown() self.setUp() try: - self.session.exchange_declare(exchange="amq.abc123", type="direct") - self.fail("Expected not allowed error (530) for exchanges starting with \"amq.\".") + self.session.exchange_declare(exchange=reservedString + "abc123", type=exchangeType) + self.fail("Expected not allowed error (530) for exchanges starting with \"" + reservedString + "\".") except SessionException, e: self.assertEquals(e.args[0].error_code, 530) # connection closed, reopen it self.tearDown() self.setUp() # The following should be legal: - self.session.exchange_declare(exchange="amq", type="direct") - self.session.exchange_declare(exchange=".amq.", type="direct") - self.session.exchange_declare(exchange="abc.amq.", type="direct") - self.session.exchange_declare(exchange="abc.amq.def", type="direct") + self.session.exchange_declare(exchange=reservedString[:-1], type=exchangeType) + self.session.exchange_delete(exchange=reservedString[:-1]) + self.session.exchange_declare(exchange=reservedString[1:], type=exchangeType) + self.session.exchange_delete(exchange=reservedString[1:]) + self.session.exchange_declare(exchange="." + reservedString, type=exchangeType) + self.session.exchange_delete(exchange="." + reservedString) + self.session.exchange_declare(exchange="abc." + reservedString, type=exchangeType) + self.session.exchange_delete(exchange="abc." + reservedString) + self.session.exchange_declare(exchange="abc." + reservedString + "def", type=exchangeType) + self.session.exchange_delete(exchange="abc." + reservedString + "def") + + def test_amq(self): + self.template("amq.", "direct") + self.template("amq.", "topic") + self.template("amq.", "fanout") + + def test_qpid(self): + self.template("qpid.", "direct") + self.template("qpid.", "topic") + self.template("qpid.", "fanout") class DeclareMethodTypeFieldTypedRuleTests(TestHelper): |