hemasrishalini commented on code in PR #4638:
URL: https://github.com/apache/polaris/pull/4638#discussion_r3407566292


##########
runtime/service/src/test/java/org/apache/polaris/service/catalog/common/CatalogUtilsTest.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.service.catalog.common;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
+import java.util.Set;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.iceberg.exceptions.ForbiddenException;
+import org.apache.polaris.core.config.FeatureConfiguration;
+import org.apache.polaris.core.config.RealmConfig;
+import org.apache.polaris.core.persistence.PolarisResolvedPathWrapper;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+public class CatalogUtilsTest {
+
+  @ParameterizedTest
+  @ValueSource(strings = {"file:/tmp/test", "http://example.com/table"})
+  public void testRejectLocationsWhenFileStorageDisabled(String location) {
+    RealmConfig realmConfig = mock(RealmConfig.class);
+    
when(realmConfig.getConfig(FeatureConfiguration.SUPPORTED_CATALOG_STORAGE_TYPES))
+        .thenReturn(List.of("S3"));
+
+    PolarisResolvedPathWrapper resolvedStorageEntity = 
mock(PolarisResolvedPathWrapper.class);
+    when(resolvedStorageEntity.getRawFullPath()).thenReturn(List.of());
+
+    Assertions.assertThatThrownBy(
+            () ->
+                CatalogUtils.validateLocationsForTableLike(

Review Comment:
   @dimas-b Thanks for reviewing.
   
   You're right that these locations would normally be validated earlier 
through PolarisServiceImpl.validateStorageConfig() and related checks.
   
   My intention was to add coverage for the defensive validation that still 
exists in CatalogUtils.validateLocationsForTableLike(), since the method 
explicitly rejects file: and http: locations when FILE storage is not enabled. 
I thought it would help guard against regressions if the validation flow 
changes in the future.
   
   That said, I understand the concern about the practical value of this path 
and am happy to follow your recommendation if you think this test isn't needed.



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