adutra commented on code in PR #5114:
URL: https://github.com/apache/polaris/pull/5114#discussion_r3615911854
##########
runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/AbstractLocalIcebergCatalogTest.java:
##########
@@ -2547,6 +2574,197 @@ public void testRegisterTableRejectsExistingView() {
.hasMessageContaining("View with same name already exists");
}
+ @ParameterizedTest
+ @ValueSource(booleans = {false, true})
+ public void
testRegisterTableRejectsMetadataFileOutsideAllowedLocations(boolean overwrite) {
+ LocalIcebergCatalog catalog = catalog();
+ Namespace namespace = Namespace.of("register_disallowed_metadata");
+ TableIdentifier table = TableIdentifier.of(namespace, "table");
+ if (requiresNamespaceCreate()) {
+ catalog.createNamespace(namespace);
+ }
+
+ String forbiddenMetadataLocation =
"s3://forbidden-bucket/table/metadata/v1.metadata.json";
+
+ Assertions.assertThatThrownBy(
+ () -> catalog.registerTable(table, forbiddenMetadataLocation,
overwrite))
+ .isInstanceOf(ForbiddenException.class)
+ .hasMessageContaining("Invalid location");
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {false, true})
+ public void
testRegisterTableRejectsTableLocationOutsideAllowedLocations(boolean overwrite)
{
+ LocalIcebergCatalog catalog = catalog();
+ Namespace namespace = Namespace.of("register_disallowed_table_location");
+ TableIdentifier table = TableIdentifier.of(namespace, "table");
+ if (requiresNamespaceCreate()) {
+ catalog.createNamespace(namespace);
+ }
+
+ // Metadata file is at an allowed location, but the table location
embedded inside it is not.
+ String metadataLocation =
+ STORAGE_LOCATION +
"/register_disallowed_table_location/table/metadata/v1.metadata.json";
+
+ fileIO.addFile(
+ metadataLocation,
+
TableMetadataParser.toJson(createSampleTableMetadata("s3://forbidden-bucket/table/"))
+ .getBytes(UTF_8));
+
+ Assertions.assertThatThrownBy(() -> catalog.registerTable(table,
metadataLocation, overwrite))
+ .isInstanceOf(ForbiddenException.class)
+ .hasMessageContaining("Invalid location");
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {false, true})
+ public void testRegisterTableRejectsMetadataFileOutsideTableLocation(boolean
overwrite) {
+ updateCatalogProperties(
+
Map.of(FeatureConfiguration.ALLOW_EXTERNAL_TABLE_LOCATION.catalogConfig(),
"false"));
Review Comment:
```suggestion
Map.of(FeatureConfiguration.ALLOW_EXTERNAL_METADATA_FILE_LOCATION.catalogConfig(),
"false"));
```
--
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]