From notifications-return-2145-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Fri Oct 4 15:22:26 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 7BAD7180651 for ; Fri, 4 Oct 2019 17:22:26 +0200 (CEST) Received: (qmail 90120 invoked by uid 500); 4 Oct 2019 15:22:25 -0000 Mailing-List: contact notifications-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list notifications@zookeeper.apache.org Received: (qmail 90106 invoked by uid 99); 4 Oct 2019 15:22:25 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Oct 2019 15:22:25 +0000 From: GitBox To: notifications@zookeeper.apache.org Subject: [GitHub] [zookeeper] suhasdantkale commented on a change in pull request #1107: ZOOKEEPER-2122: add SSL support for C-client Message-ID: <157020254576.7990.9056581274218188835.gitbox@gitbox.apache.org> Date: Fri, 04 Oct 2019 15:22:25 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit suhasdantkale commented on a change in pull request #1107: ZOOKEEPER-2122: add SSL support for C-client URL: https://github.com/apache/zookeeper/pull/1107#discussion_r331557576 ########## File path: zookeeper-client/zookeeper-client-c/tests/TestReadOnlyClient.cc ########## @@ -81,29 +85,68 @@ class Zookeeper_readOnly : public CPPUNIT_NS::TestFixture { CPPUNIT_ASSERT(system(cmd) == 0); } - void testReadOnly() { - startReadOnly(); - watchctx_t watch; - zhandle_t* zh = zookeeper_init("localhost:22181", - watcher, - 10000, - NULL, - &watch, - ZOO_READONLY); - watch.zh = zh; + zhandle_t* connectReadOnly(const char *address, watchctx_t *watch) { + zhandle_t* zh = zookeeper_init(address, watcher, 10000, NULL, watch, ZOO_READONLY); + watch->zh = zh; CPPUNIT_ASSERT(zh != 0); sleep(1); + return zh; + } + + void assertCanRead(zhandle_t* zh, const char *znode_path) { int len = 1024; char buf[len]; - int res = zoo_get(zh, "/", 0, buf, &len, 0); + int res = zoo_get(zh, znode_path, 0, buf, &len, 0); CPPUNIT_ASSERT_EQUAL((int)ZOK, res); + } + void assertCanNotWrite(zhandle_t* zh, const char *znode_path) { char path[1024]; - res = zoo_create(zh, "/test", buf, 10, &ZOO_OPEN_ACL_UNSAFE, 0, path, - 512); + char buf[1024]; + int res = zoo_create(zh, znode_path, buf, 10, &ZOO_OPEN_ACL_UNSAFE, 0, path, 512); CPPUNIT_ASSERT_EQUAL((int)ZNOTREADONLY, res); + } + + void testReadOnly() + { + startReadOnly(); + + watchctx_t watch; + zhandle_t* zh = connectReadOnly("localhost:22181", &watch); + + assertCanRead(zh, "/"); + + assertCanNotWrite(zh, "/test"); + + stopPeer(); + } + +#ifdef HAVE_OPENSSL_H + + zhandle_t* connectReadOnlySSL(const char *address, const char *certs, watchctx_t *watch) { + zhandle_t* zh = zookeeper_init_ssl(address, certs, watcher, 10000, NULL, watch, ZOO_READONLY); + watch->zh = zh; + CPPUNIT_ASSERT(zh != 0); + sleep(1); + return zh; + } + + void testReadOnlyWithSSL() { Review comment: Good to see this test being added. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services