You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kp...@apache.org on 2009/10/29 14:20:08 UTC
svn commit: r830930 - in /qpid/trunk/qpid:
cpp/src/qpid/broker/SessionAdapter.cpp python/tests_0-10/exchange.py
Author: kpvdr
Date: Thu Oct 29 13:20:07 2009
New Revision: 830930
URL: http://svn.apache.org/viewvc?rev=830930&view=rev
Log:
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.
Modified:
qpid/trunk/qpid/cpp/src/qpid/broker/SessionAdapter.cpp
qpid/trunk/qpid/python/tests_0-10/exchange.py
Modified: qpid/trunk/qpid/cpp/src/qpid/broker/SessionAdapter.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/SessionAdapter.cpp?rev=830930&r1=830929&r2=830930&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/SessionAdapter.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/SessionAdapter.cpp Thu Oct 29 13:20:07 2009
@@ -85,8 +85,8 @@
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);
Modified: qpid/trunk/qpid/python/tests_0-10/exchange.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/tests_0-10/exchange.py?rev=830930&r1=830929&r2=830930&view=diff
==============================================================================
--- qpid/trunk/qpid/python/tests_0-10/exchange.py (original)
+++ qpid/trunk/qpid/python/tests_0-10/exchange.py Thu Oct 29 13:20:07 2009
@@ -269,30 +269,49 @@
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):
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org