From: Haomai Wang Date: Tue, 27 Jan 2015 15:13:07 +0000 (+0800) Subject: test_msgr: add auth enabled basic test X-Git-Tag: v0.93~136^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=77bd883bed1d4595a246c4558e3f7ef7184f3bd1;p=ceph.git test_msgr: add auth enabled basic test Signed-off-by: Haomai Wang --- diff --git a/src/test/msgr/test_msgr.cc b/src/test/msgr/test_msgr.cc index 85ad067978a9..7238b6aceefa 100644 --- a/src/test/msgr/test_msgr.cc +++ b/src/test/msgr/test_msgr.cc @@ -573,6 +573,57 @@ TEST_P(MessengerTest, ClientStandbyTest) { client_msgr->wait(); } +TEST_P(MessengerTest, AuthTest) { + g_ceph_context->_conf->set_val("auth_cluster_required", "cephx"); + g_ceph_context->_conf->set_val("auth_service_required", "cephx"); + g_ceph_context->_conf->set_val("auth_client_required", "cephx"); + FakeDispatcher cli_dispatcher(false), srv_dispatcher(true); + entity_addr_t bind_addr; + bind_addr.parse("127.0.0.1"); + server_msgr->bind(bind_addr); + server_msgr->add_dispatcher_head(&srv_dispatcher); + server_msgr->start(); + + client_msgr->add_dispatcher_head(&cli_dispatcher); + client_msgr->start(); + + // 1. simple auth round trip + MPing *m = new MPing(); + ConnectionRef conn = client_msgr->get_connection(server_msgr->get_myinst()); + { + ASSERT_EQ(conn->send_message(m), 0); + Mutex::Locker l(cli_dispatcher.lock); + while (!cli_dispatcher.got_new) + cli_dispatcher.cond.Wait(cli_dispatcher.lock); + cli_dispatcher.got_new = false; + } + ASSERT_TRUE(conn->is_connected()); + ASSERT_TRUE((static_cast(conn->get_priv()))->get_count() == 1); + + // 2. mix auth + g_ceph_context->_conf->set_val("auth_cluster_required", "none"); + g_ceph_context->_conf->set_val("auth_service_required", "none"); + g_ceph_context->_conf->set_val("auth_client_required", "none"); + conn->mark_down(); + ASSERT_FALSE(conn->is_connected()); + conn = client_msgr->get_connection(server_msgr->get_myinst()); + { + MPing *m = new MPing(); + ASSERT_EQ(conn->send_message(m), 0); + Mutex::Locker l(cli_dispatcher.lock); + while (!cli_dispatcher.got_new) + cli_dispatcher.cond.Wait(cli_dispatcher.lock); + cli_dispatcher.got_new = false; + } + ASSERT_TRUE(conn->is_connected()); + ASSERT_TRUE((static_cast(conn->get_priv()))->get_count() == 1); + + server_msgr->shutdown(); + client_msgr->shutdown(); + server_msgr->wait(); + client_msgr->wait(); +} + class SyntheticDispatcher : public Dispatcher { public: Mutex lock;