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<Session*>(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<Session*>(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;