Skip to content

Commit

Permalink
UTs and ZK version bump required to test the change
Browse files Browse the repository at this point in the history
  • Loading branch information
pfcoperez committed Aug 31, 2024
1 parent 122d51a commit eccf215
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
package org.apache.curator.framework.imps;

import static org.apache.zookeeper.ZooDefs.Ids.ANYONE_ID_UNSAFE;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

import java.util.Collections;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -466,4 +465,33 @@ public void testProtectedUtils() throws Exception {
path = ZKPaths.makePath("hola", name);
assertEquals(ProtectedUtils.normalizePath(path), "/hola/yo");
}

/**
* Tests that parents existence checks don't need READ access to the whole path (from / to the new node)
* but just to the first ancestor parent. (See https://issues.apache.org/jira/browse/ZOOKEEPER-2590)
*/
@Test
public void testForbiddenAncestors() throws Exception {
CuratorFramework client = createClient(testACLProvider);
try {
client.start();

client.create().creatingParentsIfNeeded().forPath("/bat/bi/hiru");
client.setACL().withACL(Collections.singletonList(new ACL(0, ANYONE_ID_UNSAFE))).forPath("/bat");

// In creation attempts where the parent ("/bat") has ACL that restricts read, creation request fails.
try {
client.create().creatingParentsIfNeeded().forPath("/bat/bost");
fail("Expected NoAuthException when not authorized to read new node grandparent");
} catch(KeeperException.NoAuthException noAuthException) {
}

// But creating a node in the same subtree where its grandparent has read access is allowed and
// Curator will not check for higher nodes' existence.
client.create().creatingParentsIfNeeded().forPath("/bat/bi/hiru/bost");
assertNotNull(client.checkExists().forPath("/bat/bi/hiru/bost"));
} finally {
CloseableUtils.closeQuietly(client);
}
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<redirectTestOutputToFile>true</redirectTestOutputToFile>

<!-- versions -->
<zookeeper-version>3.9.1</zookeeper-version>
<zookeeper-version>3.9.2</zookeeper-version>
<maven-bundle-plugin-version>5.1.4</maven-bundle-plugin-version>
<maven-compiler-plugin-version>3.10.0</maven-compiler-plugin-version>
<maven-dependency-plugin-version>3.2.0</maven-dependency-plugin-version>
Expand Down

0 comments on commit eccf215

Please sign in to comment.