Copilot commented on code in PR #6810:
URL: https://github.com/apache/hive/pull/6810#discussion_r4068985041
##########
itests/qtest-iceberg/src/test/java/org/apache/hadoop/hive/cli/BaseStandaloneRESTCatalogServerTest.java:
##########
@@ -116,10 +116,24 @@ public void beforeTestClass(TestContext testContext)
throws Exception {
MetastoreConf.setVar(hmsConf, ConfVars.WAREHOUSE,
warehouseDir.getAbsolutePath());
MetastoreConf.setVar(hmsConf, ConfVars.WAREHOUSE_EXTERNAL,
warehouseDir.getAbsolutePath());
+ configureTestSsl();
+
hmsPort = MetaStoreTestUtils.startMetaStoreWithRetry(
HadoopThriftAuthBridge.getBridge(), hmsConf, true, false, false,
false);
LOG.info("Started embedded HMS on port: {} (before Spring context)",
hmsPort);
}
+
+ /**
+ * Enables HTTPS for the standalone server using a test-only keystore.
+ */
+ private static void configureTestSsl() {
+ File keystore = new File("./itests/qtest-iceberg/src/test/resources",
"keystore.p12");
Review Comment:
When Maven runs this module's Surefire fork, the working directory is the
module base directory (`itests/qtest-iceberg`), so this relative path resolves
to `itests/qtest-iceberg/itests/qtest-iceberg/src/test/resources/keystore.p12`,
which does not exist. The Spring context will then fail while trying to load
the test keystore; resolve the resource from the test classpath or from the
module base directory instead.
##########
standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/standalone/SslConfigurationValidator.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.iceberg.rest.standalone;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.springframework.boot.autoconfigure.web.ServerProperties;
+import org.springframework.boot.web.server.Ssl;
+import org.springframework.stereotype.Component;
+
+/**
+ * Rejects startup when TLS is enabled without an operator-supplied keystore
on disk.
+ */
+@Component
+public class SslConfigurationValidator {
+
+ SslConfigurationValidator(ServerProperties serverProperties) {
+ validate(serverProperties.getSsl());
+ }
+
+ private static void validate(Ssl ssl) {
+ if (ssl == null || !ssl.isEnabled()) {
+ return;
+ }
+ String keyStore = ssl.getKeyStore();
+ if (keyStore == null || keyStore.isBlank()) {
+ throw new IllegalStateException(
+ "server.ssl.enabled=true requires server.ssl.key-store to point at
an operator-managed "
+ + "keystore file (e.g.
--server.ssl.key-store=file:/etc/ssl/catalog.p12)");
+ }
+ if (keyStore.regionMatches(true, 0, "classpath:", 0,
"classpath:".length())) {
+ throw new IllegalStateException(
+ "server.ssl.key-store must not use classpath: " + keyStore
+ + ". Supply an operator-managed file path instead.");
+ }
+ if (!isManagedKeystoreLocation(keyStore)) {
Review Comment:
The new rejection branches are not covered by a focused test: the
integration setup only supplies a valid absolute-path keystore. Add tests for
the missing keystore, `classpath:`, and relative-location cases (and the
disabled default), otherwise a regression in the guard that prevents bundled
TLS configuration can pass unnoticed.
##########
standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/standalone/SslConfigurationValidator.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.iceberg.rest.standalone;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.springframework.boot.autoconfigure.web.ServerProperties;
+import org.springframework.boot.web.server.Ssl;
+import org.springframework.stereotype.Component;
+
+/**
+ * Rejects startup when TLS is enabled without an operator-supplied keystore
on disk.
+ */
+@Component
+public class SslConfigurationValidator {
+
+ SslConfigurationValidator(ServerProperties serverProperties) {
+ validate(serverProperties.getSsl());
+ }
+
+ private static void validate(Ssl ssl) {
+ if (ssl == null || !ssl.isEnabled()) {
+ return;
+ }
+ String keyStore = ssl.getKeyStore();
+ if (keyStore == null || keyStore.isBlank()) {
+ throw new IllegalStateException(
+ "server.ssl.enabled=true requires server.ssl.key-store to point at
an operator-managed "
+ + "keystore file (e.g.
--server.ssl.key-store=file:/etc/ssl/catalog.p12)");
+ }
+ if (keyStore.regionMatches(true, 0, "classpath:", 0,
"classpath:".length())) {
+ throw new IllegalStateException(
+ "server.ssl.key-store must not use classpath: " + keyStore
+ + ". Supply an operator-managed file path instead.");
+ }
+ if (!isManagedKeystoreLocation(keyStore)) {
+ throw new IllegalStateException(
+ "server.ssl.key-store must be an absolute path or file: URL to an
managed "
Review Comment:
The new startup error message says “an managed”; change this to “a managed”
so the diagnostic is grammatically correct.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]