Skip to content

Commit

Permalink
Update Table Id validator to accept all Accumulo tables (#5065)
Browse files Browse the repository at this point in the history
Fixes validation for table ids by making sure all tables in the accumulo
namespace are considered and not just root and metadata

This closes #5059
  • Loading branch information
cshannon authored Nov 15, 2024
1 parent e560e0e commit 4368f98
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public static Validator<String> sameNamespaceAs(String oldTableName) {
if (id == null) {
return Optional.of("Table id must not be null");
}
if (AccumuloTable.ROOT.tableId().equals(id) || AccumuloTable.METADATA.tableId().equals(id)
if (AccumuloTable.allTableIds().contains(id)
|| VALID_ID_PATTERN.matcher(id.canonical()).matches()) {
return Validator.OK;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import org.apache.accumulo.core.clientImpl.Namespace;
import org.apache.accumulo.core.data.TableId;
Expand Down Expand Up @@ -140,8 +142,9 @@ public void test_NOT_ROOT_TABLE_ID() {
public void test_VALID_TABLE_ID() {
Validator<TableId> v = Validators.VALID_TABLE_ID;
checkNull(v::validate);
assertAllValidate(v, List.of(AccumuloTable.ROOT.tableId(), AccumuloTable.METADATA.tableId(),
TableId.of("111"), TableId.of("aaaa"), TableId.of("r2d2")));
assertAllValidate(v, Arrays.stream(AccumuloTable.values()).map(AccumuloTable::tableId)
.collect(Collectors.toList()));
assertAllValidate(v, List.of(TableId.of("111"), TableId.of("aaaa"), TableId.of("r2d2")));
assertAllThrow(v, List.of(TableId.of(""), TableId.of("#0(U!$"), TableId.of(" #0(U!$. "),
TableId.of("."), TableId.of(" "), TableId.of("C3P0")));
}
Expand Down

0 comments on commit 4368f98

Please sign in to comment.