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

commit 11a96e8ea22e0afcf4e862b4fbe3d26300a0874d
Author: Matteo Merli <[email protected]>
AuthorDate: Wed Dec 2 17:14:51 2020 -0800

    [C++] Fixed flaky test: 
AuthPluginTest.testTlsDetectHttpsWithHostNameValidation (#8771)
    
    * [C++] Fixed flaky test: 
AuthPluginTest.testTlsDetectHttpsWithHostNameValidation
    
    * Fixed test assertion
    
    (cherry picked from commit b78b01c6718a45865a9146e415664c48d374b869)
---
 pulsar-client-cpp/tests/AuthPluginTest.cc | 34 +++++++++++++------------------
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/pulsar-client-cpp/tests/AuthPluginTest.cc 
b/pulsar-client-cpp/tests/AuthPluginTest.cc
index db7c8ee..2d7aa1d 100644
--- a/pulsar-client-cpp/tests/AuthPluginTest.cc
+++ b/pulsar-client-cpp/tests/AuthPluginTest.cc
@@ -171,26 +171,20 @@ TEST(AuthPluginTest, testTlsDetectHttps) {
 }
 
 TEST(AuthPluginTest, testTlsDetectHttpsWithHostNameValidation) {
-    try {
-        ClientConfiguration config = ClientConfiguration();
-        config.setUseTls(true);  // shouldn't be needed soon
-        config.setTlsTrustCertsFilePath(caPath);
-        config.setTlsAllowInsecureConnection(false);
-        config.setAuth(pulsar::AuthTls::create(clientPublicKeyPath, 
clientPrivateKeyPath));
-        config.setValidateHostName(true);
-
-        Client client(serviceUrlHttps, config);
-
-        std::string topicName = 
"persistent://private/auth/test-tls-detect-https";
-
-        Producer producer;
-        Promise<Result, Producer> producerPromise;
-        client.createProducerAsync(topicName, 
WaitForCallbackValue<Producer>(producerPromise));
-    } catch (const std::exception& ex) {
-        EXPECT_EQ(ex.what(), std::string("handshake: certificate verify 
failed"));
-    } catch (...) {
-        FAIL() << "Expected handshake: certificate verify failed";
-    }
+    ClientConfiguration config = ClientConfiguration();
+    config.setUseTls(true);  // shouldn't be needed soon
+    config.setTlsTrustCertsFilePath(caPath);
+    config.setTlsAllowInsecureConnection(false);
+    config.setAuth(pulsar::AuthTls::create(clientPublicKeyPath, 
clientPrivateKeyPath));
+    config.setValidateHostName(true);
+
+    Client client(serviceUrlHttps, config);
+
+    std::string topicName = 
"persistent://private/auth/test-tls-detect-https-with-hostname-validation";
+
+    Producer producer;
+    Result res = client.createProducer(topicName, producer);
+    ASSERT_NE(ResultOk, res);
 }
 
 namespace testAthenz {

Reply via email to