deniskuzZ commented on code in PR #6327: URL: https://github.com/apache/hive/pull/6327#discussion_r2911070415
########## itests/qtest-iceberg/src/test/java/org/apache/hadoop/hive/cli/TestStandaloneRESTCatalogServerJwtAuth.java: ########## @@ -0,0 +1,224 @@ +/* + * 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.hadoop.hive.cli; + +import java.io.IOException; + +import org.apache.hadoop.conf.Configuration; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars; +import org.apache.iceberg.rest.extension.OAuth2AuthorizationServer; +import org.apache.iceberg.rest.standalone.StandaloneRESTCatalogServer; +import org.junit.AfterClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.context.ApplicationContextInitializer; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.core.annotation.Order; +import org.springframework.core.Ordered; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestContext; +import org.springframework.test.context.TestExecutionListener; +import org.springframework.test.context.TestExecutionListeners; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * Integration test for Standalone REST Catalog Server with JWT authentication. + * + * Uses Keycloak (via Testcontainers) as the real OIDC server - matching the design of + * existing OAuth2 tests (TestRESTCatalogOAuth2Jwt). Verifies that the standalone server correctly + * enforces JWT auth. + * + * <p>Requires Docker to be available (Testcontainers starts Keycloak in a container). + * + * <p>Verifies: + * - Accepts valid JWT tokens from Keycloak + * - Rejects invalid/malformed tokens + * - Rejects requests without a Bearer token + */ +@RunWith(SpringRunner.class) +@SpringBootTest( + classes = BaseStandaloneRESTCatalogServerTest.TestRestCatalogApplication.class, + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = { + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration" + } +) +@ContextConfiguration(initializers = TestStandaloneRESTCatalogServerJwtAuth.RestCatalogJwtTestContextInitializer.class) +@TestExecutionListeners( + listeners = { + BaseStandaloneRESTCatalogServerTest.HmsStartupListener.class, + TestStandaloneRESTCatalogServerJwtAuth.KeycloakStartupListener.class + }, + mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS +) +public class TestStandaloneRESTCatalogServerJwtAuth extends BaseStandaloneRESTCatalogServerTest { Review Comment: should it be public? -- 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]
