ctubbsii commented on code in PR #5334:
URL: https://github.com/apache/accumulo/pull/5334#discussion_r1985717241


##########
test/src/main/java/org/apache/accumulo/test/functional/CloneTestIT.java:
##########
@@ -350,4 +353,64 @@ public void testCloneMetadataTable() {
           "mc1", CloneConfiguration.empty()));
     }
   }
+
+  @Test
+  public void testCloneIntoDiffNamespace() throws Exception {
+    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+      String tableName = getUniqueNames(1)[0];
+      client.tableOperations().create(tableName);
+      client.namespaceOperations().create("new");
+      client.tableOperations().clone(tableName, "new." + tableName, 
CloneConfiguration.empty());
+    }
+  }
+
+  @Test
+  public void testCloneIntoDiffNamespaceDoesntExist() throws Exception {
+    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+      String tableName = getUniqueNames(1)[0];
+      client.tableOperations().create(tableName);
+      assertThrows(AccumuloException.class, () -> 
client.tableOperations().clone(tableName,
+          "missing." + tableName, CloneConfiguration.empty()));
+    }
+  }
+
+  @Test
+  public void testCloneIntoAccumuloNamespace() throws Exception {
+    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+      String tableName = getUniqueNames(1)[0];
+      client.tableOperations().create(tableName);
+      assertThrows(AccumuloException.class, () -> 
client.tableOperations().clone(tableName,
+          "accumulo." + tableName, CloneConfiguration.empty()));
+    }
+  }
+
+  @Test
+  public void testCloneNamespacePermissions() throws Exception {
+    final String tableName = getUniqueNames(1)[0];
+    final String newUserName = "NEW_USER";
+    final String srcNs = "src";
+    final String srcTableName = srcNs + "." + tableName;
+    final String destNs = "dst";
+    final String dstTableName = destNs + "." + tableName;
+
+    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+      client.namespaceOperations().create(srcNs);
+      client.tableOperations().create(srcTableName);
+      client.namespaceOperations().create(destNs);
+      client.securityOperations().createLocalUser(newUserName, new 
PasswordToken(newUserName));
+      // User needs WRITE or ALTER_TABLE on the src table to flush it as part 
of the clone operation
+      client.securityOperations().grantTablePermission(newUserName, 
srcTableName,
+          TablePermission.ALTER_TABLE);
+      client.securityOperations().grantTablePermission(newUserName, 
srcTableName,
+          TablePermission.READ);

Review Comment:
   I copied the test to 2.1 myself and it failed on the assertThrows... (the 
clone succeeded with the wrong permissions). I'm not sure why it would succeed 
for you, but I've tried several times, and am certain that I'm on the 2.1 
branch without your fixes, and the test fails.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to