{
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder();
CuratorFramework client = builder
.connectString(server.getConnectString())
.authorization("digest", "me:pass".getBytes())
.retryPolicy(new RetryOneTime(1))
.build();
client.start();
try
{
ACL acl = new ACL(ZooDefs.Perms.WRITE, ZooDefs.Ids.AUTH_IDS);
List<ACL> aclList = Lists.newArrayList(acl);
client.create().withACL(aclList).forPath("/test", "test".getBytes());
client.close();
client = builder
.connectString(server.getConnectString())
.authorization("digest", "me:pass".getBytes())
.retryPolicy(new RetryOneTime(1))
.build();
client.start();
try
{
client.setData().forPath("/test", "test".getBytes());
}
catch ( KeeperException.NoAuthException e )
{
Assert.fail("Auth failed");
}
client.close();
client = builder
.connectString(server.getConnectString())
.authorization("digest", "something:else".getBytes())
.retryPolicy(new RetryOneTime(1))
.build();
client.start();
try
{
client.setData().forPath("/test", "test".getBytes());