diff options
author | Alan Conway <aconway@apache.org> | 2009-03-10 16:20:39 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2009-03-10 16:20:39 +0000 |
commit | b608df3ed3bd2b78449afa7be569dfc5cb2bcbcb (patch) | |
tree | bd9cdf44f1108b16ea18b2d42b4e76fbd63d431f /qpid/cpp/src/tests/cluster_test.cpp | |
parent | f16dd471baba1e3c531aac2430e9836b96ff4df7 (diff) | |
download | qpid-python-b608df3ed3bd2b78449afa7be569dfc5cb2bcbcb.tar.gz |
Added cluster ACL test, disabled for now as it exposes a memory leak in the SASL client.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@752154 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/cluster_test.cpp')
-rw-r--r-- | qpid/cpp/src/tests/cluster_test.cpp | 83 |
1 files changed, 48 insertions, 35 deletions
diff --git a/qpid/cpp/src/tests/cluster_test.cpp b/qpid/cpp/src/tests/cluster_test.cpp index 2ff52c1709..eee2df58cc 100644 --- a/qpid/cpp/src/tests/cluster_test.cpp +++ b/qpid/cpp/src/tests/cluster_test.cpp @@ -160,43 +160,56 @@ vector<string> browse(Client& c, const string& q, int n) { return result; } +ConnectionSettings aclSettings(int port, const std::string& id) { + ConnectionSettings settings; + settings.port = port; + settings.mechanism = "PLAIN"; + settings.username = id; + settings.password = id; + return settings; +} + +#if 0 +// FIXME aconway 2009-03-10: This test passes but exposes a memory leak in the SASL client code. +// Enable it when the leak is fixed. + +QPID_AUTO_TEST_CASE(testAcl) { + ofstream policyFile("cluster_test.acl"); + // FIXME aconway 2009-02-12: guest -> qpidd? + policyFile << "acl allow foo@QPID create queue name=foo" << endl + << "acl allow foo@QPID create queue name=foo2" << endl + << "acl deny foo@QPID create queue name=bar" << endl + << "acl allow all all" << endl; + policyFile.close(); + char cwd[1024]; + BOOST_CHECK(::getcwd(cwd, sizeof(cwd))); + ClusterFixture cluster(2,-1, list_of<string> + ("--no-data-dir") + ("--auth=no") + ("--acl-file="+string(cwd)+"/cluster_test.acl") + ("--cluster-mechanism=PLAIN") + ("--cluster-username=cluster") + ("--cluster-password=cluster") + ("--load-module=../.libs/acl.so")); + + Client c0(aclSettings(cluster[0], "c0"), "c0"); + Client c1(aclSettings(cluster[1], "c1"), "c1"); + Client foo(aclSettings(cluster[1], "foo"), "foo"); + + foo.session.queueDeclare("foo"); + BOOST_CHECK_EQUAL(c0.session.queueQuery("foo").getQueue(), "foo"); + + BOOST_CHECK_THROW(foo.session.queueDeclare("bar"), framing::NotAllowedException); + BOOST_CHECK(c0.session.queueQuery("bar").getQueue().empty()); + BOOST_CHECK(c1.session.queueQuery("bar").getQueue().empty()); -// FIXME aconway 2009-02-12: need to figure out how to test this properly. -// Current problems: -// - all brokers share the same data-dir (set ACL without data dir?) -// - updater's user name not making it through to updatee for ACL checks. -// -// QPID_AUTO_TEST_CASE(testAcl) { -// ofstream policyFile("cluster_test.acl"); -// // FIXME aconway 2009-02-12: guest -> qpidd? -// policyFile << "acl allow guest@QPID all all" << endl -// << "acl allow foo@QPID create queue name=foo" << endl -// << "acl allow bar@QPID create queue name=bar" << endl -// << "acl deny all create queue" << endl -// << "acl allow all all" << endl; -// policyFile.close(); -// ClusterFixture cluster(2,-1, list_of<string> -// ("--data-dir=.") ("--auth=no") -// ("--acl-file=cluster_test.acl") -// ("--cluster-mechanism=PLAIN") -// ("--load-module=../.libs/acl.so")); -// Client c0(cluster[0], "c0"); -// Client c1(cluster[1], "c1"); - -// ConnectionSettings settings; -// settings.port = cluster[0]; -// settings.username = "foo"; -// Client foo(settings, "foo"); - -// foo.session.queueDeclare("foo"); -// BOOST_CHECK_EQUAL(c0.session.queueQuery("foo").getQueue(), "foo"); -// BOOST_CHECK_EQUAL(c1.session.queueQuery("foo").getQueue(), "foo"); - -// BOOST_CHECK_THROW(foo.session.queueDeclare("bar"), int); -// BOOST_CHECK_EQUAL(c0.session.queueQuery("bar").getQueue(), ""); -// BOOST_CHECK_EQUAL(c1.session.queueQuery("bar").getQueue(), ""); -// } + cluster.add(); + Client c2(aclSettings(cluster[2], "c2"), "c2"); + BOOST_CHECK_THROW(foo.session.queueDeclare("bar"), framing::NotAllowedException); + BOOST_CHECK(c2.session.queueQuery("bar").getQueue().empty()); +} +#endif QPID_AUTO_TEST_CASE(testMessageTimeToLive) { // Note: this doesn't actually test for cluster race conditions around TTL, |