You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2021/01/14 15:12:02 UTC

[pulsar] branch master updated: [Functions-worker] Fix broker and functions-worker authentication compatibility (#9190)

This is an automated email from the ASF dual-hosted git repository.

penghui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 56ae93e  [Functions-worker] Fix broker and functions-worker authentication compatibility (#9190)
56ae93e is described below

commit 56ae93eecdb9f5978a5da43738ac914569c60394
Author: Zixuan Liu <no...@gmail.com>
AuthorDate: Thu Jan 14 23:11:32 2021 +0800

    [Functions-worker] Fix broker and functions-worker authentication compatibility (#9190)
    
    * Fix broker and functions-worker authentication compatibility
    
    Signed-off-by: Zixuan Liu <no...@gmail.com>
    
    * Add tests to check authentication compatibility
    
    Signed-off-by: Zixuan Liu <no...@gmail.com>
---
 conf/functions_worker.yml                          |  3 +-
 .../pulsar/functions/config/TestWorkerConfig.java  | 52 ++++++++++++++++++++++
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/conf/functions_worker.yml b/conf/functions_worker.yml
index c15e829..ae98218 100644
--- a/conf/functions_worker.yml
+++ b/conf/functions_worker.yml
@@ -61,9 +61,10 @@ pulsarWebServiceUrl: http://localhost:8080
 ############################################
 # security settings for pulsar broker client
 ############################################
-brokerClientAuthenticationEnabled: false
 # The path to trusted certificates used by the Pulsar client to authenticate with Pulsar brokers
 # brokerClientTrustCertsFilePath:
+# Whether to enable the broker client authentication used by function workers to talk to brokers
+# brokerClientAuthenticationEnabled: false
 # the authentication plugin to be used by the pulsar client used in worker service
 # brokerClientAuthenticationPlugin:
 # the authentication parameter to be used by the pulsar client used in worker service
diff --git a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/config/TestWorkerConfig.java b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/config/TestWorkerConfig.java
new file mode 100644
index 0000000..5a78a17
--- /dev/null
+++ b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/config/TestWorkerConfig.java
@@ -0,0 +1,52 @@
+/**
+ * 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.pulsar.functions.config;
+
+import org.apache.pulsar.functions.worker.WorkerConfig;
+import org.junit.Assert;
+import org.testng.annotations.Test;
+
+public class TestWorkerConfig {
+    @Test
+    public void validateAuthenticationCompatibleWorkerConfig() {
+        WorkerConfig workerConfig = new WorkerConfig();
+
+        workerConfig.setAuthenticationEnabled(false);
+        Assert.assertFalse(workerConfig.isAuthenticationEnabled());
+        workerConfig.setBrokerClientAuthenticationEnabled(null);
+        Assert.assertFalse(workerConfig.isBrokerClientAuthenticationEnabled());
+
+        workerConfig.setAuthenticationEnabled(true);
+        Assert.assertTrue(workerConfig.isAuthenticationEnabled());
+        workerConfig.setBrokerClientAuthenticationEnabled(null);
+        Assert.assertTrue(workerConfig.isBrokerClientAuthenticationEnabled());
+
+        workerConfig.setBrokerClientAuthenticationEnabled(true);
+        workerConfig.setAuthenticationEnabled(false);
+        Assert.assertTrue(workerConfig.isBrokerClientAuthenticationEnabled());
+        workerConfig.setAuthenticationEnabled(true);
+        Assert.assertTrue(workerConfig.isBrokerClientAuthenticationEnabled());
+
+        workerConfig.setBrokerClientAuthenticationEnabled(false);
+        workerConfig.setAuthenticationEnabled(false);
+        Assert.assertFalse(workerConfig.isBrokerClientAuthenticationEnabled());
+        workerConfig.setAuthenticationEnabled(true);
+        Assert.assertFalse(workerConfig.isBrokerClientAuthenticationEnabled());
+    }
+}