| 43 | |
| 44 | |
| 45 | TEST_F(ZooKeeperTest, Auth) |
| 46 | { |
| 47 | ZooKeeperTest::TestWatcher watcher; |
| 48 | |
| 49 | ZooKeeper authenticatedZk(server->connectString(), NO_TIMEOUT, &watcher); |
| 50 | watcher.awaitSessionEvent(ZOO_CONNECTED_STATE); |
| 51 | authenticatedZk.authenticate("digest", "creator:creator"); |
| 52 | authenticatedZk.create("/test", |
| 53 | "42", |
| 54 | zookeeper::EVERYONE_READ_CREATOR_ALL, |
| 55 | 0, |
| 56 | nullptr); |
| 57 | ASSERT_ZK_GET("42", &authenticatedZk, "/test"); |
| 58 | |
| 59 | ZooKeeper unauthenticatedZk(server->connectString(), NO_TIMEOUT, &watcher); |
| 60 | watcher.awaitSessionEvent(ZOO_CONNECTED_STATE); |
| 61 | ASSERT_ZK_GET("42", &unauthenticatedZk, "/test"); |
| 62 | ASSERT_EQ(ZNOAUTH, unauthenticatedZk.set("/test", "", -1)); |
| 63 | |
| 64 | ZooKeeper nonOwnerZk(server->connectString(), NO_TIMEOUT, &watcher); |
| 65 | watcher.awaitSessionEvent(ZOO_CONNECTED_STATE); |
| 66 | nonOwnerZk.authenticate("digest", "non-owner:non-owner"); |
| 67 | ASSERT_ZK_GET("42", &nonOwnerZk, "/test"); |
| 68 | ASSERT_EQ(ZNOAUTH, nonOwnerZk.set("/test", "", -1)); |
| 69 | } |
| 70 | |
| 71 | |
| 72 | TEST_F(ZooKeeperTest, SessionTimeoutNegotiation) |
nothing calls this directly
no test coverage detected