You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by lh...@apache.org on 2024/11/27 09:42:46 UTC

(pulsar) branch branch-4.0 updated (5dbc1fa02f9 -> 1ed79776b68)

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

lhotari pushed a change to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git


    from 5dbc1fa02f9 Release 4.0.1
     new f541ad94bb6 [improve][test] Reduce OneWayReplicatorUsingGlobalZKTest.testRemoveCluster execution time (#23633)
     new 0d3e4f61a70 [fix][misc] Class conflict during jetcd-core-shaded shading process (#23641)
     new 7412defa83a [fix][ws] Implement missing http header data functions in AuthenticationDataSubscription (#23638)
     new a2732b13cd7 [fix][client] Initializing client-authentication using configured auth params (#23610)
     new 1ed79776b68 [cleanup][build] skip generating pom.xml.versionsBackup (#23639)

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 jetcd-core-shaded/pom.xml                          |  4 ++
 .../AuthenticationDataSubscription.java            | 15 +++++++
 .../AuthenticationDataSubscriptionTest.java        | 48 ++++++++++++++++++++++
 .../pulsar/broker/service/BrokerServiceTest.java   | 45 ++++++++++++++++++++
 .../service/OneWayReplicatorUsingGlobalZKTest.java |  8 ++--
 .../pulsar/client/impl/ClientBuilderImpl.java      |  4 ++
 src/set-project-version.sh                         |  6 +--
 7 files changed, 124 insertions(+), 6 deletions(-)
 create mode 100644 pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationDataSubscriptionTest.java


(pulsar) 04/05: [fix][client] Initializing client-authentication using configured auth params (#23610)

Posted by lh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lhotari pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit a2732b13cd7d87f684311b355b2b62bd87088565
Author: Rajan Dhabalia <rd...@apache.org>
AuthorDate: Tue Nov 26 13:20:51 2024 -0800

    [fix][client] Initializing client-authentication using configured auth params (#23610)
    
    (cherry picked from commit 13f77aa5b09dc48cd1326096a3defc9394fedf67)
---
 .../pulsar/broker/service/BrokerServiceTest.java   | 45 ++++++++++++++++++++++
 .../pulsar/client/impl/ClientBuilderImpl.java      |  4 ++
 2 files changed, 49 insertions(+)

diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceTest.java
index e05bb836a3c..89727014be9 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceTest.java
@@ -103,6 +103,7 @@ import org.apache.pulsar.client.api.Schema;
 import org.apache.pulsar.client.api.SubscriptionInitialPosition;
 import org.apache.pulsar.client.api.SubscriptionMode;
 import org.apache.pulsar.client.api.SubscriptionType;
+import org.apache.pulsar.client.impl.ClientBuilderImpl;
 import org.apache.pulsar.client.impl.ClientCnx;
 import org.apache.pulsar.client.impl.ConnectionPool;
 import org.apache.pulsar.client.impl.PulsarServiceNameResolver;
@@ -1916,5 +1917,49 @@ public class BrokerServiceTest extends BrokerTestBase {
             }
         }
     }
+
+    @Test
+    public void testTlsWithAuthParams() throws Exception {
+        final String topicName = "persistent://prop/ns-abc/newTopic";
+        final String subName = "newSub";
+        Authentication auth;
+
+        Set<String> providers = new HashSet<>();
+        providers.add("org.apache.pulsar.broker.authentication.AuthenticationProviderTls");
+
+        conf.setAuthenticationEnabled(true);
+        conf.setAuthenticationProviders(providers);
+        conf.setBrokerServicePortTls(Optional.of(0));
+        conf.setWebServicePortTls(Optional.of(0));
+        conf.setTlsCertificateFilePath(BROKER_CERT_FILE_PATH);
+        conf.setTlsKeyFilePath(BROKER_KEY_FILE_PATH);
+        conf.setTlsAllowInsecureConnection(false);
+        conf.setTlsTrustCertsFilePath(CA_CERT_FILE_PATH);
+        conf.setNumExecutorThreadPoolSize(5);
+        restartBroker();
+
+        String authParam = String.format("tlsCertFile:%s,tlsKeyFile:%s", getTlsFileForClient("admin.cert"),
+                getTlsFileForClient("admin.key-pk8"));
+        String authClassName = "org.apache.pulsar.client.impl.auth.AuthenticationTls";
+        ClientConfigurationData conf = new ClientConfigurationData();
+        conf.setServiceUrl(brokerUrlTls.toString());
+        conf.setAuthParams(authParam);
+        conf.setAuthPluginClassName(authClassName);
+        conf.setTlsAllowInsecureConnection(true);
+
+        PulsarClient pulsarClient = null;
+        try {
+            pulsarClient = (new ClientBuilderImpl(conf)).build();
+
+            @Cleanup
+            Consumer<byte[]> consumer = pulsarClient.newConsumer().topic(topicName).subscriptionName(subName)
+                    .subscribe();
+        } catch (Exception e) {
+            fail("should not fail");
+        } finally {
+            pulsarClient.close();
+        }
+    }
+
 }
 
diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientBuilderImpl.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientBuilderImpl.java
index 69232186767..7652d8a4199 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientBuilderImpl.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientBuilderImpl.java
@@ -36,6 +36,7 @@ import org.apache.pulsar.client.api.PulsarClientException;
 import org.apache.pulsar.client.api.PulsarClientException.UnsupportedAuthenticationException;
 import org.apache.pulsar.client.api.ServiceUrlProvider;
 import org.apache.pulsar.client.api.SizeUnit;
+import org.apache.pulsar.client.impl.auth.AuthenticationDisabled;
 import org.apache.pulsar.client.impl.conf.ClientConfigurationData;
 import org.apache.pulsar.client.impl.conf.ConfigurationDataUtils;
 import org.apache.pulsar.common.tls.InetAddressUtils;
@@ -64,6 +65,9 @@ public class ClientBuilderImpl implements ClientBuilder {
                     "Cannot get service url from service url provider.");
             conf.setServiceUrl(conf.getServiceUrlProvider().getServiceUrl());
         }
+        if (conf.getAuthentication() == null || conf.getAuthentication() == AuthenticationDisabled.INSTANCE) {
+            setAuthenticationFromPropsIfAvailable(conf);
+        }
         PulsarClient client = new PulsarClientImpl(conf);
         if (conf.getServiceUrlProvider() != null) {
             conf.getServiceUrlProvider().initialize(client);


(pulsar) 02/05: [fix][misc] Class conflict during jetcd-core-shaded shading process (#23641)

Posted by lh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lhotari pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 0d3e4f61a70963600030c905e397b9e3b1d8ba1b
Author: 萧易客 <km...@live.com>
AuthorDate: Wed Nov 27 05:09:21 2024 +0800

    [fix][misc] Class conflict during jetcd-core-shaded shading process (#23641)
    
    (cherry picked from commit 3e108da4f136e9c0013c8030e496d00ea94bfd2c)
---
 jetcd-core-shaded/pom.xml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/jetcd-core-shaded/pom.xml b/jetcd-core-shaded/pom.xml
index 6595a6cdd32..2b9fb9acb16 100644
--- a/jetcd-core-shaded/pom.xml
+++ b/jetcd-core-shaded/pom.xml
@@ -94,6 +94,10 @@
                   <include>io.etcd:*</include>
                   <include>io.vertx:*</include>
                 </includes>
+                <excludes>
+                  <!-- This is required for execute shade multiple times without clean -->
+                  <exclude>org.apache.pulsar:jetcd-core-shaded</exclude>
+                </excludes>
               </artifactSet>
               <relocations>
                 <!-- relocate vertx packages since they will be transformed to use grpc-netty-shaded packages -->


(pulsar) 03/05: [fix][ws] Implement missing http header data functions in AuthenticationDataSubscription (#23638)

Posted by lh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lhotari pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 7412defa83a578f7ad146ee691391720c614af77
Author: Heesung Sohn <10...@users.noreply.github.com>
AuthorDate: Tue Nov 26 12:43:35 2024 -0800

    [fix][ws] Implement missing http header data functions in AuthenticationDataSubscription (#23638)
    
    (cherry picked from commit 81dfb439aeccb5d2d92b78905fdf400d7d183d18)
---
 .../AuthenticationDataSubscription.java            | 15 +++++++
 .../AuthenticationDataSubscriptionTest.java        | 48 ++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataSubscription.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataSubscription.java
index 9a7324a6d07..96b85989b6f 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataSubscription.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataSubscription.java
@@ -72,6 +72,21 @@ public class AuthenticationDataSubscription implements AuthenticationDataSource
         return subscription;
     }
 
+    @Override
+    public boolean hasDataFromHttp() {
+        return authData.hasDataFromHttp();
+    }
+
+    @Override
+    public String getHttpAuthType() {
+        return authData.getHttpAuthType();
+    }
+
+    @Override
+    public String getHttpHeader(String name) {
+        return authData.getHttpHeader(name);
+    }
+
     public AuthenticationDataSource getAuthData() {
         return authData;
     }
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationDataSubscriptionTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationDataSubscriptionTest.java
new file mode 100644
index 00000000000..8af7b87fd22
--- /dev/null
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationDataSubscriptionTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.broker.authentication;
+
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.testng.AssertJUnit.assertEquals;
+import javax.servlet.http.HttpServletRequest;
+import org.testng.annotations.Test;
+
+public class AuthenticationDataSubscriptionTest {
+
+    AuthenticationDataSubscription target;
+
+    @Test
+    public void testTargetFromAuthenticationDataHttp(){
+        var req = mock(HttpServletRequest.class);
+        String headerName = "Authorization";
+        String headerValue = "my-header";
+        String authType = "my-authType";
+        doReturn(headerValue).when(req).getHeader(eq(headerName));
+        doReturn("localhost").when(req).getRemoteAddr();
+        doReturn(4000).when(req).getRemotePort();
+        doReturn(authType).when(req).getAuthType();
+        AuthenticationDataSource authenticationDataSource = new AuthenticationDataHttp(req);
+        target = new AuthenticationDataSubscription(authenticationDataSource, "my-sub");
+        assertEquals(headerValue, target.getHttpHeader(headerName));
+        assertEquals(authType, target.getHttpAuthType());
+        assertEquals(true, target.hasDataFromHttp());
+    }
+}


(pulsar) 05/05: [cleanup][build] skip generating pom.xml.versionsBackup (#23639)

Posted by lh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lhotari pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 1ed79776b68e946cf9c5e1fc9aa77779df209706
Author: Hervé Boutemy <he...@free.fr>
AuthorDate: Wed Nov 27 08:33:31 2024 +0100

    [cleanup][build] skip generating pom.xml.versionsBackup (#23639)
    
    (cherry picked from commit dbfde02bd740d5a682575ee971e2eacc2b28b3d8)
---
 src/set-project-version.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/set-project-version.sh b/src/set-project-version.sh
index f3f01009b19..015b7f14cd9 100755
--- a/src/set-project-version.sh
+++ b/src/set-project-version.sh
@@ -36,9 +36,9 @@ pushd ${ROOT_DIR}
 # Get the current version
 OLD_VERSION=`python3 ${ROOT_DIR}/src/get-project-version.py`
 
-mvn versions:set -DnewVersion=$NEW_VERSION
-mvn versions:set -DnewVersion=$NEW_VERSION -pl buildtools
-mvn versions:set -DnewVersion=$NEW_VERSION -pl pulsar-bom
+mvn versions:set -DnewVersion=$NEW_VERSION -DgenerateBackupPoms=false
+mvn versions:set -DnewVersion=$NEW_VERSION -DgenerateBackupPoms=false -pl buildtools
+mvn versions:set -DnewVersion=$NEW_VERSION -DgenerateBackupPoms=false -pl pulsar-bom
 # Set terraform ansible deployment pulsar version
 sed -i -e "s/${OLD_VERSION}/${NEW_VERSION}/g" ${TERRAFORM_DIR}/deploy-pulsar.yaml
 


(pulsar) 01/05: [improve][test] Reduce OneWayReplicatorUsingGlobalZKTest.testRemoveCluster execution time (#23633)

Posted by lh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lhotari pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit f541ad94bb6ad2fc0f2666b313fc5e20475b3b7b
Author: Lari Hotari <lh...@users.noreply.github.com>
AuthorDate: Mon Nov 25 17:00:06 2024 +0200

    [improve][test] Reduce OneWayReplicatorUsingGlobalZKTest.testRemoveCluster execution time (#23633)
    
    (cherry picked from commit 2126d4016e43a21c044f2dd4f021fe7103ec83b0)
---
 .../pulsar/broker/service/OneWayReplicatorUsingGlobalZKTest.java  | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/OneWayReplicatorUsingGlobalZKTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/OneWayReplicatorUsingGlobalZKTest.java
index ad877e8f947..9287b451c2c 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/OneWayReplicatorUsingGlobalZKTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/OneWayReplicatorUsingGlobalZKTest.java
@@ -203,13 +203,15 @@ public class OneWayReplicatorUsingGlobalZKTest extends OneWayReplicatorTest {
         // The topics under the namespace of the cluster-1 will be deleted.
         // Verify the result.
         admin1.namespaces().setNamespaceReplicationClusters(ns1, new HashSet<>(Arrays.asList(cluster2)));
-        Awaitility.await().atMost(Duration.ofSeconds(120)).untilAsserted(() -> {
+        Awaitility.await().atMost(Duration.ofSeconds(60)).ignoreExceptions().untilAsserted(() -> {
             Map<String, CompletableFuture<Optional<Topic>>> tps = pulsar1.getBrokerService().getTopics();
             assertFalse(tps.containsKey(topic));
             assertFalse(tps.containsKey(topicChangeEvents));
-            assertFalse(pulsar1.getNamespaceService().checkTopicExists(TopicName.get(topic)).join().isExists());
+            assertFalse(pulsar1.getNamespaceService().checkTopicExists(TopicName.get(topic))
+                    .get(5, TimeUnit.SECONDS).isExists());
             assertFalse(pulsar1.getNamespaceService()
-                    .checkTopicExists(TopicName.get(topicChangeEvents)).join().isExists());
+                    .checkTopicExists(TopicName.get(topicChangeEvents))
+                    .get(5, TimeUnit.SECONDS).isExists());
         });
 
         // cleanup.