You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2016/01/12 16:13:30 UTC
curator git commit: ZKPaths.mkdirs() was always passing the full path
to the aclProvider instead of the subpath being created
Repository: curator
Updated Branches:
refs/heads/CURATOR-244 [created] d6da90e8e
ZKPaths.mkdirs() was always passing the full path to the aclProvider instead of the subpath being created
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/d6da90e8
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/d6da90e8
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/d6da90e8
Branch: refs/heads/CURATOR-244
Commit: d6da90e8e746c92cc182e62a96fc2a9182fd1a15
Parents: 45332f3
Author: randgalt <ra...@apache.org>
Authored: Tue Jan 12 10:13:12 2016 -0500
Committer: randgalt <ra...@apache.org>
Committed: Tue Jan 12 10:13:12 2016 -0500
----------------------------------------------------------------------
.../java/org/apache/curator/utils/ZKPaths.java | 2 +-
.../framework/recipes/locks/TestLockACLs.java | 50 ++++++++++++++++----
2 files changed, 43 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/d6da90e8/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java
index 75e1171..17fa913 100644
--- a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java
+++ b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java
@@ -278,7 +278,7 @@ public class ZKPaths
List<ACL> acl = null;
if ( aclProvider != null )
{
- acl = aclProvider.getAclForPath(path);
+ acl = aclProvider.getAclForPath(subPath);
if ( acl == null )
{
acl = aclProvider.getDefaultAcl();
http://git-wip-us.apache.org/repos/asf/curator/blob/d6da90e8/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestLockACLs.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestLockACLs.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestLockACLs.java
index 2d9a9aa..b6159cc 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestLockACLs.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestLockACLs.java
@@ -26,7 +26,6 @@ import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.ACLProvider;
import org.apache.curator.retry.ExponentialBackoffRetry;
-import org.apache.curator.test.TestingServer;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Id;
@@ -37,16 +36,17 @@ import java.util.List;
public class TestLockACLs extends BaseClassForTests
{
- private static final List<ACL> ACLS = Collections.singletonList(new ACL(ZooDefs.Perms.ALL, new Id("ip", "127.0.0.1")));
+ private static final List<ACL> ACLS1 = Collections.singletonList(new ACL(ZooDefs.Perms.ALL, new Id("ip", "127.0.0.1")));
+ private static final List<ACL> ACLS2 = Collections.singletonList(new ACL(ZooDefs.Perms.CREATE, new Id("ip", "127.0.0.1")));
- private CuratorFramework createClient() throws Exception
+ private CuratorFramework createClient(ACLProvider provider) throws Exception
{
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
CuratorFramework client = CuratorFrameworkFactory.builder()
.namespace("ns")
.connectString(server.getConnectString())
.retryPolicy(retryPolicy)
- .aclProvider(new MyACLProvider())
+ .aclProvider(provider)
.build();
client.start();
return client;
@@ -55,7 +55,7 @@ public class TestLockACLs extends BaseClassForTests
@Test
public void testLockACLs() throws Exception
{
- CuratorFramework client = createClient();
+ CuratorFramework client = createClient(new TestLockACLsProvider());
try
{
client.create().forPath("/foo");
@@ -78,19 +78,53 @@ public class TestLockACLs extends BaseClassForTests
}
}
- public class MyACLProvider implements ACLProvider
+ @Test
+ public void testACLsCreatingParents() throws Exception
+ {
+ CuratorFramework client = createClient(new TestACLsCreatingParentsProvider());
+ try
+ {
+ client.create().creatingParentsIfNeeded().forPath("/parent/foo");
+ Assert.assertEquals(ZooDefs.Perms.CREATE, client.getACL().forPath("/parent").get(0).getPerms());
+ Assert.assertEquals(ZooDefs.Perms.ALL, client.getACL().forPath("/parent/foo").get(0).getPerms());
+ }
+ finally
+ {
+ CloseableUtils.closeQuietly(client);
+ }
+ }
+
+ private class TestACLsCreatingParentsProvider implements ACLProvider
{
+ @Override
+ public List<ACL> getDefaultAcl()
+ {
+ return ACLS1;
+ }
@Override
+ public List<ACL> getAclForPath(String path)
+ {
+ if ( path.equals("/ns/parent") )
+ {
+ return ACLS2;
+ }
+ return ACLS1;
+ }
+ }
+
+ private class TestLockACLsProvider implements ACLProvider
+ {
+ @Override
public List<ACL> getDefaultAcl()
{
- return ACLS;
+ return ACLS1;
}
@Override
public List<ACL> getAclForPath(String path)
{
- return ACLS;
+ return ACLS1;
}
}
}