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

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

commit e122f293d0feddc715a0fb0a3f07152e3c33adf8
Author: Lari Hotari <[email protected]>
AuthorDate: Thu Jun 1 23:07:11 2023 +0300

    [fix][test] Remove dependency on httpbin.org service in FunctionCommonTest 
(#20464)
    
    (cherry picked from commit a5f2d25e0f435fa8758904a0f71ceefceb8b5deb)
---
 pulsar-functions/utils/pom.xml                           |  9 ++++++++-
 .../pulsar/functions/utils/FunctionCommonTest.java       | 16 +++++++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/pulsar-functions/utils/pom.xml b/pulsar-functions/utils/pom.xml
index 305cd523e22..f9d4327c070 100644
--- a/pulsar-functions/utils/pom.xml
+++ b/pulsar-functions/utils/pom.xml
@@ -99,6 +99,13 @@
       <version>${project.version}</version>
     </dependency>
 
+    <dependency>
+      <groupId>com.github.tomakehurst</groupId>
+      <artifactId>wiremock-jre8</artifactId>
+      <version>${wiremock.version}</version>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
   <build>
     <plugins>
@@ -119,7 +126,7 @@
           </execution>
         </executions>
       </plugin>
-      
+
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-checkstyle-plugin</artifactId>
diff --git 
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/FunctionCommonTest.java
 
b/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/FunctionCommonTest.java
index 113824fc7c1..131f153b08d 100644
--- 
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/FunctionCommonTest.java
+++ 
b/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/FunctionCommonTest.java
@@ -18,12 +18,19 @@
  */
 package org.apache.pulsar.functions.utils;
 
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.configureFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.testng.Assert.assertEquals;
+import com.github.tomakehurst.wiremock.WireMockServer;
 import java.io.File;
 import java.util.Collection;
+import lombok.Cleanup;
 import org.apache.pulsar.client.impl.MessageIdImpl;
 import org.apache.pulsar.common.util.FutureUtil;
 import org.apache.pulsar.functions.api.Context;
@@ -87,7 +94,14 @@ public class FunctionCommonTest {
 
     @Test
     public void testDownloadFileWithBasicAuth() throws Exception {
-        final String jarHttpUrl = 
"https://foo:[email protected]/basic-auth/foo/bar";;
+        @Cleanup("stop")
+        WireMockServer server = new WireMockServer(0);
+        server.start();
+        configureFor(server.port());
+        stubFor(get(urlPathEqualTo("/"))
+                .withBasicAuth("foo", "bar")
+                .willReturn(aResponse().withBody("Hello 
world!").withStatus(200)));
+        final String jarHttpUrl = "http://foo:bar@localhost:"; + server.port() 
+ "/";
         final File file = Files.newTemporaryFile();
         file.deleteOnExit();
         assertThat(file.length()).isZero();

Reply via email to