This is an automated email from the ASF dual-hosted git repository.
penghui pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-2.7 by this push:
new 8b7c81e [Functions-worker] Fix broker and functions-worker
authentication compatibility (#9190)
8b7c81e is described below
commit 8b7c81ef3a00a8c865021c634f4d8f4cb81a43ea
Author: Zixuan Liu <[email protected]>
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 <[email protected]>
* Add tests to check authentication compatibility
Signed-off-by: Zixuan Liu <[email protected]>
(cherry picked from commit 56ae93eecdb9f5978a5da43738ac914569c60394)
---
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 e1f675d..4dfcf58 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());
+ }
+}