bugfix - username capitalization problem 13/130313/1
authorGuangrong Fu <fu.guangrong@zte.com.cn>
Wed, 17 Aug 2022 00:41:44 +0000 (08:41 +0800)
committerGuangrong Fu <fu.guangrong@zte.com.cn>
Wed, 17 Aug 2022 00:41:44 +0000 (08:41 +0800)
Issue-ID: HOLMES-564
Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
Change-Id: Ifa350d406f5fc7549c88bf5b50a8bc111d76fd8c

12 files changed:
holmes-actions/pom.xml
holmes-actions/src/main/java/org/onap/holmes/common/database/DbDaoUtil.java
holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/ClosedLoopControlNameCache.java
holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/UniqueRequestIdCache.java
holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityMapper.java
holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java
holmes-actions/src/main/java/org/onap/holmes/common/utils/CorrelationRuleMapper.java
holmes-actions/src/main/java/org/onap/holmes/common/utils/GsonUtil.java
holmes-actions/src/main/java/org/onap/holmes/common/utils/UserUtil.java
holmes-actions/src/test/java/org/onap/holmes/common/utils/UserUtilTest.java
pom.xml
version.properties

index 8c74bca..5687d18 100644 (file)
@@ -12,7 +12,7 @@
     <parent>\r
         <groupId>org.onap.holmes.common</groupId>\r
         <artifactId>holmes-common-parent</artifactId>\r
-        <version>1.4.3-SNAPSHOT</version>\r
+        <version>1.4.4-SNAPSHOT</version>\r
     </parent>\r
 \r
     <name>holmes-common-service</name>\r
index 2cbb538..15f49e4 100644 (file)
@@ -1,5 +1,5 @@
 /**\r
- * Copyright 2017-2021 ZTE Corporation.\r
+ * Copyright 2017-2022 ZTE Corporation.\r
  * <p>\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
index 89514dc..cd47431 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2020-2021 ZTE Corporation.
+ * Copyright 2020-2022 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 8c68776..6a65b0c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2020-2021 ZTE Corporation.
+ * Copyright 2020-2022 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 5432027..3dc652e 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright 2020-2021 ZTE Corporation.
+ * Copyright 2020-2022 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 996df25..e9755e8 100644 (file)
@@ -1,5 +1,5 @@
 /**\r
- * Copyright 2017-2021 ZTE Corporation.\r
+ * Copyright 2017-2022 ZTE Corporation.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
index ed1c581..835d059 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017-2021 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index f5ad56c..e43a68e 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright 2018-2021 ZTE Corporation.
+ * Copyright 2018-2022 ZTE Corporation.
  * <p>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index f0ff8d9..5400b20 100644 (file)
@@ -1,5 +1,5 @@
 /**\r
- * Copyright 2017 ZTE Corporation.\r
+ * Copyright 2017-2022 ZTE Corporation.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  */\r
 package org.onap.holmes.common.utils;\r
 \r
-import javax.servlet.http.HttpServletRequest;\r
 import org.onap.holmes.common.constant.AlarmConst;\r
 \r
+import javax.servlet.http.HttpServletRequest;\r
+\r
 public class UserUtil {\r
 \r
     private UserUtil() {\r
@@ -25,11 +26,7 @@ public class UserUtil {
     }\r
 \r
     public static String getUserName(HttpServletRequest request) {\r
-        String userName = AlarmConst.ADMIN;\r
-        String sessionName = request.getHeader("username");\r
-        if (sessionName != null) {\r
-            userName = sessionName.toLowerCase();\r
-        }\r
-        return userName;\r
+        return request.getHeader("username") == null ?\r
+                AlarmConst.ADMIN : request.getHeader("username");\r
     }\r
 }\r
index d88525a..7b452f0 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.holmes.common.utils;
 
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-
-import javax.servlet.http.HttpServletRequest;
 import org.easymock.EasyMock;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.powermock.api.easymock.PowerMock;
+
+import javax.servlet.http.HttpServletRequest;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
 public class UserUtilTest {
 
     private HttpServletRequest request;
@@ -39,29 +40,25 @@ public class UserUtilTest {
     }
 
     @Test
-    public void getUserName_header_name_empty() throws Exception {
+    public void getUserName_header_name_empty() {
         EasyMock.expect(request.getHeader("username")).andReturn(null);
 
         PowerMock.replayAll();
 
-        String userName = UserUtil.getUserName(request);
+        assertThat("admin", equalTo(UserUtil.getUserName(request)));
 
         PowerMock.verifyAll();
-
-        assertThat("admin", equalTo(userName));
     }
 
     @Test
-    public void getUserName_normal() throws Exception {
-        EasyMock.expect(request.getHeader("username")).andReturn("name1");
+    public void getUserName_normal() {
+        EasyMock.expect(request.getHeader("username")).andReturn("Name").times(2);
 
         PowerMock.replayAll();
 
-        String userName = UserUtil.getUserName(request);
+        assertThat("Name", equalTo(UserUtil.getUserName(request)));
 
         PowerMock.verifyAll();
-
-        assertThat("name1", equalTo(userName));
     }
 
 } 
diff --git a/pom.xml b/pom.xml
index cda749e..19a1f22 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -20,7 +20,7 @@
     <artifactId>holmes-common-parent</artifactId>\r
     <packaging>pom</packaging>\r
 \r
-    <version>1.4.3-SNAPSHOT</version>\r
+    <version>1.4.4-SNAPSHOT</version>\r
     <name>holmes-common</name>\r
     <modules>\r
         <module>holmes-actions</module>\r
index 5abc35c..4761c30 100644 (file)
@@ -4,7 +4,7 @@
 \r
 major=1\r
 minor=4\r
-patch=3\r
+patch=4\r
 \r
 base_version=${major}.${minor}.${patch}\r
 \r