[
https://issues.apache.org/jira/browse/CALCITE-2294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16483058#comment-16483058
]
ASF GitHub Bot commented on CALCITE-2294:
-----------------------------------------
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/calcite-avatica/pull/48#discussion_r189712478
--- Diff:
server/src/test/java/org/apache/calcite/avatica/server/CustomAuthHttpServerTest.java
---
@@ -0,0 +1,300 @@
+/*
+ * 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.calcite.avatica.server;
+
+import org.apache.calcite.avatica.ConnectionSpec;
+import org.apache.calcite.avatica.jdbc.JdbcMeta;
+import org.apache.calcite.avatica.remote.AuthenticationType;
+import org.apache.calcite.avatica.remote.Driver;
+import org.apache.calcite.avatica.remote.LocalService;
+
+import org.eclipse.jetty.security.ConstraintSecurityHandler;
+import org.eclipse.jetty.security.UserAuthentication;
+import org.eclipse.jetty.server.Authentication;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ServerConnector;
+import org.eclipse.jetty.server.UserIdentity;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.sql.SQLException;
+import javax.servlet.http.HttpServletRequest;
+
+import static org.hamcrest.core.StringContains.containsString;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+import java.util.Arrays;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+/**
+ * Test class for providing CustomAvaticaServerConfiguration to the HTTP
Server
+ */
+public class CustomAuthHttpServerTest extends HttpAuthBase {
+ private static final ConnectionSpec CONNECTION_SPEC =
ConnectionSpec.HSQLDB;
+ private static HttpServer server;
+ private static String url;
+
+ private static int methodCallCounter1 = 0;
+ private static int methodCallCounter2 = 0;
+ private static int methodCallCounter3 = 0;
+
+ @Before
+ public void before() throws SQLException {
+ methodCallCounter1 = 0;
+ methodCallCounter2 = 0;
+ methodCallCounter3 = 0;
+ }
+
+ @Test
+ public void testCustomImpersonationConfig() throws Exception {
+ final JdbcMeta jdbcMeta = new JdbcMeta(CONNECTION_SPEC.url,
+ CONNECTION_SPEC.username, CONNECTION_SPEC.password);
+ LocalService service = new LocalService(jdbcMeta);
+
+ server = new HttpServer.Builder()
+ .withCustomAuthentication(new CustomImpersonationConfig())
+ .withHandler(service, Driver.Serialization.PROTOBUF)
+ .withPort(0)
+ .build();
+ server.start();
--- End diff --
Ahh, sorry. I missed the After method hanging out at the bottom of the file.
I know it's nit-picky, but could you reorganize the class to be:
* setup/teardown methods
* test methods
* support inner-classes for tests
That's how we have the majority of tests organized now. Would be nice to
keep the style similar.
> Allow customization for AvaticaServerConfiguration for plugging new
> authentication mechanisms
> ---------------------------------------------------------------------------------------------
>
> Key: CALCITE-2294
> URL: https://issues.apache.org/jira/browse/CALCITE-2294
> Project: Calcite
> Issue Type: Improvement
> Components: avatica
> Reporter: Karan Mehta
> Priority: Major
>
> {{AvaticaServerConfiguration}} is currently only created if authentication
> mechanism such as {{BASIC, DIGEST or SPNEGO}} is provided. We can change it
> to a builder pattern to create this object and provide a way for users to
> plugin their own security configuration.
> An example here can be using it for custom config that supports MTLS.
> Thanks [~alexaraujo] for suggesting this approach.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)