From 5798a28471012e3a49ccfafc122fff80a7da9e04 Mon Sep 17 00:00:00 2001 From: John Niang Date: Wed, 6 Jul 2022 15:44:12 +0800 Subject: [PATCH] Revert huaweicloud-sdk-java-obs from 3.21.8.1 to 3.21.4 (#2209) Signed-off-by: johnniang --- build.gradle | 2 +- .../app/handler/file/HuaweiObsSdkTest.java | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/test/java/run/halo/app/handler/file/HuaweiObsSdkTest.java diff --git a/build.gradle b/build.gradle index 8fc3976247..a4c0f5b0f4 100644 --- a/build.gradle +++ b/build.gradle @@ -70,7 +70,7 @@ ext { levelDbVersion = "0.12" annotationsVersion = "3.0.1u2" zxingVersion = '3.4.1' - huaweiObsVersion = '3.21.8.1' + huaweiObsVersion = '3.21.4' templateInheritanceVersion = "0.4.RELEASE" jsoupVersion = '1.14.3' embeddedRedisVersion = '0.6' diff --git a/src/test/java/run/halo/app/handler/file/HuaweiObsSdkTest.java b/src/test/java/run/halo/app/handler/file/HuaweiObsSdkTest.java new file mode 100644 index 0000000000..c842507385 --- /dev/null +++ b/src/test/java/run/halo/app/handler/file/HuaweiObsSdkTest.java @@ -0,0 +1,46 @@ +package run.halo.app.handler.file; + +import com.obs.services.internal.ObsProperties; +import com.obs.services.internal.RestConnectionService; +import com.obs.services.internal.ServiceException; +import com.obs.services.model.HttpMethodEnum; +import java.util.Map; +import okhttp3.Request; +import okhttp3.RequestBody; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class HuaweiObsSdkTest { + + /** + * See + * + * https://github.com/halo-dev/halo/issues/1909 + * + * for more. + */ + @Test + void shouldSetUpConnectionCorrectly() { + var connSvc = new RestConnectionService() { + + { + // We have to initialize the obsProperties, or we will get a NPE while setting up + // connection. + obsProperties = new ObsProperties(); + } + + @Override + public Request.Builder setupConnection(HttpMethodEnum method, String bucketName, + String objectKey, + Map requestParameters, + RequestBody body) throws ServiceException { + return super.setupConnection(method, bucketName, objectKey, requestParameters, + body); + } + }; + var builder = connSvc.setupConnection(HttpMethodEnum.GET, "fake-bucket-name", + "fake-object-key", Map.of(), null); + Assertions.assertNotNull(builder); + } + +}