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

casion pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
     new f8f2489eb feat: linkis-module unit test add
     new bbd1d73bd Merge pull request #3787 from 
ruY9527/dev-1.3.1-linkis-module-unit-test
f8f2489eb is described below

commit f8f2489eb7013cd14704bf3a4386e378e17d2216
Author: ruY9527 <[email protected]>
AuthorDate: Sat Nov 5 00:00:54 2022 +0800

    feat: linkis-module unit test add
---
 .../apache/linkis/server/security/SSOUtils.scala   |  3 +-
 .../LinkisModuleErrorCodeSummaryTest.java          | 61 ++++++++++++++++++++++
 .../linkis/server/utils/AopTargetUtilsTest.java    | 33 ++++++++++++
 .../src/test/resources/linkis.properties           | 21 ++++++++
 .../server/conf/ServerConfigurationTest.scala      | 55 +++++++++++++++++++
 .../server/conf/SessionHAConfigurationTest.scala   | 44 ++++++++++++++++
 .../linkis/server/security/SSOUtilsTest.scala      | 50 ++++++++++++++++++
 .../linkis/server/utils/LinkisMainHelperTest.scala | 42 +++++++++++++++
 8 files changed, 308 insertions(+), 1 deletion(-)

diff --git 
a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/security/SSOUtils.scala
 
b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/security/SSOUtils.scala
index 05ac9dbff..4fa325514 100644
--- 
a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/security/SSOUtils.scala
+++ 
b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/security/SSOUtils.scala
@@ -91,8 +91,9 @@ object SSOUtils extends Logging {
   private[security] def getUserAndLoginTime(userTicketId: String): 
Option[(String, Long)] = {
     ServerConfiguration.getUsernameByTicket(userTicketId).map { 
userAndLoginTime =>
       {
-        if (userAndLoginTime.indexOf(",") < 0)
+        if (userAndLoginTime.indexOf(",") < 0) {
           throw new IllegalUserTicketException(s"Illegal user token 
information(非法的用户token信息).")
+        }
         val index = userAndLoginTime.lastIndexOf(",")
         (userAndLoginTime.substring(0, index), 
userAndLoginTime.substring(index + 1).toLong)
       }
diff --git 
a/linkis-commons/linkis-module/src/test/java/org/apache/linkis/errorcode/LinkisModuleErrorCodeSummaryTest.java
 
b/linkis-commons/linkis-module/src/test/java/org/apache/linkis/errorcode/LinkisModuleErrorCodeSummaryTest.java
new file mode 100644
index 000000000..f4a4c59d2
--- /dev/null
+++ 
b/linkis-commons/linkis-module/src/test/java/org/apache/linkis/errorcode/LinkisModuleErrorCodeSummaryTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.linkis.errorcode;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class LinkisModuleErrorCodeSummaryTest {
+
+  @Test
+  @DisplayName("enumTest")
+  public void enumTest() {
+
+    int dataworkcloudMustVersionErrorCode =
+        LinkisModuleErrorCodeSummary.DATAWORKCLOUD_MUST_VERSION.getErrorCode();
+    int fetchMapcacheErrorErrorCode =
+        LinkisModuleErrorCodeSummary.FETCH_MAPCACHE_ERROR.getErrorCode();
+    int notExistsApplicationErrorCode =
+        LinkisModuleErrorCodeSummary.NOT_EXISTS_APPLICATION.getErrorCode();
+    int haveNotSetErrorCode = 
LinkisModuleErrorCodeSummary.HAVE_NOT_SET.getErrorCode();
+    int verificationCannotEmptyErrorCode =
+        LinkisModuleErrorCodeSummary.VERIFICATION_CANNOT_EMPTY.getErrorCode();
+    int loggedIdErrorCode = 
LinkisModuleErrorCodeSummary.LOGGED_ID.getErrorCode();
+    int notLoggedErrorCode = 
LinkisModuleErrorCodeSummary.NOT_LOGGED.getErrorCode();
+    int illegalIdErrorCode = 
LinkisModuleErrorCodeSummary.ILLEGAL_ID.getErrorCode();
+    int illegalUserTokenErrorCode = 
LinkisModuleErrorCodeSummary.ILLEGAL_USER_TOKEN.getErrorCode();
+    int serverssocketNotExistErrorCode =
+        LinkisModuleErrorCodeSummary.SERVERSSOCKET_NOT_EXIST.getErrorCode();
+    int websocketIsFullErrorCode = 
LinkisModuleErrorCodeSummary.WEBSOCKET_IS_FULL.getErrorCode();
+    int websocketStoppedErrorCode = 
LinkisModuleErrorCodeSummary.WEBSOCKET_STOPPED.getErrorCode();
+
+    Assertions.assertTrue(10010 == dataworkcloudMustVersionErrorCode);
+    Assertions.assertTrue(10021 == fetchMapcacheErrorErrorCode);
+    Assertions.assertTrue(10050 == notExistsApplicationErrorCode);
+    Assertions.assertTrue(11000 == haveNotSetErrorCode);
+    Assertions.assertTrue(11001 == verificationCannotEmptyErrorCode);
+    Assertions.assertTrue(11002 == loggedIdErrorCode);
+    Assertions.assertTrue(11002 == notLoggedErrorCode);
+    Assertions.assertTrue(11003 == illegalIdErrorCode);
+    Assertions.assertTrue(11003 == illegalUserTokenErrorCode);
+    Assertions.assertTrue(11004 == serverssocketNotExistErrorCode);
+    Assertions.assertTrue(11005 == websocketIsFullErrorCode);
+    Assertions.assertTrue(11035 == websocketStoppedErrorCode);
+  }
+}
diff --git 
a/linkis-commons/linkis-module/src/test/java/org/apache/linkis/server/utils/AopTargetUtilsTest.java
 
b/linkis-commons/linkis-module/src/test/java/org/apache/linkis/server/utils/AopTargetUtilsTest.java
new file mode 100644
index 000000000..ba7a6d24e
--- /dev/null
+++ 
b/linkis-commons/linkis-module/src/test/java/org/apache/linkis/server/utils/AopTargetUtilsTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.linkis.server.utils;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class AopTargetUtilsTest {
+
+  @Test
+  @DisplayName("getTargetTest")
+  public void getTargetTest() throws Exception {
+
+    Object target = AopTargetUtils.getTarget(new Object());
+    Assertions.assertNotNull(target);
+  }
+}
diff --git a/linkis-commons/linkis-module/src/test/resources/linkis.properties 
b/linkis-commons/linkis-module/src/test/resources/linkis.properties
new file mode 100644
index 000000000..1c575edc5
--- /dev/null
+++ b/linkis-commons/linkis-module/src/test/resources/linkis.properties
@@ -0,0 +1,21 @@
+# 
+# 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.
+#
+
+#wds.linkis.test.mode=true
+wds.linkis.server.version=v1
+
+#test
+wds.linkis.test.mode=true
+wds.linkis.test.user=hadoop
\ No newline at end of file
diff --git 
a/linkis-commons/linkis-module/src/test/scala/org/apache/linkis/server/conf/ServerConfigurationTest.scala
 
b/linkis-commons/linkis-module/src/test/scala/org/apache/linkis/server/conf/ServerConfigurationTest.scala
new file mode 100644
index 000000000..cbe56cfcc
--- /dev/null
+++ 
b/linkis-commons/linkis-module/src/test/scala/org/apache/linkis/server/conf/ServerConfigurationTest.scala
@@ -0,0 +1,55 @@
+/*
+ * 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.linkis.server.conf
+
+import org.junit.jupiter.api.{Assertions, DisplayName, Test}
+
+class ServerConfigurationTest {
+
+  @Test
+  @DisplayName("constTest")
+  def constTest(): Unit = {
+
+    val bdpServerExcludePackagesStr = 
ServerConfiguration.BDP_SERVER_EXCLUDE_PACKAGES.getValue
+    val bdpServerExcludeClassesStr = 
ServerConfiguration.BDP_SERVER_EXCLUDE_CLASSES.getValue
+    val bdpServerExcludeAnnotation = 
ServerConfiguration.BDP_SERVER_EXCLUDE_ANNOTATION.getValue
+    val bdpServerSpringApplicationStr =
+      ServerConfiguration.BDP_SERVER_SPRING_APPLICATION_LISTENERS.getValue
+    val bdpserverversion = ServerConfiguration.BDP_SERVER_VERSION
+    val bdpTestUser = ServerConfiguration.BDP_TEST_USER.getValue
+    val bdpServerHome = ServerConfiguration.BDP_SERVER_HOME.getValue
+    val bdpServerDistinctMode = 
ServerConfiguration.BDP_SERVER_DISTINCT_MODE.getValue
+    val bdpServerSocketMode = 
ServerConfiguration.BDP_SERVER_SOCKET_MODE.getValue
+    val bdpServerIdentString = 
ServerConfiguration.BDP_SERVER_IDENT_STRING.getValue
+    val bdpServerPort = ServerConfiguration.BDP_SERVER_PORT.getValue
+
+    Assertions.assertEquals("", bdpServerExcludePackagesStr)
+    Assertions.assertEquals("", bdpServerExcludeClassesStr)
+    Assertions.assertEquals("", bdpServerExcludeAnnotation)
+    Assertions.assertEquals("", bdpServerSpringApplicationStr)
+    Assertions.assertEquals("v1", bdpserverversion)
+    Assertions.assertEquals("hadoop", bdpTestUser)
+    Assertions.assertEquals("", bdpServerHome)
+    Assertions.assertTrue(bdpServerDistinctMode)
+    Assertions.assertFalse(bdpServerSocketMode)
+    Assertions.assertEquals("true", bdpServerIdentString)
+    Assertions.assertTrue(20303 == bdpServerPort.intValue())
+
+  }
+
+}
diff --git 
a/linkis-commons/linkis-module/src/test/scala/org/apache/linkis/server/conf/SessionHAConfigurationTest.scala
 
b/linkis-commons/linkis-module/src/test/scala/org/apache/linkis/server/conf/SessionHAConfigurationTest.scala
new file mode 100644
index 000000000..c2f50656f
--- /dev/null
+++ 
b/linkis-commons/linkis-module/src/test/scala/org/apache/linkis/server/conf/SessionHAConfigurationTest.scala
@@ -0,0 +1,44 @@
+/*
+ * 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.linkis.server.conf
+
+import org.junit.jupiter.api.{Assertions, DisplayName, Test}
+
+class SessionHAConfigurationTest {
+
+  @Test
+  @DisplayName("constTest")
+  def constTest(): Unit = {
+
+    val redisHost = SessionHAConfiguration.RedisHost
+    val password = SessionHAConfiguration.RedisPassword
+    val redisPort = SessionHAConfiguration.RedisPort
+    val redisSentinalMaster = SessionHAConfiguration.RedisSentinalMaster
+    val redisSentinalServer = SessionHAConfiguration.RedisSentinalServer
+    val ssoRedis = SessionHAConfiguration.SsoRedis
+
+    Assertions.assertEquals("127.0.0.1", redisHost)
+    Assertions.assertEquals("", password)
+    Assertions.assertTrue(6379 == redisPort.intValue())
+    Assertions.assertEquals("", redisSentinalMaster)
+    Assertions.assertEquals("", redisSentinalServer)
+    Assertions.assertFalse(ssoRedis)
+
+  }
+
+}
diff --git 
a/linkis-commons/linkis-module/src/test/scala/org/apache/linkis/server/security/SSOUtilsTest.scala
 
b/linkis-commons/linkis-module/src/test/scala/org/apache/linkis/server/security/SSOUtilsTest.scala
new file mode 100644
index 000000000..feb7d602a
--- /dev/null
+++ 
b/linkis-commons/linkis-module/src/test/scala/org/apache/linkis/server/security/SSOUtilsTest.scala
@@ -0,0 +1,50 @@
+/*
+ * 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.linkis.server.security
+
+import org.junit.jupiter.api.{Assertions, DisplayName, Test}
+
+class SSOUtilsTest {
+
+  @Test
+  @DisplayName("constTest")
+  def constTest(): Unit = {
+
+    val sslEnable = SSOUtils.sslEnable
+    Assertions.assertFalse(sslEnable)
+
+  }
+
+  @Test
+  @DisplayName("getUserTicketIdMapTest")
+  def getUserTicketIdMapTest(): Unit = {
+
+    val ticketIdMap = SSOUtils.getUserTicketIdMap
+    Assertions.assertNotNull(ticketIdMap)
+
+  }
+
+  @Test
+  @DisplayName("decryptLoginTest")
+  def decryptLoginTest(): Unit = {
+
+    val decryptPwd = SSOUtils.decryptLogin("hadoop")
+    Assertions.assertNotNull(decryptPwd)
+  }
+
+}
diff --git 
a/linkis-commons/linkis-module/src/test/scala/org/apache/linkis/server/utils/LinkisMainHelperTest.scala
 
b/linkis-commons/linkis-module/src/test/scala/org/apache/linkis/server/utils/LinkisMainHelperTest.scala
new file mode 100644
index 000000000..b90b09a51
--- /dev/null
+++ 
b/linkis-commons/linkis-module/src/test/scala/org/apache/linkis/server/utils/LinkisMainHelperTest.scala
@@ -0,0 +1,42 @@
+/*
+ * 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.linkis.server.utils
+
+import org.junit.jupiter.api.{Assertions, DisplayName, Test}
+
+class LinkisMainHelperTest {
+
+  @Test
+  @DisplayName("constTest")
+  def constTest(): Unit = {
+
+    val servernamekey = LinkisMainHelper.SERVER_NAME_KEY
+    Assertions.assertEquals("serviceName", servernamekey)
+
+  }
+
+  @Test
+  @DisplayName("getExtraSpringOptionsTest")
+  def getExtraSpringOptionsTest(): Unit = {
+
+    val array = LinkisMainHelper.getExtraSpringOptions("dev")
+    Assertions.assertTrue(array.length > 0)
+
+  }
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to